/* FUNCTIONS USED IN THE views/posts/list.rhtml */
/************************ START *************************/


var className;
var isIE=document.all;
if (isIE){
	className = "className";
}
else{
	className = "class";
}

var create_reputation_url;

function openCreatePage()
{ 
  self.location=create_reputation_url  
}
    
  
function setPageUrl(page_url, identity_name)
{ 
  create_reputation_url=page_url;  
  //This is temperory solution for IE to remove extra padding.
  if (document.getElementById('createRepLink') != null) 
  {
  	if (navigator.appName == 'Microsoft Internet Explorer') 
	{
  		document.getElementById('createRepLink').style.width = eval(140 + identity_name.length * 7.2) + "px";
  	}
  	//Resetting Button Value
	if (identity_name) 
		document.getElementById('createRepLink').value = "Create Reputation For " + identity_name;
	//else 
	//	document.getElementById('createRepLink').value = "Create Reputation";
  } 
}


function post_table_alignment(row_no)
{
    if(navigator.appName!='Microsoft Internet Explorer') //check the browser
        { 
          for(i=0;i<=row_no;i++)
           {
                document.getElementById("post"+i+".0").width="196" 
                document.getElementById("post"+i+".1").width="241"  
                document.getElementById("post"+i+".2").width="122"
                document.getElementById("post"+i+".3").width="71"
                //document.getElementById("post"+i+".4").width="85"
           }
        }
}


function post_table_scroll(row_no)
{   
    // scroll the list so the selected index is visible
    var tbl;  
    if (tbl = document.getElementById("posts_table"))
    {  
        var rownum = row_no;
        var row = document.getElementById("post"+rownum+".0"); 
        var top;
        if (row)
        {
            top = row.offsetTop;
        }
        else
        {
            top = tbl.scrollHeight; 
        }
        tbl.scrollTop = top - tbl.clientHeight;
    }
}


function change_post_table_class()
{
    if (navigator.appVersion.indexOf("MSIE")!=-1)
      {
         document.getElementById("posts_table").className="ajaxcontent_IE"
      }
     else
      {
         document.getElementById("posts_table").className="ajaxcontent"
      }

}

/************************ END *************************/



/* FUNCTIONS USED IN THE views/replies/list.rhtml */
/************************ START *************************/

function replies_table_alignment(row_no)
{
    if(navigator.appName!='Microsoft Internet Explorer') //check the browser
    { 
       for(i=0;i<= row_no;i++)
      {
            document.getElementById("reply"+i+".1").width="196"
            document.getElementById("reply"+i+".2").width="444"
            //document.getElementById("reply"+i+".3").width="85"
       }                               
    }

}
/*
function replies_table_scroll(row_no)
{ 
    // scroll the list so the selected index is visible
    var tbl;
    if (tbl = document.getElementById("repliesTable"))
    {   
        var rownum = row_no + 1;
        var row = document.getElementById("reply"+rownum+".1");alert(row.innerHTML);
        var top;
        if (row)
        {
            top = row.offsetTop;
        }
        else
        {
            top = tbl.scrollHeight
        }
        tbl.scrollTop = top - tbl.clientHeight;
    }
}*/
function replies_table_scroll(reply_rowid)
{ 
   /*
    var tbl=document.getElementById("repliesTable");
    var row=document.getElementById("reply_row_"+reply_rowid);
    //alert("tbl.clientHeight :"+tbl.scrollHeight);
    var top;
    if(tbl)
    {
            if(row)
            {
             top = row.offsetTop;
            // alert(top);
            }
            else
            {       
                    top = tbl.scrollHeight;alert(top);
            }
             tbl.scrollTop = top - tbl.clientHeight;     
   }  */
     
}


/************************ END *************************/




/* FUNCTIONS USED IN THE views/ratings/list.rhtml */
/************************ START *************************/

