// JavaScript Document
var xmlHttp
var t=0
var tpath='http://www.metrojoint.com/';

function addtoprofile(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"addtoprofile.php"
	url=url+"?vid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=addtoprofileDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function addtoprofileDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		alert("This video has been added to your profile under your Favorite Videos");
	} 
}

function acceptfriend(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=n;
	var url=tpath+"acceptfriends.php"
	url=url+"?fid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=acceptDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function acceptDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	} 
}

function rejectfriend(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=n;
	var url=tpath+"rejectfriends.php"
	url=url+"?fid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=rejectDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function rejectDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	} 
}

function addasfriend(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"addasfriend_ajax.php"
	url=url+"?touid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=addasfriendDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function addasfriendDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
	} 
}

function send_activationmail()
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"send_amail.php"
	url=url+"?sid="+Math.random()
	xmlHttp.onreadystatechange=activation_maildone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function activation_maildone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
		document.getElementById("amail_msg").style.display="none";
	} 
}

function bogaus_profile(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"bogas_profile_ajax.php"
	url=url+"?userid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=bogaus_profileDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function bogaus_profileDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
	} 
}

function bogaus_video1(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"bogas_video.php"
	url=url+"?videoid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=bogaus_videoDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function bogaus_videoDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("video_msg").innerHTML=xmlHttp.responseText
	} 
}

function video_ratesubmit(fid,rating)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 	
	var url=tpath+"rate_video.php"
	url=url+"?videoid="+fid
	url=url+"&rating="+rating
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=rate_videoDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function rate_videoDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("video_msg").innerHTML=xmlHttp.responseText
		//alert(xmlHttp.responseText);
		document.getElementById("rate_video").style.display="none";
		document.getElementById("display_fullrate").style.display="block";
		
		rateval=xmlHttp.responseText
		var r_display="";
		for(i=1;i<=5;i++)
		{
			if(rateval>=1)
			{
				r_display+="<img src=\""+tpath+"images/star2.gif\">";
				rateval=rateval-1;
			}
			else if(rateval>=0.5)
			{
				r_display+="<img src=\""+tpath+"images/star3.gif\">";
				rateval=rateval-1;
			}
			else if (rateval<0.5 && rateval>0)
			{
				r_display+="<img src=\""+tpath+"images/star1.gif\">";
				rateval=rateval-1;
			}
			else if(rateval<=0)
			{
				r_display+="<img src=\""+tpath+"images/star1.gif\">";
			}
		}
		
		document.getElementById("display_fullrate").innerHTML=r_display+"<br>Thanks for rating";
		//alert(document.getElementById("display_fullrate").innerHTML);
	} 
}

function send_profile(fid,fname,femail)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 	
	var url=tpath+"save_sand_profile_ajax.php"
	url=url+"?pid="+fid
	url=url+"&friend_name="+fname
	url=url+"&femail="+femail
	url=url+"&sid="+Math.random()	
	xmlHttp.onreadystatechange=send_profileDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function send_profileDone() 
{ 	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
	} 
}

function send_blog(fid,fname,femail)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 	
	var url=tpath+"send_blogtofrd.php"
	url=url+"?pid="+fid
	url=url+"&friend_name="+fname
	url=url+"&femail="+femail
	url=url+"&sid="+Math.random()	
	xmlHttp.onreadystatechange=send_blogDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function send_blogDone() 
{ 	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
	} 
}

function send_video_link(fid,fname,femail)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 	
	var url=tpath+"send_video.php"
	url=url+"?pid="+fid
	url=url+"&friend_name="+fname
	url=url+"&femail="+femail
	url=url+"&sid="+Math.random()	
	xmlHttp.onreadystatechange=send_videoDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function send_videoDone() 
{ 	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("video_msg").innerHTML=xmlHttp.responseText
	} 
}

/*function send_video_ecard(fid,yname,yemail,fname,femail)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 	
	var url="send_ecard_video.php"
	url=url+"?pid="+fid
	url=url+"&your_name="+yname
	url=url+"&your_email="+yemail
	url=url+"&friend_name="+fname
	url=url+"&femail="+femail
	url=url+"&sid="+Math.random()	
	xmlHttp.onreadystatechange=send_ecardDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function send_ecardDone() 
{ 	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("video_msg").innerHTML=xmlHttp.responseText
	} 
}*/

function block_profile(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"block_profile_ajax.php"
	url=url+"?userid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=block_profileDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function block_profileDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
	} 
}


function replyscrap(from1,to1,msg,n)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=n;
	var url=tpath+"save_scrap_reply.php"
	url=url+"?fid="+from1
	url=url+"&puid="+to1
	url=url+"&scrap="+msg
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=replySended
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function replySended() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("p"+t).innerHTML=xmlHttp.responseText 
		document.getElementById("Reply"+t).disabled=false;
	} 
} 

