
var my_base_url='http://www.sayitfacetoface.com';
var my_pligg_base='';




dochref = document.location.href.substr(document.location.href.search('/')+2, 1000);
if(dochref.search('/') == -1){
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref;
} else {
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref.substr(0, dochref.search('/'));
}
$thisurl = $thisurl + '';

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/

if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
  try {
	xmlhttp = new XMLHttpRequest ();
  }
  catch (e) {
  xmlhttp = false}
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;


function vote (user, id, htmlid, md5, value)
{
  	if (xmlhttp) {
		url = $thisurl + "/vote.php";
		var mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            window.location="http://www.sayitfacetoface.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");    
    			target1 = document.getElementById ('xvotes-' + htmlid);    
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);    					} else {
														if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {changemnmvalues (htmlid, value, false); }     					}
    				}
    			}
    		}
    	}
	}
}


function unvote (user, id, htmlid, md5, value)
{
  	if (xmlhttp) {
		url = $thisurl + "/vote.php";
		var mycontent = "unvote=true&id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;
        if (anonymous_vote == false && user == '0') {
            window.location="http://www.sayitfacetoface.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
    					   'application/x-www-form-urlencoded');
    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");    
				target1 = document.getElementById ('xvotes-' + htmlid);
  				target2 = document.getElementById ('xvote-' + htmlid);    
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
    					if (xvotesString[htmlid].match (errormatch)) {
    						 xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);
							changemnmvalues (htmlid, value, true);target2.innerHTML = "<span>Like It</span>";						} else {
							if (xvotesString[htmlid].substring (1, 6) == "ERROR") { alert(xvotesString[htmlid]);  } else {target2.innerHTML = "<span>Like It</span>";changemnmvalues (htmlid, value, false); }							
    					}
    				}
    			}
    		}
    	}
	}
}


function cvote (user, id, htmlid, md5, value)
{
	if (xmlhttp) {
		url = $thisurl + "/cvote.php";
		mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
		anonymous_vote = false;

        if (anonymous_vote == false && user == '0') {
            window.location="http://www.sayitfacetoface.com/login.php?return="+location.href;
        } else {
    		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
    		if (mnmxmlhttp) {
    			mnmxmlhttp[htmlid].open ("POST", url, true);
    			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
    			mnmxmlhttp[htmlid].send (mycontent);
    			errormatch = new RegExp ("^ERROR:");
    			target1 = document.getElementById ('cvote-' + htmlid);        
    			mnmPrevColor[htmlid] = target1.style.backgroundColor;
    			target1.style.backgroundColor = '#FFFFFF';
    			mnmxmlhttp[htmlid].onreadystatechange = function () {
    				if (mnmxmlhttp[htmlid].readyState == 4) {
    					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;    
    					if (xvotesString[htmlid].match (errormatch)) {
    						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
    						changecvotevalues (htmlid, true);							
    					} else {
                            target1 = document.getElementById ('ratebuttons-' + id);
							target2 = document.getElementById ('reported_id-' + id);
                            target1.style.display = "none";
							target2.style.display = "none";
							target3 = document.getElementById ('ratetext-' + id);
							//target3.innerHTML = "Thank you for rating this comment.";
							changecvotevalues (htmlid, false);
    					}
    				}
    			}
    		}
    	}
	}
}

function changemnmvalues (id, value, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	//alert(id);
	target1 = document.getElementById ('xvotes-' + id);
	target2 = document.getElementById ('xvote-' + id);
	target3 = document.getElementById ('xreport-' + id);
	target4 = document.getElementById ('xnews-' + id);
	if (error) {
		if (value > 0) { target2.innerHTML = "<span>Liked</span> "; }
		else if (value < 0) { target2.innerHTML = "<span>Discarded!</span> "; }
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
		
        if (value > 0) { 
            target2.innerHTML = "<span>Liked</span> "; 
            target3.style.display = "none"; 
        }
		else if (value < 0 ){    
            target2.innerHTML = "<span>Discarded!</span> ";
            target3.style.display = "none";
            //new Effect.Fade(target3); 
            // Fix me 
		    //new Effect.Opacity(target4, {duration:0.8, from:1.0, to:0.3}); 
            
        }
	}
	return false;
}