function showTR(icon,id)
{
    element = document.getElementById(id);
    iconElement = document.getElementById(icon);
        if(element)
        {
            if(element.style.visibility == 'hidden')
            {
                element.style.visibility = 'visible';
                element.style.display = '';
                iconElement.src = "/images/twiddle_open.gif";
            }
            else
            {
                element.style.visibility = 'hidden';
                element.style.display = 'none';
                iconElement.src = "/images/twiddle_closed.gif";
            }
        }
}

function reputation_given_received_alignment(row_no)
{
    if(navigator.appName!='Microsoft Internet Explorer') //check the browser
       { 
    	  for(i=0;i<= row_no;i++)
    	  {
    		 document.getElementById("rating" + i + ".1").width="23"  
             document.getElementById("rating" + i + ".2").width="50"
             document.getElementById("rating" + i + ".3").width="73"
             document.getElementById("rating" + i + ".4").width="25"
             document.getElementById("rating" + i + ".5").width="183"                  
             document.getElementById("rating" + i + ".6").width="170"
             document.getElementById("rating" + i + ".7").width="77"
          }
       }    
}


function change_table_class(id)
{    
    if (navigator.appVersion.indexOf("MSIE")!=-1)
	   document.getElementById(id).className="ajaxcontent_IE"
	else
	   document.getElementById(id).className="ajaxcontent"
}

/************************ END *************************/



/* FUNCTIONS USED IN THE views/ratings/show_confirm_create.rhtml */
/************************ START *************************/

function goBack(input_url)
{
   self.location=input_url;
} 
/************************ END *************************/

/*This method is used to update priority icon in reputation detail list on change of priority
  from repution detail section.   
*/
function change_priorityicon(rating_id,para)
{
    var agt=navigator.userAgent.toLowerCase();
    var priority_div=document.getElementById('rep_priority_'+rating_id);
    temp1=document.getElementById('priorityIcon').innerHTML;
    var temp2 = new Array();
    temp2 = temp1.split('>');
    if(navigator.appName =='Microsoft Internet Explorer' ) //check the browser
    {
      temp3=temp2[1].substr(7)
    }
    else
     if (agt.indexOf("safari") != -1)
    {
      temp3=temp2[1].substr(5)
    } 
    else
    {
      temp3=temp2[1].substr(10)
    }
    
    var temp4 = new Array();
    temp4 = temp3.split(' ');
    if(temp4[0] == 'No')
    {
      temp3="&nbsp;"
    }
    else
    {
      temp3=temp3+">"
    }
    
    priority_div.innerHTML=temp3;
    return false;
}


/*
*******************************************************************
following method will change the visibility in reputation details.
*****************************************************************
*/

function setVisibility(rating_id ,visibility_value,return_url)
{
  if (visibility_value == 1)
  {
  if (confirm('Are you sure you want to mark this reputation as private? Private reputation cannot be made public again.')){location='/ratings/change_visibility/'+rating_id+'?return_url='+return_url+'&amp;visibility=' + visibility_value; }  
  }
  if(visibility_value == 2)
  {
  if (confirm('Are you sure you want to mark this reputation as Invisible? Invisible reputation cannot be made public again.')){location='/ratings/change_visibility/'+rating_id+'?return_url='+return_url+'&amp;visibility=' + visibility_value; }  
  }
}

/*
*******************************************************************
following method will change the priority in reputation details.
*****************************************************************
*/

function setPriority(role,rating_id,priority_value)
{
    if(role == 'Demo')
    {
        alert('You are currently using a demonstration login that has limited permissions. The feature you selected is not available to the demonstration login.')
        return true
    }
    new Ajax.Updater('priorityIcon', '/ratings/change_priority/'+rating_id+'?priority=' +priority_value + '', {asynchronous:true, evalScripts:true, onComplete:function(request){change_priorityicon(rating_id,'?priority='+ priority_value )}})
}

