function delete_img(image, gallery)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="deleteimage.php"
	params="image="+image+"&gallery="+gallery;
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			window.location = 'myphotos.php';
			//document.getElementById("images").innerHTML=xmlHttp.responseText; 
	  	}
	}
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function delete_video(image)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="myAjaxFuncs.php"
	params="image="+image+"&delVideo=true&fav=0"
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			window.location = "myVideo.php";
	  	}
	}
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function delete_fav(image,fav)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="myAjaxFuncs.php"
	params="image="+image+"&delVideo=true&fav="+fav
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			window.location = "favVideos.php";
	  	}
	}
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function postComment(uid, text)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	if(text == "")
	{
		alert("Please provide comments");
		return false;
	}

	var url="post_comments.php"
	params="uid="+uid+"&text="+text+"&post=enter"
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			document.getElementById("postComm").innerHTML="Your comment was successfully added"; 
	  	}
		else
		{
			document.getElementById("postComm").innerHTML="<img src='images/myLoader.gif'>";
		}
	}
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}


function createalbum(title)
{
	if(title=='')
	{
		alert("Please Enter title for album");
		return false;
	}
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request")
	 	return
 	}
	
	var location = document.getElementById('location').value;
	var desc = document.getElementById('desc').value;	
	
	location = escape(location);
	desc = escape(desc);
	
	var url="createalbum.php"
	params="title=" + title + "&desc=" + desc + "&location=" + location;

	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			//document.all.album_name.value = "";
			//document.all.create_album.style.visibility = "hidden";
			//alert(xmlHttp.responseText);
			window.location="myphotos.php";
	 	}
	}
	
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function change_image(str, gall)
	{
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url="changeimage.php"
	params="image="+str+"&gallery="+gall
	
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 	{ 
			document.getElementById("image").innerHTML=xmlHttp.responseText; 
	 	}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}


function change_userimage(str, gall)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="changeuserimage.php"
	params="image="+str+"&gallery="+gall
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("image").innerHTML=xmlHttp.responseText; 
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function checkemail(str)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkemail.php"
	params="str="+str
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById('message').innerHTML=xmlHttp.responseText
			if(xmlHttp.responseText=="Already Registered")
			{
				document.getElementById("email").value ='';
			//	document.getElementById("pre_email").value = str;
				//document.newuser.reset();
			//	document.getElementById("pre_passwrd").focus();
			}
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function checkemailband(str,type1)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="checkemail.php"
	params="str="+str+"&type=band&chk1="+type1
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("pre_"+type1).innerHTML=xmlHttp.responseText
			if(xmlHttp.responseText=="Already Registered")
			{
				document.getElementById(type1).value ='';
			}
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)
}

function makeurl(str, error, success, visitid)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	if (str.value == "")
	{
		alert ("Please provide URL")
		return 
	} 

	var charpos = str.value.search("[^A-Za-z0-9]"); 
	if(str.value.length > 0 &&  charpos >= 0) 
	{ 
	    strError = "Only alpha-numeric characters allowed"; 
		alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
		return; 
	}

	document.all("sbmtBtn").value="Processing...";
	document.all("sbmtBtn").disabled=true;
	var url="myAjaxFuncs.php"
	params="chkUrlUsr="+str.value+"&visitID="+visitid
	xmlHttp.onreadystatechange=function () 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if(xmlHttp.responseText=="EXISTS")
			{
				document.all("urlname").value ='';
				document.all("urlname").focus();
				document.all(error).innerHTML="URL already taken. Please try other";
			}
			else if(xmlHttp.responseText=="DONE")
			{
				document.all(success).innerHTML='<a href="http://mypage5.com/userprofile.php?user='+ str.value +'" target="_blank"  style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; text-decoration:none">http://mypage5.com/userprofile.php?user='+ str.value +'</a><br /><a href="mailto:your_friends_emails_here?subject=Invitation&amp;body=Hey, come join me at MyPage5. http://mypage5.com/userprofile.php?user='+ str.value +'"  style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; text-decoration:none">Send it to your friends</a>';
			}
		}	

	}	
	document.all("sbmtBtn").disabled=false;
	document.all("sbmtBtn").value="Save";

	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params)

}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	 }
	return xmlHttp;
}

function right(e) 
{
	var msg = "Sorry, you don't have permission to Save Images";
	if (navigator.appName == 'Netscape' && e.which == 3) 
	{
		alert(msg);
		return false;
	}
	
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) 
	{
		alert(msg);
		return false;
	}
	else 
	{
		return true;
	}
}

function trap() 
{
	if(document.images)
	{
		for(i=0;i<document.images.length;i++)
		{
			document.images[i].onmousedown = right;
			document.images[i].onmouseup = right;
		}
	}
}

function chgStatus(status, user)
{
	var dtNow = new Date();
	var unixtimeps = dtNow.getTime();
	doOper=GetXmlHttpObject()
	doOper.open("GET", 'chat/im.php?blockop='+ status +'&blockuser='+user, true);
	doOper.send(null);
}

var newwindow;

function poptastic(url,name)
{
	newwindow=window.open('chat/' + url, name,'height=258, width=342, left=40, top=40, toolbar=no, menubar=no, directories=no, location=no, scrollbars=no, status=no, resizable=yes, fullscreen=no');
	if (window.focus) 
	{
		newwindow.focus() 
	}
}
function popgroup(url,name)
{
	newwindow=window.open('chat/' + url, name,'height=258, width=342, left=40, top=40, toolbar=no, menubar=no, directories=no, location=no, scrollbars=no, status=no, resizable=yes, fullscreen=no');
	if (window.focus) 
	{
		newwindow.focus() 
	}
}
function popadmin() 
{
	newwindow=window.open('chat/admin.php','admin','height=358, width=469, left=60, top=60, toolbar=no, menubar=no, directories=no, location=no, scrollbars=yes, status=no, resizable=yes, fullscreen=no');
	if (window.focus) { newwindow.focus() }
}

function poptasticDV(url, dv)
{
	var divTag = document.createElement("div");
	divTag.setAttribute("id",'aa');
	divTag.className = "botChatR";
	divTag.innerHTML = '<iframe id=reqID src="chat/' + url + '" width="100%" height="100%" scrolling="no" frameborder="0" style="vertical-align:text-top"></iframe>';
	document.body.appendChild(divTag);
}
function poptasticDR(url, dv)
{
	var divTag = document.createElement("div");
	divTag.setAttribute("id",dv);
	divTag.className = "botChatR";
	divTag.innerHTML = '<iframe id=reqID src="chat/' + url + '" width="100%" height="100%" scrolling="no" frameborder="0" style="vertical-align:text-top"></iframe>';
	document.body.appendChild(divTag);
}

function closesa()
{
	$('chaDIV').hide();
}

function postForm(val, id, onb)
{
	xmlHttps=GetXmlHttpObject()
	if (xmlHttps==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="chat/im.php";
	params="choice=no&id="+id;
	xmlHttps.onreadystatechange=function () 
	{ 
		if (xmlHttps.readyState==4 || xmlHttps.readyState=="complete")
		{ 
			document.getElementById('chaDIV').innerHTML = xmlHttps.responseText;
			if(val == "Accept")
			{
				poptastic("chat.php?id=" + id + "&type=" + onb +"&choice=yes",id);
			}
		}
	}
	xmlHttps.open("POST",url,true);
	xmlHttps.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttps.setRequestHeader("Content-length", params.length);
	xmlHttps.setRequestHeader("Connection", "close");
	xmlHttps.send(params)

}
