// JavaScript Document
// jscript.js
if(document.images)
{
  img01 = new Image();
  img01.src = "images/dn_arrow.gif";
  img012 = new Image();
  img012.src = "images/dn_arrow.gif";
}
function OnImage(name) {
	if (document.images) {
		fullname = eval(name + "2");
		document[name].src = fullname.src;
	}
}
function OffImage(name) {
  if (document.images) {
    fullname = eval(name);
	if (fullname.complete) {
      document[name].src = fullname.src;
	}
  }
}
function primery_picture(objPic)
{
	window.location.href="makeprimerypic.php?id="+objPic
}
function delete_picture(objPic)
{
	window.location.href="deleteprimerypic.php?id="+objPic;
}
function editmydomain(objDomain)
{
	document.formmain.action="mydomain.php?id="+objDomain;
	document.formmain.submit();
}
function reply_form_submit(objSender, obgMsg)
{
	document.formmain.msg.value=obgMsg;
	document.formmain.id.value=objSender;
	document.formmain.action="sendmessage.php";
	document.formmain.submit();
}
function delete_submit(objMsg, objFolder)
{
	document.formmain.action="messages.php?folder="+objFolder+"&msg="+objMsg+"&action=delete";
	document.formmain.askquestion.value = 1;
	document.formmain.reply.value = 0;
	document.formmain.submit();
}
function cancel_confirm(objMsg, objFolder)
{
	document.formmain.action="messages.php?folder="+objFolder+"&msg="+objMsg+"&action=delete";
	document.formmain.askquestion.value = 0;
	document.formmain.reply.value = 1;
	document.formmain.submit();
}
function confirmd_ok(objMsg)
{
	document.formmain.action ="fnmessagedelete.php";
	document.formmain.msg = objMsg;
	document.formmain.submit();
}

function block_submit(objSender)
{
	document.formmain.action="fnblocksender.php?objSender="+objSender;
	document.formmain.submit();
}

function edit_domain(objDomain, objVal)
{
	var elemval = document.getElementById(objVal).value;
	
	document.formmain.action="editdomain.php?id="+objDomain;
	document.formmain.newval.value=elemval;
	document.formmain.submit();
}
function delete_domain(objDomain)
{
	if(confirm("Do you want to delete?"))
	{
		document.formmain.action="deletedomain.php?id="+objDomain;
		document.formmain.submit();
	}
}
function terms()
{
	var new_win =window.open('terms.php','','width=725,height=520,scrollbars=yes,resizable=no');
	new_win.moveTo(100,50);	
}
function searchItem()
{
	var searchTxt
	var searchType
	searchTxt = document.getElementById('searchTxt').value;
	searchType= document.getElementById('searchType').value;
	if((searchTxt=='') || (searchTxt==null ))
	{
		alert('Please enter some characters');
		return false;
	}
	else
	{
		if(searchType=='v')
		{
			document.searchForm.action = "videossearch.php?search="+searchTxt;
			document.searchForm.submit();
		}
		if(searchType=='m')
		{
			document.searchForm.action="membersearch.php?search="+searchTxt;
			document.searchForm.submit();
		}
		if(searchType=='p')
		{
			document.searchForm.action="photosearch.php?search="+searchTxt;
			document.searchForm.submit();
		}
	}
}
function checkall(objForm)
{
	len = objForm.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) 
	{
		if (objForm.elements[i].type=='checkbox') 
		{
			objForm.elements[i].checked=objForm.check_all.checked;
		}
	}
}
function ValidateComment()
{
	if(document.frmComment.comment.value=="")
	{
		document.frmComment.comment.focus();
		alert("Please enter some comment.");
		return false;
	}
}
function dispalay_topsite(objOne)
{
	document.MyForm.action="top.php";
	document.MyForm.ts_mode.value = objOne;
	document.MyForm.submit();
}
function display_domains(objFirst, objSecond)
{
	document.MyForm.action="domains.php";
	document.MyForm.country.value = objFirst;
	document.MyForm.lang.value = objFirst;
	document.MyForm.extension.value = objFirst;
	document.MyForm.category.value = objFirst;
	document.MyForm.submit();
}
function display_sites(objFirst, objSecond)
{
	document.MyForm.action="sites.php";
	document.MyForm.country.value = objFirst;
	document.MyForm.lang.value = objFirst;
	document.MyForm.extension.value = objFirst;
	document.MyForm.category.value = objFirst;
	document.MyForm.submit();
}
function display_projects(objFirst, objSecond)
{
	document.MyForm.action="projects.php";
	document.MyForm.country.value = objFirst;
	document.MyForm.lang.value = objFirst;
	document.MyForm.extension.value = objFirst;
	document.MyForm.category.value = objFirst;
	document.MyForm.submit();
}
function browse_sites()
{
	document.MyForm.action="sites.php";
	document.MyForm.country.value = objFirst;
	document.MyForm.lang.value = objFirst;
	document.MyForm.extension.value = objFirst;
	document.MyForm.category.value = objFirst;
	document.MyForm.submit();
}
// For Pagination

