var checked = false;
var checked_new_user = false;
var checked_new_email = false;
var totFBTWNavlink = 0;

/**************** START NEW SIGNUP PAGE SCRIPTS *************************/


function validate_new_signup(txt){
  var nickName = document.getElementById('user_login').value;
  var password = document.getElementById('user_password').value;
  var retValue=false;
  document.getElementById('signupType').value = txt;
  nickNameMatch = nickName.match(/((^(\w*)([-_]*\w+)*)(\d+)$)|(^(\d+)((\w*)([-_]*\w+)*)$)|(^(\d+)((\w*)([-_]*\w+)*)(\d+)$)/)
  
  if((nickName =="" || nickName =="YourName1") && password==""){
    alert("Please enter your Nickname & Password.");
    retValue=false;
  }
  else if((nickName == "" || nickName == "YourName1") && password != ""){
    if(password.length <= 4){
      alert("Please enter your Nickname & Invalid Password.");
    }else{
      alert("Please enter your Nickname.");
      retValue=false;
    }
  }else if((nickName != "" || nickName != "YourName1") && password == ""){
    if(!nickNameMatch){
      alert("Invalid Nickname & Please enter your Password.");
    }else{
      alert("Please enter your Password.");
      retValue=false;
    }
  }
  else if((nickName != "" || nickName != "YourName1") && password != ""){
    if(!nickNameMatch && password.length <=4){
      alert("Invalid NickName & Password & Please refer help icon.");
      retValue=false;
    }
    else if(!nickNameMatch){
      alert("Invalid NickName & Please refer help icon.");
      retValue=false;
    }else if(password.length <=4){
      alert("Invalid Password & Please refer help icon.");
      retValue=false;
    }
    else{
      retValue=true;
    }
  } 
  
  if (checked_new_user){ //Vlidation for old user
    retValue=false;
  }
  
  
  return retValue;
} 

function brandMoreLinks(type, length,flag){
  if (flag == "signup"){
    for (i=5  ; i<=length-1; i++){
      div_id = "facebook_navlink_row_" + i;
      if(document.getElementById(div_id))
       document.getElementById(div_id).style.display='block';
    }
    document.getElementById('fb_link_display_count').innerHTML=length;
  }
  else if( flag == "hub"){
    for (i=5  ; i<=length-1; i++){
      if (type == "facebook"){
        div_id = "facebook_navlink_row_" + i;
      }else{
        div_id = "twitter_navlink_row_" + i;
      }
      if(document.getElementById(div_id)){
        alert(" document.getElementById(div_id).style.display before : " + document.getElementById(div_id).style.display);
        document.getElementById(div_id).style.display='block';
        alert(" document.getElementById(div_id).style.display After : " + document.getElementById(div_id).style.display);
      }
    }
    if (type == "facebook"){
      document.getElementById('fb_link_display_count').innerHTML=length;
    }else{
      document.getElementById('tw_link_display_count').innerHTML=length;
    }
  }else{
    if(document.getElementById("more_facebook_navlink")){
      if (document.getElementById("more_facebook_navlink").innerHTML == "FETCH OLDER LINKS FROM FACEBOOK"){
        for (i=7; i<=length-1; i++){
          div_id = "facebook_navlink_row_" + i;
          if(document.getElementById(div_id))
            document.getElementById(div_id).style.display='block';
            
          document.getElementById("display_fb_navlink_count").innerHTML=length-1;  
        }
      
      }
    
    }else{
      for (i=5; i<length-1; i++){
        alert("**** i *****" + i);
        if (i==7){
          document.getElementById("display_fb_navlink_count").innerHTML=i;
          document.getElementById("more_facebook_navlink").innerHTML="FETCH OLDER LINKS FROM FACEBOOK";
          break;
        }
        div_id = "facebook_navlink_row_" + i;
        if(document.getElementById(div_id))
          document.getElementById(div_id).style.display='block';
          
        document.getElementById("display_fb_navlink_count").innerHTML=i;  
      }
    }
  }
  
  return false;
}