function changecvotevalues (id, error)
{
	split = new RegExp ("~--~");
	b = xvotesString[id].split (split);
	target1 = document.getElementById ('cvote-' + id);
	if (error) {
		return false;
	}
	if (b.length <= 3) {
		target1.innerHTML = b[0];
		target1.style.backgroundColor = mnmPrevColor[id];
	}
	return false;
}


function enablebutton (button, button2, target)
{
	var string = target.value;
	button2.disabled = false;
	if (string.length > 0) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
}

function checkfield (type, form, field)
{
	url = $thisurl + '/checkfield.php?type='+type+'&name=' + field.value;
	checkitxmlhttp = new myXMLHttpRequest ();
	checkitxmlhttp.open ("GET", url, true);
	checkitxmlhttp.onreadystatechange = function () {
		if (checkitxmlhttp.readyState == 4) {
		responsestring = checkitxmlhttp.responseText;
			if (responsestring == 'OK') {
				document.getElementById (field.name+'checkitvalue').innerHTML = '<span style="color:black">"' + field.value + 
						'": ' + responsestring + '</span>';
				form.submit.disabled = '';
			} else {
				document.getElementById (field.name+'checkitvalue').innerHTML = '<span style="color:red">"' + field.value + '": ' +
				responsestring + '</span>';
				form.submit.disabled = '';
			}
		}
	}
  checkitxmlhttp.send (null);
  return false;
}

function emailto (original_id, htmlid, instpath, address_count)
{
	email_message = document.getElementById('email_message' + htmlid).value;
	email_address = document.getElementById('email_address_1_' + htmlid).value;
	if (address_count > 1){ 
		for ($i = 2; $i <= address_count; $i++) {
			if(document.getElementById('email_address_' + $i + '_' + htmlid).value != "") {
				email_address = email_address + ', ' + document.getElementById('email_address_' + $i + '_' + htmlid).value;
			}
		}
	}

    
	if (xmlhttp) {
		url = $thisurl + "/recommend.php";
		mycontent = "email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0";
		target2 = document.getElementById ('emailto-' + htmlid);
		target2.innerHTML = "<br>Sending, please wait....";
		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;

					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];	
                       			
					} else {
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];
                      
					}
				}
			}
		}
	}
}