function setPrivacy(role, ownership_id ,privacy_value, privacy)
{
   var privacyName = '';
   switch(privacy_value)
   {
        case 0:
            privacyName = "Public";
            break;
        case 1:
            privacyName = "Private";
            break;
   }
   unsetFlag();
   delayHideMenu('privacy_menu');
   if(role == 'Demo')
   {
        alert('You are currently using a demonstration login that has limited permissions. The feature you selected is not available to the demonstration login.')
        return true
   }
   else
   {
       if(privacy!=privacy_value)
           if (confirm('Are you sure you want to mark this identity as '+ privacyName +'?'))
                new Ajax.Updater('privacyIcon', '/trustsources/change_privacy/'+ownership_id+'?privacy=' +privacy_value + '', {asynchronous:true, evalScripts:true, onComplete:function(request){unsetFlag();hideMenu('privacy_menu')}})
   }
}

/* Scroll for recieved reputation */
function reputation_table_scroll(row_no)
{
    // scroll the list so the selected index is visible
    var tbl;
    if (tbl = document.getElementById("reputation_table"))
    {
        var rownum = row_no + 1;
        var row = document.getElementById("rating"+rownum+".1");
        var top;
        if (row)
        {
            top = row.offsetTop;
        }
        else
        {
            top = tbl.scrollHeight
        }
        tbl.scrollTop = top - tbl.clientHeight;

    }
}

/* Function is added to change class of table */
function change_table_class_trustsource(id)
{    
    if (navigator.appVersion.indexOf("MSIE")!=-1)
    {
	   document.getElementById(id).className = "ajaxcontent_IE_trustsource";
       document.getElementById("trustsources").width = "96%";
	}
	else
	   document.getElementById(id).className = "ajaxcontent_trustsource";
	document.getElementById("trustsource_type").width      = "110px";
	document.getElementById("trustsource_identity").width  = "200px";
	document.getElementById("trustsource_verify").width    = "60px";	
}

/*------------------------------------------------------------------------------------+ 
| This function is used to show Retrieving replies/reputation message before loading. |
| Created on 2007-04-19 by Kishore.                                                   |
+------------------------------------------------------------------------------------*/
function retrieveDetails(divName)
{
    
    document.getElementById(divName).innerHTML = document.getElementById('blankDetails').innerHTML;
}

function retriveDefaultValue(source_val)
    {
        var ele = this.options[selectIndex].value;
         alert(ele);
    }



/*
	THE FOLLOWING FUNCTION 'numbersOnly' IS USED BY CREATE REPUTATION FUNCTION FOR 'Transaction'....
*/
//Added to check Transaction value is number 
function numbersOnly(e)
{
    var rep_form = document.forms[repform];
    var unicode=e.charCode? e.charCode : e.keyCode
    if (unicode!=8)
    {                 
        xstr =  rep_form.trans_value.value;
	
        if (unicode==46) //if .
        {
            if (xstr!="")
            {
              xst=xstr.split(".");
              if (xst.length>1)
              {
                return false //disable keypress if user tries to enter second decimal point
              }
            }
            return true //enable key press
        }
    
        //if the key isn't the backspace key (which we should allow)
        if (unicode<48||unicode>57) //if not a number
            return false //disable key press
    }
}


/*
THE 'reset_Form' FUNCTION WILL BE CALLED BY CREATE REPUTATION PAGE...
*/
function reset_Form(x)
   {    
     var rep_form=document.forms[repform];
     if (x==1)
     {rep_form.ratee_identity.value = '';}
      
     if(rep_form.rater_email_id != undefined)
        rep_form.rater_email_id.value = '';
     
     rep_form.rating_visibility_0.checked = true;
     rep_form.rating_transaction_type_1.checked = true;
     rep_form.rating_interaction_type_1.checked = false;
     rep_form.reputation_context.value = '';
     rep_form.trans_value.value = '0.00';
     rep_form.txn_completed_checkbox.checked = false;
     selectrep('rating_rating_3');
     //imgmover(3);
     rep_form.rating_comment.value = 'Enter any textual information you would like about this experience and/or individual. Enter as much or as little as you like. Please respect their privacy, and do not include any identifying or personal information.';
     rep_form.rating_comment.innerHTML = 'Enter any textual information you would like about this experience and/or individual. Enter as much or as little as you like. Please respect their privacy, and do not include any identifying or personal information.';
     //clicktext('rating_comment');     
     
     document.getElementById('recipient_verification_msg').innerHTML="";
     
     if (document.getElementById('divEmail1')!=null)
     {document.getElementById('divEmail1').innerHTML=""}
         
     if (document.getElementById('txtval')!=null)
     {document.getElementById('txtval').innerHTML=""}    
     
     if (document.getElementById('rat_status')!=null)
     {document.getElementById('rat_status').innerHTML=""
     document.getElementById('rat_status1').innerHTML=""}
   }