function brandMoreLinksTwitter(type, length,flag){
  if (flag == "signup"){
    for (i=5  ; i<length-1; i++){
      div_id = "twitter_navlink_row_" + i;
      if(document.getElementById(div_id))
       document.getElementById(div_id).style.display='block';
      }
  }
  else{
    for (i=5; i<length-1; i++){
      div_id = "twitter_navlink_row_" + i;
      if(document.getElementById(div_id))
       document.getElementById(div_id).style.display='block';
    }
  
  }
  
  return false;
}





/*
function validate_new_signup(txt){
  alert("****** validate_new_signup ********");
  alert("****** txt ********" + txt);
  var text_box1 = document.getElementById('user_login').value
  var text_box2 = document.getElementById('user_password').value
  document.getElementById('signupType').value = txt;
  if (text_box1 !='' && text_box2 !='' ){
    if (text_box1.length >= 4 && text_box1.length >=3){
      retValue=true;
    }else{
      retValue=false;
    }
  }else {
    retValue=false;
  }
  
  if (checked_new_user){
    retValue=false;
  }
  
  if (text_box1 == "YourName1" && text_box2 =='' ){
    alert("Please enter your Nickname & Password.");
    retValue=false;
  }else if((text_box1 =='' || text_box1 == "YourName1") && text_box2 !='' ){
    alert("Please enter your Nickname.");
    retValue=false;
  }else{
  
  }
  
  return retValue;
} */

function validation_tw_fb_navlink(flag, length){
  retValue=true;
  if (flag == "tw_save"){
    for(i=0; i<length; i++){
      var twitter_navlink_term = "twitter_navlink_term_"+i;
      if (document.getElementById(twitter_navlink_term).value == ""){
        document.getElementById('twitter_navlinks').style.display='block';
        document.getElementById('twitter_navlinks').innerHTML='Term name can\'t be blank.';
        retValue=false;
      }else{
        //document.getElementById('tw_fb_navlinks').style.display='none';
        //document.getElementById('tw_fb_navlinks').innerHTML='';
        //retValue=true;
      }
    }  
    if(retValue){
      document.getElementById('twitter_navlinks').style.display='none';
      document.getElementById('twitter_navlinks').innerHTML='';
    }
   
  }else if (flag == "fb_save"){
    for(i=0; i<length; i++){
      var facebook_navlink_term = "facebook_navlink_term_"+i;
      if (document.getElementById(facebook_navlink_term).value == ""){
        document.getElementById('facebook_navlinks').style.display='block';
        document.getElementById('facebook_navlinks').innerHTML='Term name can\'t be blank.';
        retValue=false;
      }else{
        //document.getElementById('tw_fb_navlinks').style.display='none';
        //document.getElementById('tw_fb_navlinks').innerHTML='';
        //retValue=true;
      }
    }  
    if(retValue){
      document.getElementById('facebook_navlinks').style.display='none';
      document.getElementById('facebook_navlinks').innerHTML='';
    }
   
  }else if (flag=="brand_more_links"){
    retValue=false;
  }else if (flag=="brand_links_from_facebook"){
    retValue=false;
  }else if (flag=="brand_links_from_twitter"){
    retValue=false;
  }else{
    retValue=false;
  }
  return retValue;
}