function checknewemail(str,str1)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (str==""){
		//document.getElementById("emailcheck").innerHTML="Enter value for Email"
		//document.login.email.focus();
		return false;
	}
	var validRegExp = /^\w(\.?\w)*@\w(\.?[-\w])*\.([a-z]{3}(\.[a-z]{2})?|[a-z]{2}(\.[a-z]{2})?)$/i ;
	var isValid = validRegExp.test(str);
	
	if(!isValid)
	{
	/*	document.getElementById("emailcheck").innerHTML="Email is not ok"
		document.login.lemail.focus(); */
		return false;
	}
	else{
		var url="checkemail.php"
		url=url+"?q="+str
		url=url+"&q1="+str1
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=stateChanged
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		if (xmlHttp.responseText!="")
		{
			document.getElementById("emailcheck").innerHTML=xmlHttp.responseText 
		}
		if (xmlHttp.responseText!=""){
			document.login.lemail.value=""
			document.login.lemail.focus()
		} 
	} 
} 
function emailcheck(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (str==""){
	//	document.getElementById("checkemail").innerHTML="Enter Email ID"
	//	document.reg.email.focus()
		return false;
	}
	n=str.indexOf('.');
	n1=str.indexOf('@');
	if(!((n>0) && (n1>0)))
	{
		document.getElementById("checkemail").innerHTML="Email is not ok"
		document.f1.email.focus()
		return false;
	}
	var url=tpath+"emailcheck.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged2
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("checkemail").innerHTML=xmlHttp.responseText 		
		if (xmlHttp.responseText!=""){
			document.f1.email.value=""
			document.f1.email.focus()
		} 
	} 
}

function sendmail(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"sendmail.php"
	url=url+"?q="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=sendmailDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function sendmailDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("mypageerror").innerHTML=xmlHttp.responseText
	} 
}
//document.getElementById("sendmail").style.display="block";

function checknname(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url=tpath+"checknname.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged10
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged10() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	document.getElementById("checknname").innerHTML=xmlHttp.responseText 
	if(xmlHttp.responseText!="")
	{
	document.f1.nname.value=document.f1.nname.value
	document.f1.nname.focus()
	} 
	} 
} 


function resend(pid,no)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=no;
	var url=tpath+"resend.php"
	url=url+"?pid="+pid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=resendSended
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function resendSended() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("rmsg"+t).innerHTML=xmlHttp.responseText 
		//document.getElementById("Reply"+t).disabled=false;
	} 
}

function cancelsend(pid,no)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=no;
	var url=tpath+"cancel.php"
	url=url+"?pid="+pid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=cancelSended
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function cancelSended() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("rmsg"+t).innerHTML=xmlHttp.responseText 
		//document.getElementById("Reply"+t).disabled=false;
	} 
}

function banusersubmit(gid,userid,no)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=no;
	var url=tpath+"banuser.php"
	url=url+"?gid="+gid
	url=url+"&userid="+userid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=banusersubmitSended
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function banusersubmitSended() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("rmsg"+t).innerHTML=xmlHttp.responseText 		
	} 
}

function removebanusersubmit(gid,userid,no)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=no;
	var url=tpath+"removebanuser.php"
	url=url+"?gid="+gid
	url=url+"&userid="+userid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=banusersubmitSended1
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function banusersubmitSended1() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("rmsg"+t).innerHTML=xmlHttp.responseText 		
	} 
}

function topsearchcount(fid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=tpath+"savetopsearch_ajax.php"
	url=url+"?wid="+fid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=topsearchcountDone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function topsearchcountDone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	} 
}

// function for display rating
function display_rate(rate)
{
rateval=rate;
var r_display="";
for(i=1;i<=5;i++)
{
	if(rateval>=1)
	{
		r_display+="<img src=\""+tpath+"images/star2.gif\">";
		rateval=rateval-1;
	}
	else if(rateval>=0.5)
	{
		r_display+="<img src=\""+tpath+"images/star3.gif\">";
		rateval=rateval-1;
	}
	else if (rateval<0.5 && rateval>0)
	{
		r_display+="<img src=\""+tpath+"images/star1.gif\">";
		rateval=rateval-1;
	}
	else if(rateval<=0)
	{
		r_display+="<img src=\""+tpath+"images/star1.gif\">";
	}
}	
document.write(r_display);
}
//end

function remove_theme(tid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=tid;
	var url=tpath+"removetheme.php"
	url=url+"?tid="+tid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=remove_themedone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function remove_themedone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("tmsg"+t).innerHTML="<br>Theme is removed from your profile"
	} 
}

function apply_theme(tid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	t=tid;
	var url=tpath+"applytheme.php"
	url=url+"?tid="+tid
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=apply_themedone
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function apply_themedone() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("tmsg"+t).innerHTML="<br>Theme is added to your profile"
	} 
}

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}