/*
THE 'getQueryParam' IS USED FOR CREATING REPUTATION THE FOLLOWING FUNCTION WILL GENERATE A UNIQUE ID WIL CREATING REPUTATION.
*/

// THE FOLLOWING FUNCTION IS USED FOR THE TRASACTION PURPOSE CREATED BY ABHISHEK SHUKLA ON 11-07-2007
function get_div_update(id)
	{
		if(id==null)
		{
		  id="Transacting";
		}		
		var div_array = new Array("Transacting", "Interacting", "Relationship");
		var prev_value = "";
		var interaction_value;
		
		for(var i=0; i< div_array.length; i++)
		{	
			if (id==div_array[i])
			{
				$(div_array[i]).innerHTML = "<img src='/images/" +div_array[i]+ "_uncell.gif'/>";
//				$(div_array[i]).setAttribute(className, "tabcellsel");
			}
			else if(id != div_array[i])
			{

				var img = div_array[i]+"_cell.gif"
				$(div_array[i]).innerHTML = "<img src='/images/"+img+"'/>";
			//	alert($(div_array[i]).innerHTML);
				//$(div_array[i]).setAttribute(className, "tabcellunsel");
			//	$(div_array[i]).innerHTML = div_array[i];
			}
			
			interaction_value = i;                        
			if(id == div_array[i])
			{                                
				if(id == 0)                                    
					checkTransaction(interaction_value);
				else                                    
				    checkInteraction(interaction_value);	
                                    
			}
			
			//checkInteraction(interaction_value);
		}
		//Hidden field value which will use to display when a user clicks on the back button
		document.getElementById("tab_index").value = id;
	//	alert(document.getElementById("tab_index").value);
		hide_div(id);
	}
	
	function hide_div(id)
	{
		// Hide the div	
		var id_name = id + "_type";
		var div_name = ["Transacting_type", "Interacting_type", "Relationship_type"];
		for(var j = 0; j<div_name.length; j++)
		{
			var show_hide_div = document.getElementById(div_name[j]);
				if (id_name == div_name[j])	
				{
					show_hide_div.style.visibility = "visible";
					show_hide_div.style.display = "";
				}
				else
				{
					show_hide_div.style.visibility = "hidden";
					show_hide_div.style.display = "none";
				}							
		}
	}

/* Function is added to change class of table Scroll Bar */
/* Created on: 2007-07-16                                */
function change_table_class_rate(id)
{    
    if (navigator.appVersion.indexOf("MSIE")!=-1)
	   document.getElementById(id).className = "ajaxcontent_IE";
	else
	   document.getElementById(id).className = "ajaxcontent";
}