function inav2_signup_check(type){
  var term = document.getElementById('tou').checked;
  var policy = document.getElementById('pp').checked;
  var user_email = document.getElementById('user_email').value;
 
  if (type == "inav2"){
    document.getElementById('spinner_signup').style.display='none';
    var captcha = document.getElementById('recaptcha_response_field').value;
  }
  
  var error = false;
  msg = ""
  
  
  if(user_email == "") {
    msg= "Email"
    error = true;
  }
  
  if(user_email != "") {
  
    if (user_email == "Add your email here."){
      msg= "Email"
      error = true;
    }
    /*else{
      userEmailMatch = user_email.match(/[0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9}/)
      if(userEmailMatch == null){
        msg = "Invaild Email"
        error = true;
      }else{
        msg= "Email"
        error = true;
      }  
    } */
  }
  
  if(type== "inav2"){
    if(captcha==''){
      if(msg==''){
        msg= "Captcha"
      }else{
        msg+= ", Captcha"
      }
      error = true;
    }
  }
  
  if(term == false){
    if(msg==''){
    msg= "Term of use"
    }else{
    msg+= ", Term of use"
    }
    error = true;
  }
  
  if(policy == false){
    if(msg==''){
    msg= "Private Policy"
    }else{
    msg+= ", Private Policy"
    }
    error = true;
  }
  
  if (error){
    document.getElementById('cookie_err').innerHTML = "Please enter the following fields " + msg + ".";
    document.getElementById('cookie_err').style.display='block';
    
    return false;
  
  }
  else if (checked_new_email){
    return false;
  }else{
    document.getElementById('cookie_err').style.display='none';
    document.getElementById('spinner_signup').style.display='block';
    return true;
  }

}

/*
function inav2_signup_check(){
    var flag = true;
    var validation_check = new Array();
    var check_text_box = document.getElementById('textbox_collect').getElementsByTagName("input");
    var tou = document.getElementById('tou').checked
    var pp = document.getElementById('pp').checked
     if (tou == true && pp == true){
        for(var i=0;i<check_text_box.length;i++){
            
            if (check_text_box[i].value =='' ){
                validation_check[i] = false;
            }else {
                validation_check[i] = true;
            }
        }
        for(var i=0;i<validation_check.length;i++){
            if (validation_check[i] == false)
                flag = false;
        }

    }else{
        document.getElementById('cookie_err').innerHTML = "Please check the textbox to continue.";
        document.getElementById('cookie_err').style.display='block';
        return false;
    }
    
    if (checked_new_email){
      flag=false;
    }
    
    return flag;
} */

function validate_signup(){
    var flag = true;
    var validation_check = new Array();
    var check_text_box = document.getElementById('in-rightside-bar').getElementsByTagName("input");
    for(var i=0;i<check_text_box.length;i++){
        
        if (check_text_box[i].value !='' ){
            if (i==0){
                if (check_text_box[i].value.length >= 4)
                    validation_check[i] = true;
                else
                    validation_check[i] = false;
            }
            else{
                if (check_text_box[i].value.length >= 3)
                    validation_check[i] = true;
                else
                    validation_check[i] = false;
            }
        }else {
            validation_check[i] = false;
        }
    }
    
    for(var i=0;i<validation_check.length;i++){
        if (validation_check[i] == false)
            flag = false;        
    }
    return flag;  
}

function validate_password_edit(){
    
    var flag_password_edit = true;
    var validation_check_password_edit = new Array();
    var check_text_box_password_edit = document.getElementById('password_edit_div').getElementsByTagName("input");
    for(var i=0;i<check_text_box_password_edit.length;i++){
        if (check_text_box_password_edit[i].value !='' ){
            if (check_text_box_password_edit[i].value.length >= 5)
                validation_check_password_edit[i] = true;
            else
                validation_check_password_edit[i] = false;
        }else {
            validation_check_password_edit[i] = false;
        }
    }
    for(var i=0;i<validation_check_password_edit.length;i++){
        if (validation_check_password_edit[i] == false)
            flag_password_edit = false;
    }

    if(flag_password_edit){
        return flag_password_edit;
    }else{
        var element_id = document.getElementById('current_user_err');
        element_id.innerHTML='Please fill all the textboxes with 6 characters..';
        element_id.style.display='block';
        return flag_password_edit;
    }
}

function validate_login(){

    if(document.getElementById('login').value =='' || document.getElementById('password').value ==''){
        var element_id = document.getElementById('login_err');
        element_id.innerHTML='Please fill the textboxe(s) to login.';
        element_id.style.display='block';
        return false;
    }else{
        return true;
    }
}

function validate_forget_password(){
    if(document.getElementById('email').value ==''){
        var element_id = document.getElementById('forget_password_err');
        element_id.innerHTML='Please fill the textbox.';
        element_id.style.display='block';
        return false;
    }else{
        return true;
    }
}