function show_recommend(htmlid, linkid, instpath)
{
	var emailtodisplay=document.getElementById('emailto-' + htmlid).style.display ? '' : 'none';
	document.getElementById('emailto-' + htmlid).style.display = emailtodisplay;

	if (xmlhttp) {
		url = $thisurl + "/recommend.php";
		mycontent = "draw=small&htmlid=" + htmlid + "&linkid=" + linkid;
		target2 = document.getElementById ('emailto-' + htmlid);
		target2.innerHTML = "<br>Loading, please wait....";		
		mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
		
		if (mnmxmlhttp) {
			mnmxmlhttp[htmlid].open ("POST", url, true);
			mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp[htmlid].send (mycontent);
			errormatch = new RegExp ("^ERROR:");
			target1 = document.getElementById ('emailto-' + htmlid);
			mnmxmlhttp[htmlid].onreadystatechange = function () {
				if (mnmxmlhttp[htmlid].readyState == 4) {
					xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;			
					if (xvotesString[htmlid].match (errormatch)) {
						xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);						
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];						
					} else {
						target2 = document.getElementById ('emailto-' + htmlid);
						target2.innerHTML = xvotesString[htmlid];
					}
				}
			}
		}
	}
}

 


 function add_links(who,whom,target_id)
 {
   if (who < 0 ) {
            window.location=my_base_url +my_bloggers_base+'/login.php?return="+location.href';
   } else {  
    
        if (xmlhttp) {
             var url = $thisurl + "/user_add_remove_links.php?action=add_links";  

            mycontent = "who=" + who + "&whom=" + whom + "&target_id=" + target_id;
            
            mnmxmlhttp[target_id] = new myXMLHttpRequest (); 
      
            var target1 = document.getElementById ('save_remove_links-'+target_id);

            if (mnmxmlhttp) {       
                mnmxmlhttp[target_id].open ("POST", url, true);
                mnmxmlhttp[target_id].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded'); 
                mnmxmlhttp[target_id].setRequestHeader ('X_REQUESTED_WITH', 'XMLHttpRequest');   
                mnmxmlhttp[target_id].send (mycontent);
                
                mnmxmlhttp[target_id].onreadystatechange = function () {
                    if (mnmxmlhttp[target_id].readyState == 4) {
                        xvotesString[target_id] = mnmxmlhttp[target_id].responseText;
                        if( xvotesString[target_id] == '-1' || xvotesString[target_id] == '' ) {
                            //alert("Vote invalid!");                        
                        }
                        else{
                            processtarget = xvotesString[target_id].split('<!');
                            target1.innerHTML =processtarget[0];

                        }

                    }
                }
                
            }
           
      } // xmlhttp
    
    }// else
 }

 function remove_links(who,whom,target_id)
 {
   if (who < 0 ) {
            window.location=my_base_url +my_bloggers_base+'/login.php?return="+location.href';
   } else {  
    
        if (xmlhttp) {
             var url = $thisurl + "/user_add_remove_links.php?action=remove_links";  

            mycontent = "who=" + who + "&whom=" + whom + "&target_id=" + target_id;
            
            mnmxmlhttp[target_id] = new myXMLHttpRequest (); 
      
            var target1 = document.getElementById ('save_remove_links-'+target_id);

            if (mnmxmlhttp) {       
                mnmxmlhttp[target_id].open ("POST", url, true);
                mnmxmlhttp[target_id].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded'); 
                mnmxmlhttp[target_id].setRequestHeader ('X_REQUESTED_WITH', 'XMLHttpRequest');   
                mnmxmlhttp[target_id].send (mycontent);
                
                mnmxmlhttp[target_id].onreadystatechange = function () {
                    if (mnmxmlhttp[target_id].readyState == 4) {
                        xvotesString[target_id] = mnmxmlhttp[target_id].responseText;
                        if( xvotesString[target_id] == '-1' || xvotesString[target_id] == '' ) {
                            //alert("Vote invalid!");                        
                        }
                        else{
                            processtarget = xvotesString[target_id].split('<!');
                            target1.innerHTML =processtarget[0];

                        }

                    }
                }
                
            }
           
      } // xmlhttp
    
    }// else
 }


function video_view_count(id)
 {
       
    
    if (xmlhttp) 
         {  
            
            var url = $thisurl + "/user_add_remove_links.php?action=video_view_count";
            url =  url + '&type='+id; 
    
            veiwcounthttp = new myXMLHttpRequest ();
         
                    if(veiwcounthttp)
                    {
        
                        veiwcounthttp.open ("GET", url, true);
                        veiwcounthttp.onreadystatechange = function () {
                            if (veiwcounthttp.readyState == 4) {
                                   msgString = veiwcounthttp.responseText; 
                                  //document.getElementById (target).innerHTML = msgString ; 
                            }
                        }
                          
                        veiwcounthttp.send (null);
                        return false;
                    
                    }      
                 
         }
  
}