/* Added to fit for the Create Reputation button in Post&Reply button as the new style tages have been added July30th 2007 */
function change_post_table_class_PostReply(id)
{ 
    if (navigator.appVersion.indexOf("MSIE")!=-1)
      {  
         document.getElementById(id).className="ajaxcontent_IE_PostReply"         
      }
     else
      {  
         document.getElementById(id).className="ajaxcontent_PostReply"
      }

}
/*-------------------------------------------------------------------------+ 
| This function is used in share repuation to add email list into text box |
| Created on 2007-07-25 by Kishore.                                        |
+-------------------------------------------------------------------------*/
function AddEmailAddress(totalCheckbox,ret,selectedCheck)
{
    //alert(document.getElementById("myTrustCircle").getElementsByTagName("INPUT")[selectedCheck].checked);
    //Defined variables and resetting To Text box value
    
    var emailAddress ="";
    if(ret=="MT")
        emailAddress     = document.share_rating.rating_email_address;
    else if(ret=="IC")
        emailAddress     = document.invite_user.invitation_email_address;

    //Getting To Email Address of selected from the list
    var divCircle = document.getElementById("myTrustCircle");
    var divInput  = divCircle.getElementsByTagName("INPUT");
    emailText = emailAddress.value;
    emailTextSplit = emailText.split(", ");
    var valueText = null;    
    
    if(divInput[selectedCheck].checked == true && divInput[selectedCheck].value.length > 0)
    { 
        if(emailAddress.value=="")
        {
            emailAddress.value = divInput[selectedCheck].value;
            if(ret=="IC")
            {
                countInvitation();
            }       
            return;
        }
        for(var j=0;j<emailTextSplit.length;j++)
        {
           if(divInput[selectedCheck].value == emailTextSplit[j])
                valueText = null;
           else
                valueText = divInput[selectedCheck].value;                
        }
        if(valueText!=null)
            emailTextSplit[emailTextSplit.length]= valueText; 
    }
    else
    {
        for(var j=0;j<emailTextSplit.length;j++)
        {
           if(divInput[selectedCheck].value == emailTextSplit[j])
                emailTextSplit.splice(j,1);
        }
    }
    emailAddress.value = emailTextSplit.join(", ");
    
   

   	if(ret=="IC")
    {
        countInvitation();
    }
}

function countInvitation()
{
    var emailAdd = document.invite_user.invitation_email_address;
    var textEmail = emailAdd.value;
    var totCount=0;    
    
    emailArr = textEmail.split(",");
    var btnText = document.invite_user.btnSendinvitation.value;
    var idx = btnText.indexOf("(");
    if (idx>0)
        btnText = btnText.substring(0,idx);
    
    if (textEmail!="")
        btnText = btnText + "(" + emailArr.length + ")";
            
    document.invite_user.btnSendinvitation.value= btnText;    

}

/*++++++++++++++++++++++++++++++++++++++++++
+ THE FOLLOWING CODE IS ONLY LOGOFF USERS  +
+ CREATED BY ABHISHEK SHUKLA               +
+++++++++++++++++++++++++++++++++++++++++++*/
function trustcircle_popup(id, value, show)
	{

		var inner_circle_id = id;
		var inner_circle_value = value;
		if(inner_circle_value != 0 && show == true)
		{
			document.getElementById("hiddenDiv").style.display = (show) ? "block" : "none";              
			//alert("You are not signed in to TrustPlus. Only signed-in users can share ratings with their TrustCircle");
		}
		else if (show == false)
		{
			document.getElementById("hiddenDiv").style.display = (show) ? "block" : "none";
		}
		  document.getElementById('rating_visibility_0').checked = true;
	}


/* Popup text for disabled link*/
function disabledLinks()
{
    var text="";
    text = "You are currently using a private preview version of the TrustPlus service.\n" 
    text = text + "Some of the site's functionality is still being polished and will be made available shortly.\n"
    text = text + "If you have any questions about the service in general or about functionality you cannot access,\n"
    text = text + "please don't hesitate to email us at: support@trustplus.com and we will get right back to you."
    
    alert(text);
	return false;
}


function rating_selection(id)
{	
	var split_id = id.split("_");
	var digit_id = split_id[2];
	var chk_box_id = "rating_rating_"+ digit_id;
	var trust_circle_id = "rating_selection_"+ digit_id;
	document.getElementById(chk_box_id).checked = true;

	rate_people_image(id);
}

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ THE FOLLOWING FUNCTION IS USED TO CHANGE THE RATE PEOPLE IMAGE IN create_reputation PAGE +
+ CREATED BY ABHISHEK SHUKLA ON 12-08-2007.												   +	
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