function validate_reset_password(){
    var new_password = document.getElementById('user_password').value;
    var confirm_password = document.getElementById('user_password_confirmation').value;
    var element_id = document.getElementById('reset_password_err');
    if(new_password =='' || confirm_password ==''){
        element_id.innerHTML='Please fill the textbox(es).';
        element_id.style.display='block';
        return false;
    //    } else if(new_password != confirm_password){
    //        element_id.innerHTML='Please fill the textbox.';
    //        element_id.style.display='block';
    //        return false;
    }else{
        return true;
    }
}

function reset_signup(){
    var reset_text_box = document.getElementById('in-rightside-bar').getElementsByTagName("input");
    for(var i=0;i<reset_text_box.length-1;i++){
        reset_text_box[i].value ='';
    }
}

/**************** END NEW SIGNUP PAGE SCRIPTS *************************/

function toggleDisable(type, mode){
    if(type == "networking"){
        document.getElementById('twitter_id').disabled = mode;
        document.getElementById('twitter_pwd_id').disabled = mode;
        document.getElementById('facebook_id').disabled = mode;
        document.getElementById('facebook_pwd_id').disabled = mode;
        document.getElementById('myspace_id').disabled = mode;
        document.getElementById('myspace_pwd_id').disabled = mode;
        document.getElementById('googletalk_id').disabled = mode;
        document.getElementById('googletalk_pwd_id').disabled = mode;
    }
    else{
        document.getElementById('digg_id').disabled = mode;
        document.getElementById('delicious_id').disabled = mode;
        document.getElementById('stumbleupon_id').disabled = mode;
        document.getElementById('reddit_id').disabled = mode;
    }
}

function checkAll(form_name) {
    if (checked == false){
        checked = true;
        if(form_name.name == 'bookmark_form') {
            bookmark_toggle_display('inline');
            toggleDisable('bookmarking', false)
        }else{
            network_toggle_display('inline');
            toggleDisable('networking', false);
        }
    }
    else{
        checked = false;
        if(form_name.name == 'bookmark_form'){
            bookmark_toggle_display('none');
        }else{
            network_toggle_display('none');
            toggleDisable(true);
        }
    }
    toggleCHECKED(form_name, checked)
}

function toggleCHECKED(form_name, checked){
    for (var i =0; i < form_name.elements.length; i++) {
        form_name.elements[i].checked = checked;
    }
}

function bookmark_toggle_display(display_mode){
    document.getElementById('digg').style.display = display_mode;
    document.getElementById('delicious').style.display = display_mode;
    document.getElementById('stumbleupon').style.display = display_mode;
    document.getElementById('reddit').style.display = display_mode;
}

function network_toggle_display(display_mode){
    document.getElementById('twitter').style.display = display_mode;
    document.getElementById('twitter_pwd').style.display = display_mode;
    document.getElementById('facebook').style.display = display_mode;
    document.getElementById('facebook_pwd').style.display = display_mode;
    document.getElementById('myspace').style.display = display_mode;
    document.getElementById('myspace_pwd').style.display = display_mode;
    document.getElementById('googletalk').style.display = display_mode;
    document.getElementById('googletalk_pwd').style.display = display_mode;
}

function check_individual_bookmark(status, toggle_div, user_name ){
    if(status.checked){
        document.getElementById(toggle_div).style.display = 'inline';
        document.getElementById(user_name).disabled = false;
    }
    else{
        document.getElementById(toggle_div).style.display = 'none';
        document.getElementById(user_name).disabled = true;
    }
}
  
function check_individual_network(status, toggle_div_user, toggle_div_pwd, user_name, password){
    if(status.checked) {
        document.getElementById(toggle_div_user).style.display = 'inline';
        document.getElementById(toggle_div_pwd).style.display = 'inline';
        document.getElementById(user_name).disabled = false;
        document.getElementById(password).disabled = false;
    }
    else{
        document.getElementById(toggle_div_user).style.display = 'none';
        document.getElementById(toggle_div_pwd).style.display = 'none';
        document.getElementById(user_name).disabled = true;
        document.getElementById(password).disabled = true;
    }
} 