function change_status(who,id,type,url_id)
 {
   if (who< 1) {
      window.location="http://www.sayitfacetoface.com/login.php?return="+location.href;
    }   
    
    if (xmlhttp) 
         {  
            
            var url = $thisurl + "/user_add_remove_links.php?action=change_status";
            url =  url + '&who='+who+'&id='+id+'&type='+type; 
            changethttp = new myXMLHttpRequest ();
         
                    if(changethttp)
                    {
        
                        changethttp.open ("GET", url, true);
                        changethttp.onreadystatechange = function () {
                            if (changethttp.readyState == 4) {
                                   msgString = changethttp.responseText;    
                                  //window.location="http://www.sayitfacetoface.com"+document.getElementById (url_id).value; 
                            }
                        }
                          
                        changethttp.send (null);
                        return false;
                    
                    }      
                 
         }
  
}

 function change_youtube_id(who,target_id)
 {
   if (who < 0 ) {
            window.location=my_base_url +my_bloggers_base+'/login.php?return="+location.href';
   } else {  
    
        if (xmlhttp) {
            var url = $thisurl + "/user_add_remove_links.php?action=change_youtube_id";  
            var youtube_name = target_id; 
            var target_id = document.getElementById ('changed_youtube_id');    
            
            mycontent = "who=" + who + "&type=" + youtube_name;
            mnmxmlhttp[target_id] = new myXMLHttpRequest (); 
      
            if (mnmxmlhttp) {       
                mnmxmlhttp[target_id].open ("POST", url, true);
                mnmxmlhttp[target_id].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded'); 
                mnmxmlhttp[target_id].setRequestHeader ('X_REQUESTED_WITH', 'XMLHttpRequest');   
                mnmxmlhttp[target_id].send (mycontent);
                
                mnmxmlhttp[target_id].onreadystatechange = function () {
                    if (mnmxmlhttp[target_id].readyState == 4) {
                        xvotesString[target_id] = mnmxmlhttp[target_id].responseText;
                        if( xvotesString[target_id] == '-1' || xvotesString[target_id] == '' ) {
                            //alert("Vote invalid!");                        
                        }
                        else{
                            processtarget = xvotesString[target_id].split('<!');
                            target_id.style.display = 'block';
                            target_id.innerHTML =processtarget[0];

                        }

                    }
                }
                
            }
           
      } // xmlhttp
    
    }// else
 }
 
 function show_voted ( id){
 
    if(document.getElementById(id).style.display ="none")
    { 
        document.getElementById(id).style.display ="block"; 
    }else{
       document.getElementById(id).style.display ="none"; 
    }
 
 }
 
 function report_profile_comments (user, id, htmlid, md5, value)
{
    if (xmlhttp) {
        url = $thisurl + "/cvote.php";
        mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value+ "&type=" + 'profile_report';
        anonymous_vote = false;

        if (anonymous_vote == false && user == '0') {
            window.location="http://www.sayitfacetoface.com/login.php?return="+location.href;
        } else {
            mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
            if (mnmxmlhttp) {
                mnmxmlhttp[htmlid].open ("POST", url, true);
                mnmxmlhttp[htmlid].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');    
                mnmxmlhttp[htmlid].send (mycontent);
                errormatch = new RegExp ("^ERROR:");
                target1 = document.getElementById ('profile_reported-' + htmlid);        
                mnmPrevColor[htmlid] = target1.style.backgroundColor;
                target1.style.backgroundColor = '#FFFFFF';
                mnmxmlhttp[htmlid].onreadystatechange = function () {
                    if (mnmxmlhttp[htmlid].readyState == 4) {
                        
                        xvotesString[htmlid] = mnmxmlhttp[htmlid].responseText;
                        
                        //alert(xvotesString[htmlid]);
                            
                       if (xvotesString[htmlid].match (errormatch)) {
                            xvotesString[htmlid] = xvotesString[htmlid].substring (6, xvotesString[htmlid].length);                        
                            changeprofilevotevalues (htmlid, true);                            
                        } else {
                            target1 = document.getElementById ('report-' + htmlid);
                            target1.style.display = "none";
                            changeprofilevotevalues (htmlid, false);
                        }
                    }
                }
            }
        }
    }
}


function changeprofilevotevalues (id, error)
{
    split = new RegExp ("~--~");
    b = xvotesString[id].split (split);
    target1 = document.getElementById ('profile_reported-' + id);
    if (error) {
        return false;
    }
    if (b.length <= 3) {
        //target1.innerHTML = b[0];
        target1.style.display = 'block';
    }
    return false;
}



 