function rate_people_image(id)
{
	var split_value = id.split("_");
	var split_digit = split_value[2];
	// THE BELOW MENTION TWO VARIABLE NOT REQUIRED 'chk_box_id' AND 'trust_circle_id'
	var chk_box_id = "rating_rating_"+ split_digit;
	var trust_circle_id = "rating_selection_"+ split_digit;	 
	var div_name = "rate_people_image";
	
	if (split_digit == 0 || split_digit == 1 || split_digit == 2 || split_digit == 3 || split_digit == 4 || split_digit == 5)
	{
		var rate_ppl_class_name = "rate_people_"+split_digit;
		$("rate_people_image").setAttribute(className, rate_ppl_class_name);	
	}	
}

/*------------------------------------------------------------------------------------------+ 
| This function is used in share repuation to Check & Set Email address is already selected |
| Created on 2007-08-06 by Kishore.                                                         |
+------------------------------------------------------------------------------------------*/
function CheckEmailAddress()
{
    //Getting Trustcircle Email Addresses & Split into an array
    var emailText = document.getElementById("rating_email_address").value;
    var emailTextSplit = emailText.split(", ");

    //Getting To Email Address of selected from the list
    var divCircle = document.getElementById("myTrustCircle");
    var divInput  = divCircle.getElementsByTagName("INPUT");
    
    //Loop for checking Selected from trustcircle against email address of textboxes
    for(var i=0;i<divInput.length;i++)
    {
        for(var j=0;j<emailTextSplit.length;j++)
        {
            //alert("Left: " + divInput[i].value + " Right: " + emailTextSplit[j] )
            //If found in To address set checkbox value to checked
            if(divInput[i].value == emailTextSplit[j])
                divInput[i].checked=true;
        }
    }
}	

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ THE FOLLOWING FUNCTION IS USED TO SEND THE SELECTED VALUE INTO THE 'update_trustcircle_type' +
+ ACTION IN THE 'trustsources' CONTROLLER CREATED BY ABHISHEK SHUKLA ON 24TH JULY 2007		   +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
function setTrustCircle(rownum,user_id, current_trustcircle_value, id) 	
{
	var trustCircle_value = document.getElementById("select_trust_circle" + rownum).value;
	var textLevel = document.getElementById("txtLevel" + rownum);
	var dropdown = document.getElementById("select_trust_circle" + rownum);				
	trustCircleName = dropdown.options[dropdown.selectedIndex].text;
	curr = dropdown.options[dropdown.selectedIndex].value
	if (confirm('Are you sure you want to mark this identity as '+ trustCircleName +'?'))
	{
		new Ajax.Updater('my_trustcircle_level','/trustsources/update_trustcircle_type/'+id+'?privacy=' +trustCircle_value, {asynchronous:true, evalScripts:true});		
		textLevel.value = curr;		
	}
	else
	{	
	   dropdown.value = textLevel.value;
	}
	
}

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  + THE FOLLWING FUNCTION IS FOR UPDATING QUICK RATE IN 'my_trustcircle' page +
  + CREATED BY ABHISHEK SHUKLA ON 21st AUGUST 2007							  +
  + Modified By K on 2007-09-07                                               +
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
function change_quick_rate(rownum, quickRateValue, id, trustcircle_id)
{
    //Declaring Variable to get options and image details
	var quick_rate_value       = $("select_trust_circle_"+rownum).value;
	var quick_rate_dropdown    = $("select_trust_circle_"+rownum);
	var drop_down_name         = quick_rate_dropdown.options[quick_rate_dropdown.selectedIndex].text;
	var	imageSrc               = $("score_icon_"+rownum).src;
	
	//Matching of trustplus icon name
    var regEx                  = new RegExp("repicon_(\\d*)_16x16.gif",'gi');
 	//var quickRateMatch       = imageSrc.exec(regEx);
 	
 	var quickRateMatch         = regEx.exec(imageSrc);
 	 	
 	//Checking if it not matched with trustplus icon of trustcricle
	if(quick_rate_value != RegExp.$1)
	{
		if(confirm('Are you sure you want to rate "' +drop_down_name+ '" to this person?'))
		{	new Ajax.Updater('update_quick_rate_div'+rownum,'/ratings/update_quick_rate/'+trustcircle_id+'?quick_rate_val='+quick_rate_value+ '&rownum=' + rownum, {asynchronous:true, evalScripts:true});			}
		else
		{
		    
		    quick_rate_dropdown.selectedIndex = (RegExp.$1)-1;		    
		}
	}
}


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  + THE FOLLWING FUNCTION IS WHEN SELECTING A TRUSTCIRCLE LEVEL, INNER RADIO  +
  + BUTTONS SELECT TOGETHER WITH OUTER BUTTONS 								  +
  + CREATED BY ABHISHEK SHUKLA ON 2st SEPTEMBER 2007						  +
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
function activated_trustcircle(radio_button_id)
{
	 if(radio_button_id == 1)
		{
			$("rating_visibility_2").checked = false;
			$("rating_visibility_3").checked = false;
		}
	 else if(radio_button_id == 2) 
		{		
			$("rating_visibility_1").checked = true;
			$("rating_visibility_3").checked = false;
			
		}
	else if(radio_button_id == 3)
		{
			$("rating_visibility_1").checked = true;
			$("rating_visibility_2").checked = true;
		}
}


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ THE BELOW MENTION FUNCTION IS USED TO SELECT MULTIPLE RADIO BUTTON AT A TIME.+
+ CREATED BY ABHISHEK SHUKLA ON 6th SEPT 2007                                  + 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
function activeTrustcircle(value, visibility)
{    
    var visibility_value=null;
    if(visibility == null)
        {
            visibility_value = "rating[visibility]";
        }
    else 
        {
            visibility_value = "visibility";
        }    
    var trustcircle_value = value.toString();  
    switch(trustcircle_value)
    {
        case "0":               
                $("rating_visibility_0").name = visibility_value;
                $("rating_visibility_1").name = "inner_circle_select";
                $("rating_visibility_2").name = "firends_and_family_select";
                $("rating_visibility_3").name = "acquaintances_select";
                $("rating_visibility_0").checked = true;
                $("rating_visibility_1").checked = true;
                $("rating_visibility_2").checked = true;
                $("rating_visibility_3").checked = true; 
                break;
        case "1":
                $("rating_visibility_0").name = "public_select";
                $("rating_visibility_1").name = visibility_value;
                $("rating_visibility_2").name = "firends_and_family_select";
                $("rating_visibility_3").name = "acquaintances_select";               
                
                $("rating_visibility_0").checked = false;
                $("rating_visibility_1").checked = true;
                $("rating_visibility_2").checked = false;
                $("rating_visibility_3").checked = false;
                break;
        case "2":
                $("rating_visibility_0").name = "public_select";
                $("rating_visibility_1").name = "inner_circle_select";
                $("rating_visibility_2").name = visibility_value;
                $("rating_visibility_3").name = "acquaintances_select";
                
                $("rating_visibility_0").checked = false;
                $("rating_visibility_1").checked = true;
                $("rating_visibility_2").checked = true;
                $("rating_visibility_3").checked = false;
                break;
        case "3":
                $("rating_visibility_0").name = "public_select";
                $("rating_visibility_1").name = "inner_circle_select";
                $("rating_visibility_2").name = "firends_and_family_select";
                $("rating_visibility_3").name = visibility_value;
                
                $("rating_visibility_0").checked = false;
                $("rating_visibility_1").checked = true;
                $("rating_visibility_2").checked = true;
                $("rating_visibility_3").checked = true;                
                break;        
     }    
}