function publishLayoutFormat(data, count, hub_id, layout_type){

    alias_label = 'publish_aliasname_label_' + count;
    alias_txt = 'publish_aliasname_text_box_' + count;
    alias_input_txt = 'network_alias_name_' + count;
    twitter_button = 'publish_twitter_button_' + count;
    publish_success_wrong = 'publish_success_wrong_icon_' + count
    facebook_button = 'publish_facebook_button_' + count;
    linkedin_button = 'publish_linkedin_button_' + count;
    publish_icon = 'publish_icon_' + count;
  
  
    if ($('adminpanel-div-main-new-hub')){
        var dimensions = $('adminpanel-div-main-new-hub').getDimensions();
        var height_navlinker = dimensions.height;
        var width_navlinker = dimensions.width;
        document.getElementById('spinner_layout_div_admin').style.width=width_navlinker;
        document.getElementById('spinner_layout_div_admin').style.height=height_navlinker;
        document.getElementById('spinner_layout_div_image_admin').style.width= width_navlinker;
        document.getElementById('spinner_layout_div_image_admin').style.height= height_navlinker;
    }
  
  
    if(data.value == "twitter"){
        document.getElementById(alias_label).style.display = 'block';
        document.getElementById(alias_label).style.paddingLeft = '10px';
        document.getElementById(alias_txt).style.display = 'block';
        document.getElementById(twitter_button).style.display = 'block';
        document.getElementById(facebook_button).style.display = 'none';
        document.getElementById(linkedin_button).style.display = 'none';
        document.getElementById(publish_success_wrong).style.display = 'none';
        document.getElementById(publish_icon).style.display = 'block';
        document
        allforms = document.getElementsByTagName("form");
        for (i = 0; i < allforms.length; i++) {
            form_name = "publish_form_" + count
            if(form_name == allforms[i].id){
                div_id = 'publish_process_icon_' + count;
                allforms[i].setAttribute("onSubmit","new Ajax.Request('/sign_in_twitter/sign_in_with_twitter?hub_id=" + hub_id + "&count=" + count + "&layout_type=" + layout_type+ "',{asynchronous:true, evalScripts:true, onComplete:function(request){}, onLoading:function(request){}, parameters:Form.serialize(this)}); return false;");
            }
        }
        if (count > 5){
            delete_button  = 'row_delete_network_' + count;
            document.getElementById(delete_button).style.paddingLeft = '75px';
        }
    }
    else if(data.value == "facebook"){
        document.getElementById(alias_label).style.display = 'block';
        document.getElementById(alias_label).style.paddingLeft = '10px';
        document.getElementById(alias_txt).style.display = 'block';
        document.getElementById(twitter_button).style.display = 'none';
        document.getElementById(facebook_button).style.display = 'block';
        document.getElementById(linkedin_button).style.display = 'none';
        document.getElementById(publish_icon).style.display = 'block';
        document.getElementById(publish_success_wrong).style.display = 'none';
        allforms = document.getElementsByTagName("form");
        for (i = 0; i < allforms.length; i++) {
            form_name = "publish_form_" + count
            if(form_name == allforms[i].id){
                div_id = 'publish_process_icon_' + count;
                allforms[i].setAttribute("onSubmit","new Ajax.Request('/sign_in_facebook/new_facebook?hub_id=" + hub_id + "&count=" + count + "',{asynchronous:true, evalScripts:true, onComplete:function(request){Element.hide(\'" + div_id + "\')}, onLoading:function(request){Element.show(\'"+ div_id +"\')}, parameters:Form.serialize(this)}); return false;");
            }
        }
        if (count > 5){
            delete_button  = 'row_delete_network_' + count;
            document.getElementById(delete_button).style.paddingLeft = '75px';
        }

    }else if(data.value == "linkedin"){
        document.getElementById(alias_label).style.display = 'block';
        document.getElementById(alias_label).style.paddingLeft = '10px';
        document.getElementById(alias_txt).style.display = 'block';
        document.getElementById(twitter_button).style.display = 'none';
        document.getElementById(facebook_button).style.display = 'none';
        document.getElementById(linkedin_button).style.display = 'block';
        document.getElementById(publish_icon).style.display = 'block';
        document.getElementById(publish_success_wrong).style.display = 'none';
        allforms = document.getElementsByTagName("form");
        for (i = 0; i < allforms.length; i++) {
            form_name = "publish_form_" + count
            if(form_name == allforms[i].id){
                div_id = 'publish_process_icon_' + count;
                allforms[i].setAttribute("onSubmit","new Ajax.Request('/sign_in_linkedin/new_linkedin?hub_id=" + hub_id + "&count=" + count + "',{asynchronous:true, evalScripts:true, onComplete:function(request){Element.hide(\'" + div_id + "\')}, onLoading:function(request){Element.show(\'"+ div_id +"\')}, parameters:Form.serialize(this)}); return false;");
            }
        }
        if(count > 5){
            delete_button  = 'row_delete_network_' + count;
            document.getElementById(delete_button).style.paddingLeft = '75px';
        }

    }else{
 
}
}