function disclaimer()
{
	document.MyForm.action = 'disclaimer.php';
	document.MyForm.submit();
}
function redirect(objPage)
{
	document.MyForm.action = objPage;
	document.MyForm.submit();
}
function page_navigation(objPage, objNum)
{
	document.MyForm.action = objPage+'?page='+objNum;
	document.MyForm.submit();
}
function echeck(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	
	if (str.indexOf(at,(lat+1))!=-1)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	
	if (str.indexOf(dot,(lat+2))==-1)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	
	if (str.indexOf(" ")!=-1)
	{
		alert("Please Enter your Valid Email ID .")
		return false
	}
	return true					
}

function Evaluate()
{
	ak_name = document.form1.ak_name.value;
	ak_state = document.form1.ak_state.value;
	ak_city = document.form1.ak_city.value;
	email = document.form1.ak_email.value;
	
	if((document.form1.ak_name.value=="") || (document.form1.ak_name.value==null))
	{
		alert("Plese enter your name");
		document.form1.ak_name.focus();
		return false;
	}
	if((document.form1.ak_state.value=="") || (document.form1.ak_state.value==null))
	{
		alert("Plese enter state name.");
		document.form1.ak_state.focus();
		return false;
	}
	if((document.form1.ak_city.value=="") || (document.form1.ak_city.value==null))
	{
		alert("Plese enter city name.");
		document.form1.ak_city.focus();
		return false;
	}
	if (echeck(email)==false)
	{
		document.form1.ak_email.value="";
		document.form1.ak_email.focus();
		return(false);
	}
	else
	{
		var NewWin = window.open("askhp.php","testform",'width=400,height=300,top=300,left=300,scrollbars=0,resizable=0');
		NewWin.moveTo(400,250);	
		//document.form1.action = 'askhp.php';
		//document.form1.submit();
	}
}
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
function preloadImages()
{
	if (document.images) {
		var tab_home = newImage("images/tabs_selected_01.gif");
		var tab_video = newImage("images/tabs_selected_03.gif");
		var tab_cat = newImage("images/tabs_selected_05.gif");
		var tab_photo = newImage("images/tabs_selected_07.gif");
		var tab_community = newImage("images/tabs_selected_09.gif");
                var tab_premium = newImage("images/tabs_selected_11.gif");		
		preloadFlag = true;
	}
}
function textCounter(field,cntfield,maxlimit) 
{
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	else
	cntfield.value = maxlimit - field.value.length;
}



// START RELATED TO USER REPORT
function postFlagUser(strURL)
{
    var xmlHttp;
    if(window.XMLHttpRequest)
    {
        var xmlHttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.open('POST', strURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById("txtUserReport").innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.send(strURL);
}
function showreportdiv()
{
	document.getElementById("flagTxt").innerHTML = "";
	document.getElementById("reportDiv").style.display = "inline";
	document.getElementById("main").style.display = "none";
}
function hidereportdiv()
{
	document.getElementById("flagTxt").innerHTML = "";
	document.getElementById("reportDiv").style.display = "none";
	document.getElementById("main").style.display = "inline";
}
function DisplayBox()
{//flagTxt
document.getElementById("flagTxt").style.display = "inline";
}
function HideBox()
{//flagTxt
document.getElementById("flagTxt").style.display = "none";
}
function postreport(objUID)
{
	var flagTxt = document.getElementById("flagTxt").value;	
	chosen = "";
	len = document.FormReport.flagid.length;
	for (i = 0; i <len; i++) {
		if (document.FormReport.flagid[i].checked) {
		chosen = document.FormReport.flagid[i].value;
		}
	}
	var url = "add_flag_user.php?id=" + objUID + "&flagid="+chosen+"&flagTxt=" +flagTxt;
	postFlagUser(url);
	document.getElementById("flagTxt").value = '';
	setTimeout('document.getElementById(\'txtUserReport\').innerHTML=\'\'',5000);
}
// END RELATED TO USER REPORT

// REMOVE FROM FRIEND
function removeUserFromFriend(strURL)
{
    var xmlHttp;
    if(window.XMLHttpRequest)
    {
        var xmlHttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.open('POST', strURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById("txtContact").innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.send(strURL);
}

function getContact(nUserId)
{
    var xmlHttp;
    if(window.XMLHttpRequest)
    {
        var xmlHttp = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
	var strURL = "contact.php?nUserId="+nUserId;
    xmlHttp.open('POST', strURL, true);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            document.getElementById("contact").innerHTML = xmlHttp.responseText;
        }
    }
    xmlHttp.send(strURL);
}
function removefriend(objUID)
{	
	var url = "removefriend.php?usr=" + objUID;
	removeUserFromFriend(url);
	//setTimeout('document.getElementById(\'txtContact\').innerHTML=\'\'',5000);
}

function u_video()
 {
	 window.location.href="uploadvideo.php";
 }
 function u_photo()
 {
	 window.location.href="addphoto.php";
 }