/* Added to fit for the My Trustcircle  added on Sept.18 2007 */
function change_trustcircle_table_class(id)
{ 
    if (navigator.appVersion.indexOf("MSIE")!=-1)
      {  
         document.getElementById(id).className="mytrustcircle_table_IE";         
      }
     else
      {  
         document.getElementById(id).className="mytrustcircle_table";
      }

}

/*-----------------------------------------------------------------------+ 
| This function is used in share repuation to clearing all email address |
| Created on 2007-10-15 by Kishore.                                      |
+------------------------------------------------------------------------*/
function ClearEmailAddress()
{    
    if (document.getElementById("rating_email_address").value!='')
    {
        //Getting To Email Address of selected from the list
        var divCircle = document.getElementById("myTrustCircle");
        var divInput  = divCircle.getElementsByTagName("INPUT");
        
        //Confirmation for clearing all email address
        if(confirm('Are you sure you want clear all selected email Addresses?'))
        {
            //Loop for checking Selected from trustcircle against email address of textboxes
            for(var i=0;i<divInput.length;i++)
            {
                divInput[i].checked=false;
            }
            document.getElementById("rating_email_address").value='';
            //alert("Please Select User from TrustCircle to Share a Reputation");
        }
    }
    else
        alert("Email addresses are already Cleared");    
}