function addElement() {
    var ni = document.getElementById('myDiv');
    var numi = document.getElementById('total_row');
    var num = (document.getElementById('total_row').value -1)+ 2;
    numi.value = num;
    var newdiv = document.createElement('div');
    var divIdName = 'my'+num+'Div';
    newdiv.setAttribute('id',divIdName);
    var contant_bookmark = "<div class='bookmark_odd_row' id='bookmark_tag_"+num+"'>"
    contant_bookmark +=   "<div class='bookmark-service'><select name='bookmark[]' id='bookmark_service_"+num+"' style='color:#008000;'><option value=''></option><option value='digg'>Digg</option><option value='delicious'>Delicious</option><option value='stumbleupon' disabled='disabled'>StumbleUpon</option><option value='reddit' disabled='disabled'>Reddit</option></select></div>"
    contant_bookmark +=   "<span  class='bookmark-font-size' onmouseover=\"Tip('This is the account name',SHADOW, false, STICKY, 1, CLICKCLOSE, true, PADDING, 5, TEXTALIGN, \'left\', OFFSETX, -10);return false\" onmouseout=\"UnTip();\">User Name:</span>";
    //contant_bookmark += "<span class='bookmark-font-size' tooltipText=\"<span class='tool-tip-network-user'>This is the account name</span>\" onmouseout=\"DHTMLgoodies_globalTooltipObj.__hideTooltipFromLink();return false\">User Name:</span>"
    contant_bookmark += "<div class='bookmark-curve-text-box'><div class='center-line-textbox'><div class='left-curve-textbox'><div class='right-curve-textbox'>";
    contant_bookmark += "<input type='text' name='user_name[]'  value='' class='username_bookmark' style='border:0px solid #ffffff;' id='bookmark_user_name_"+num+"' onmouseover=\"text_box_over(true,'bookmark_user_name_"+num+"')\" onmouseout=\"text_box_over(false,'bookmark_user_name_"+num+"')\" onfocus=\"text_box_over(true,'bookmark_user_name_"+num+"')\" onblur=\"text_box_over(false,'bookmark_user_name_"+num+"')\" />&nbsp;"
    contant_bookmark += "</div></div></div></div>"
    contant_bookmark +=   "<div class='bookmark-row-delete'><input type='image' src='../images/social/3-1.png'  class='row_delete' onclick=\"removeElement('"+divIdName+"');\" onmouseover=\"Tip('Delete',SHADOW, false, STICKY, 1, CLICKCLOSE, true, PADDING, 5, TEXTALIGN, \'left\', OFFSETX, -10);return false\" onmouseout=\"UnTip();\"/></div>"
    contant_bookmark +=   "</div>";
    
    newdiv.innerHTML = contant_bookmark
    ni.appendChild(newdiv);
}
 
function removeElement(divNum) {
    var d = document.getElementById('myDiv');
    var olddiv = document.getElementById(divNum);
    d.removeChild(document.getElementById(divNum));
}

 
// ADD EXTRA SERVICES
function add_row_network() {
    var ni = document.getElementById('network_div');
    var numi = document.getElementById('total_row_network');
    var num = (document.getElementById('total_row_network').value -1)+ 2;
    numi.value = num;
    var newdiv = document.createElement('div');
    var divIdName = 'my'+num+'Div';
    newdiv.setAttribute('id',divIdName);
    var contant_network = "<div class='network_odd_row' id='network_twitter_tag_"+num+"'>"
    
    contant_network +=   "<div class='network-service'><select onChange='publishLayoutFormat(this, "+num+");' name='network[]' id='network_service_"+num+"' style='color:#008000;' >"
    contant_network += "<option value=''></option><option value='twitter'>Twitter</option><option value='facebook'> Facebook</option><option disabled='disabled'> Myspace</option><option disabled='disabled'> Googletalk</option></select>"
    contant_network += "</select></div>"
    
    contant_network +=   "<span id='publish_username_label_"+num+"' class='network-font-size' onmouseover=\"Tip('This is the account name',SHADOW, false, STICKY, 1, CLICKCLOSE, true, PADDING, 5, TEXTALIGN, \'left\', OFFSETX, -10);return false\" onmouseout=\"UnTip();\">User Name:</span>";
    contant_network += "<div id='publish_username_text_box_"+num+"' class='network-curve-text-box'><div class='center-line-textbox'><div class='left-curve-textbox'><div class='right-curve-textbox'>";
    contant_network +=   "<input type='text' name='user_name[]'  value='' class='user_name_network' id='network_user_name_"+num+"'  style='border:0px solid #ffffff;' onmouseover=\"text_box_over(true,'network_user_name_"+num+"')\" onmouseout=\"text_box_over(false,'network_user_name_"+num+"')\" onfocus=\"text_box_over(true,'network_user_name_"+num+"')\" onblur=\"text_box_over(false,'network_user_name_"+num+"')\"/>"
    contant_network +="</div></div></div></div>"
    
    //This code for Password field
    contant_network +=   "<span id='publish_password_label_"+num+"' class='network-font-size'  onmouseover=\"Tip('Account Password',SHADOW, false, STICKY, 1, CLICKCLOSE, true, PADDING, 5, TEXTALIGN, 'left', OFFSETX, -10);return false\" onmouseout=\"UnTip();\">Password: </span>"
    contant_network += "<div id='publish_password_text_box_"+num+"' class='network-curve-text-box'><div class='center-line-textbox'><div class='left-curve-textbox'><div class='right-curve-textbox'>";
    contant_network +=   "<input type='password'  name='password[]'  value='' class='user_name_network' id='network_password_"+num+"'    style='border:0px solid #ffffff;'  onmouseover=\"text_box_over(true,'network_password_"+num+"')\" onmouseout=\"text_box_over(false,'network_password_"+num+"')\" onfocus=\"text_box_over(true,'network_password_"+num+"')\" onblur=\"text_box_over(false,'network_password_"+num+"')\"/>"
    contant_network +="</div></div></div></div>"
    
    contant_network +=   "<span id='publish_aliasname_label_"+num+"' class='network-font-size'  onmouseover=\"Tip('This is the name you will use <br/>when you create NavLinks and <br/>want to publish them to this service. <br/>More that one Network can be <br/>associated with an Alias.',SHADOW, false, STICKY, 1, CLICKCLOSE, true, PADDING, 5, TEXTALIGN, 'left', OFFSETX, -10);return false\" onmouseout=\"UnTip();\"> Alias Name:</span>"
    contant_network += "<div id='publish_aliasname_text_box_"+num+"' class='network-curve-text-box'><div class='center-line-textbox'><div class='left-curve-textbox'><div class='right-curve-textbox'>";
    contant_network +=   "<input type='text' name='alias_name[]'  value='' class='user_name_network' id='network_alias_name_"+num+"' style='border:0px solid #ffffff;' onmouseover=\"text_box_over(true,'network_alias_name_"+num+"')\" onmouseout=\"text_box_over(false,'network_alias_name_"+num+"')\" onfocus=\"text_box_over(true,'network_alias_name_"+num+"')\" onblur=\"text_box_over(false,'network_alias_name_"+num+"')\"/>"
    contant_network +="</div></div></div></div>"
    
    // For Sign-in-with-Twitter button 
    contant_network += "<div id='publish_twitter_button_"+num+"' style='display:none;' class='network-curve-text-box' style='border:0px solid red;margin-top:0px;'>";
    contant_network += "<a href='javascript:void(0);' onCLick=\"new Ajax.Request('/new_twitter/sign_in_with_twitter?hub_id=#{current_user.default_hub_id}',{asynchronous:true, evalScripts:true}); return false;\" >"
    contant_network += "<img src='/images/social/Sign-in-with-Twitter-darker.png.?1274967502' alt='Sign-in With Twitter'></a>"
    contant_network += "</div>"
    
    
    
    contant_network +=   "<input type='image' src='../images/social/3-1.png' id='row_delete_network_"+num+"' class='row_delete_network' onclick=\"remove_row_network('"+divIdName+"');\" onmouseover=\"Tip('Delete',SHADOW, false, STICKY, 1, CLICKCLOSE, true, PADDING, 5, TEXTALIGN, \'left\', OFFSETX, -10);return false\" onmouseout=\"UnTip();\"/>"
    contant_network +=   "</div>";
    
    newdiv.innerHTML = contant_network
    ni.appendChild(newdiv);
}