function api_searchDiv(id)
	{
		// THE BELOW MENTION CONDITION IS USED TO CLEAR THE ERROR MESSAGE OF ZOOMINFO SITE..... LIKE 'SEARCH RESULT NOT FOUND'
		// MODIFIED ON 31-03-2008
		if ($('err').innerHTML != '')
		{
			$('err').innerHTML  = '';
		} 
			
		var x = "";
		var split_id = id.split("_");
		var splitLastPast = split_id[1] +"_"+ split_id[2];
		var div_array = new Array("search_1", "search_2", "search_3");		
		for(var i=1; i <= div_array.length; i++)
		{
			if (splitLastPast == div_array[i-1])
			{
				$(i+'_search_'+i).src 			= "/images/images_zoom/zcurve_brown_left.gif";
				$(i+'.1_search_'+i).className 	= "zoomTabActiveImage zoomTabActive";
				$(i+'_search_'+i+'_1').src  	= "/images/images_zoom/zcurve_brown_right.gif";
			}
			else //if(i != 0)
			{				
				$(i+'_search_'+i).src 			= "/images/images_zoom/zcurve_left.gif";
				$(i+'.1_search_'+i).className 	= "zoomTabInactiveImage zoomTabActive";
				$(i+'_search_'+i+'_1').src  	= "/images/images_zoom/zcurve_right.gif";
			}		
		}
		api_searchDiv_text(splitLastPast);
	}
	
	

// THE 'hideThirdPartySearchDiv' FUNCTION WILL HIDE AND SHOW THE SEARCH PAGE FOR THE FOLLOWING VENDOR'S ZOOMINFO, GOOGLE, FACEBOOK...
function api_searchDiv_text(id)
{
	var id_name = id + "_page";
	var div_name = ["search_1_page", "search_2_page", "search_3_page"];
	for(var j = 0; j<div_name.length; j++)
	{
		var show_hide_div = $(div_name[j]);
			if (id_name == div_name[j])	
			{		
				show_hide_div.style.visibility = "visible";
				show_hide_div.style.display = "";
			
			}
			else
			{				
				show_hide_div.style.visibility = "hidden";
				show_hide_div.style.display = "none";
				
			}							
	}
}

// THE 'get_first_part()' IS CALLED FROM 'trustsources/add_trustsource.rhtml' FILE.
// THE 'get_first_part()' WILL RETURN THE FIRST PART OF EMAIL ADDRESS...
// CREATE ON 25-01-2008 BY ABHISHEK SHUKLA

function get_first_part(forwarding_mail)
{
	get_split_val					=	forwarding_mail.split("@");
	$('identity_user_name').value 	= get_split_val[0];	
}

function comment_character_limit(id, count)
{
	var text	   =	id;
	if(text.value.length > count)
		// 'substring' is used to save the first 500 character in 'text.value'
	text.value			=	text.value.substring(0,count);
	$('text_count_text_count').value = count - text.value.length;
}