function remove_row_network(divNum) {
    var d = document.getElementById('network_div');
    var olddiv = document.getElementById(divNum);
    d.removeChild(document.getElementById(divNum));
}

function remove_row_fb_tw_navlink(mainDiv, divNum, total, divIdCountlink) {
  totFBTWNavlink = totFBTWNavlink + 1;
  var d = document.getElementById(mainDiv);
  //var olddiv = document.getElementById(divNum);
  d.removeChild(document.getElementById(divNum));
  document.getElementById(divIdCountlink).innerHTML= total - totFBTWNavlink;
}

function text_box_over(argbool,myid) {
    document.getElementById(myid).parentNode.className=argbool?"right-curve-textbox-over":"right-curve-textbox";
    document.getElementById(myid).parentNode.parentNode.className=argbool?"left-curve-textbox-over":"left-curve-textbox";
    document.getElementById(myid).parentNode.parentNode.parentNode.className=argbool?"center-line-textbox-over":"center-line-textbox";
}

/**************** START Pagination login for navlink widget *************************/
function page_val_pre_change(current_val,total_page){
    if (total_page > 1) {
        str1 = "page_val_"+current_val
        tmp_check = current_val-1
        if (tmp_check > 0)
        {
            str2 = "page_val_"+tmp_check
            tmp = document.getElementById(str2);
            if (tmp != null)
                tmp.style.display="block";
            document.getElementById(str1).style.display="none";
        }
    }
}

function page_val_next_change(current_val,total_page){
    if (total_page > 1) {
        str1 = "page_val_"+current_val
        tmp_check = current_val+1
        if (tmp_check <= total_page)
        {
          str2 = "page_val_"+tmp_check
          tmp_div = document.getElementById(str2);
          if (tmp_div != null)
            tmp_div.style.display="block";
            document.getElementById(str1).style.display="none";
       }
        if (tmp_check == total_page) {
            str2 = "next_val_"+tmp_check
            str_next_change = "change_val_"+tmp_check
            tmp_next = document.getElementById(str2);
            if (tmp_next != null) {
                tmp_next.style.display="none";
                document.getElementById(str_next_change).innerHTML="Previous 5";
            }
        }
    }
}
/**************** END Pagination login for navlink widget *************************/

