/* - - - - - - - - - - - - - - - - - - - - - - -
 JavaScript
 Thursday, February 17, 2009
 - - - - - - - - - - - - - - - - - - - - - - - */

//Credit Cart Verification



function checkdetails()
 {

   if(document.frmpay.OrderTotal.value=="")
    {
      alert("Please select Card Type.");
      document.frmpay.OrderTotal.focus();
      return false;
    }
   if(document.frmpay.CreditCardNumber.value=="")
    {
      alert("Please insert Card No.");
      document.frmpay.CreditCardNumber.focus();
      return false;
    }
   if(document.frmpay.ExpMonth.value=="")
    {
      alert("Please insert Expires On Month.");
      document.frmpay.ExpMonth.focus();
      return false;
    }   
   if(document.frmpay.ExpYear.value=="")
    {
      alert("Please insert Expires On Year.");
      document.frmpay.ExpYear.focus();
      return false;
    }
   if(document.frmpay.CVV2.value=="")
    {
      alert("Please insert CVV No.");
      document.frmpay.CVV2.focus();
      return false;
    }
   if(document.frmpay.card_fname.value=="")
    {
      alert("Please insert Card First Name.");
      document.frmpay.card_fname.focus();
      return false;
    }
   if(document.frmpay.card_lname.value=="")
    {
      alert("Please insert Card Last Name    .");
      document.frmpay.card_lname.focus();
      return false;
    }
   if(document.frmpay.card_address.value=="")
    {
      alert("Please insert Card Address1.");
      document.frmpay.card_address.focus();
      return false;
    }      
   if(document.frmpay.card_street2.value=="")
    {
      alert("Please insert Card Street.");
      document.frmpay.card_street2.focus();
      return false;
    }     
   if(document.frmpay.card_city.value=="")
    {
      alert("Please insert Card City.");
      document.frmpay.card_city.focus();
      return false;
    }         
   if(document.frmpay.card_state.value=="")
    {
      alert("Please insert Card State.");
      document.frmpay.card_state.focus();
      return false;
    }        
   if(document.frmpay.card_zip.value=="")
    {
      alert("Please insert Card Zip.");
      document.frmpay.card_zip.focus();
      return false;
    }        
   if(document.frmpay.card_phone.value=="")
    {
      alert("Please insert Card Phone No.");
      document.frmpay.card_phone.focus();
      return false;
    }
   return true;
 }
 
//*************************** Function for validating form fields starts here*************************//

function registercheck()
{
	var s='\n';
	var flag=true;
	var minLength=6;
	var pw=document.register.pass.value;
	var pw1=document.register.pass1.value;
	var at="@";
	var dot=".";
	var str=document.register.email.value;
	var str1=str.length;
//alert ("test+document.register.user.value");
   if(document.register.user.value=="")
  {
	alert("Please fill Username.");
	document.register.user.focus();
	return false;
  }
  else if(document.register.pass.value=="")
  {
	alert("Please fill Password.");
	document.register.pass.focus();
	return false;
  }
  else if(document.register.pass1.value=="")
  {
	alert("Please Re-enter Password.");
	document.register.pass1.focus();
	return false;
  }
  else if(document.register.email.value=="")
  {
	alert("Please Enter your email.");
	document.register.email.focus();
	return false;
  }
  
// check for minimum length
	
else if (document.register.pass.value.length < minLength) 
	{
		alert('Your password must be at least ' + minLength + ' characters long. Try again.');
		document.register.pass.focus();
		return false;
	}
	
	else if (pw != pw1) 
		{
		alert ("You did not enter the same new password twice. Please re-enter your password.");
		return false;
		}

//check for correct mailing
	

//alert ("test+document.register.sex1.value");
else if(document.register.sex1.selectedIndex=="")
	{
		alert("Choose an option from the gender list.");
		document.register.sex1.focus();
		return false;
	}

//validating Country Code
else if(document.register.country_id.selectedIndex=="0")
	{
		alert("You didn't choose an option from the country list.");
		document.register.country_id.focus();
		return false;
	}
	else if(document.register.city.value=="")
	{
		alert("Please enter your city name.");
		document.register.city.focus();
		return false;
	}
else if(document.register.zip.value=="")
	{
		alert("Please enter your zip code.");
		document.register.zip.focus();
		return false;
	}
	else if((document.register.region_id.disabled==false) && (document.register.region_id.selectedIndex=="0"))
	{
		alert("You didn't choose an option from the Region list.");
		document.register.region_id.focus();
		return false;
	}
else if((document.register.state_code.disabled==false) && (document.register.state_code.selectedIndex=="0"))
	{
		alert("You didn't choose an option from the State list.");
		document.register.state_code.focus();
		return false;
	}
	
 
//validating City and Zip Code	

else if((document.register.email.value!="") && (str.indexOf(at)==-1))
			{
		   alert("Invalid E-mail ID");
		   return false;
			}

else if((document.register.email.value!="") &&  (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==str1))
			{
		   alert("Invalid E-mail ID");
		   return false;
			}
else if((document.register.email.value!="") &&  (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==str1))
			{
		    alert("Invalid E-mail ID");
		    return false;
			}
else
	{
		//alert("Successful");
		return true;
		
	}

}
function viewState(val)
{
	//alert(val);
if (val=="254")
	{
		document.getElementById("state_id").disabled=false;
		document.getElementById("region_id").disabled=true;
		document.getElementById("state_id").focus();
		document.register.submit();
		
	}
		else
		{
			document.getElementById("state_id").disabled=true;
			document.getElementById("region_id").disabled=false;
			document.getElementById("region_id").focus();
			document.register.submit();
		}
}

function statechange(val)
{
	//alert(val);
if (val=="254")
	{
		document.getElementById("state_id").disabled=false;
		document.getElementById("state_id").focus();
		
	}
		else
		{
			document.getElementById("state_id").disabled=true;
			document.register.city.focus();
		}
}

function registration()
{
	var s='\n';
	var flag=true;
	var minLength=6;
	var pw=document.register.pass.value;
	var pw1=document.register.pass1.value;
	var at="@";
	var dot=".";
	var str=document.register.email.value;
	var str1=str.length;
//alert ("test+document.register.user.value");
   if(document.register.user.value=="")
  {
	alert("Please fill Username.");
	document.register.user.focus();
	return false;
  }
  else if(document.register.pass.value=="")
  {
	alert("Please fill Password.");
	document.register.pass.focus();
	return false;
  }
  else if(document.register.pass1.value=="")
  {
	alert("Please Re-enter Password.");
	document.register.pass1.focus();
	return false;
  }
  else if(document.register.email.value=="")
  {
	alert("Please Enter your email.");
	document.register.email.focus();
	return false;
  }
  
// check for minimum length
	
else if (document.register.pass.value.length < minLength) 
	{
		alert('Your password must be at least ' + minLength + ' characters long. Try again.');
		document.register.pass.focus();
		return false;
	}
	
	else if (pw != pw1) 
		{
		alert ("You did not enter the same new password twice. Please re-enter your password.");
		return false;
		}

//check for correct mailing
	

//alert ("test+document.register.sex1.value");
else if(document.register.sex1.selectedIndex=="")
	{
		alert("Choose an option from the gender list.");
		document.register.sex1.focus();
		return false;
	}
else if (document.register.hair_color.selectedIndex=="")
	{
		alert("Please choose your hair color");
		document.register.hair_color.focus();
		return false;
	}
else if (document.register.eye_color.selectedIndex=="")
	{
		alert("Please choose your eye color");
		document.register.eye_color.focus();
		return false;
	}
else if (document.register.height1.selectedIndex=="")
	{
		alert("Please choose your height");
		document.register.height1.focus();
		return false;
	}
else if (document.register.children.selectedIndex=="")
	{
		alert("Please select an option from list");
		document.register.children.focus();
		return false;
	}
else if (document.register.ethnicity1.selectedIndex=="")
	{
		alert("Please choose your ethnicity");
		document.register.ethnicity1.focus();
		return false;
	}
else if (document.register.bodytype1.selectedIndex=="")
	{
		alert("Please choose your bodytype");
		document.register.bodytype1.focus();
		return false;
	}
else if (document.register.maritals1.selectedIndex=="")
	{
		alert("Please choose your marital status");
		document.register.maritals1.focus();
		return false;
	}
else if (document.register.smoker1.selectedIndex=="")
	{
		alert("Please select an option from list");
		document.register.smoker1.focus();
		return false;
	}

//validating Country Code
else if(document.register.country_id.selectedIndex=="0")
	{
		alert("You didn't choose an option from the country list.");
		document.register.country_id.focus();
		return false;
	}
	
	
else if((document.register.state_code.disabled==false) && (document.register.state_code.selectedIndex=="0"))
	{
		alert("You didn't choose an option from the State list.");
		document.register.state_code.focus();
		return false;
	}
	
 else if(document.register.city.value=="")
	{
		alert("Please enter your city name.");
		document.register.city.focus();
		return false;
	}
else if(document.register.zip.value=="")
	{
		alert("Please enter your zip code.");
		document.register.zip.focus();
		return false;
	}
//validating City and Zip Code	
else if(document.register.pic_name.value=="")
	{
		alert("Please upload your piture.");
		document.register.pic_name.focus();
		return false;
	}

else if(document.register.mon1.value=="")
	{
		alert("Please enter your Month.");
		document.register.mon1.focus();
		return false;
	}
	else if(document.register.day1.value=="")
	{
		alert("Please enter your Date of Birth.");
		document.register.day1.focus();
		return false;
	}
else if(document.register.year1.value=="")
	{
		alert("Please enter your Year.");
		document.register.year1.focus();
		return false;
	}
else if (document.register.pic_name.selectedIndex=='')
	{
		alert("Please upload your photo");
		document.register.pic_name.focus();
		return false;
	}
else if(document.register.agree.checked=="0")
  {
	     alert("Please check terms & conditions");
         return false;
  }
else if((document.register.email.value!="") && (str.indexOf(at)==-1))
			{
		   alert("Invalid E-mail ID");
		   return false;
			}

else if((document.register.email.value!="") &&  (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==str1))
			{
		   alert("Invalid E-mail ID");
		   return false;
			}
else if((document.register.email.value!="") &&  (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==str1))
			{
		    alert("Invalid E-mail ID");
		    return false;
			}
else
	{
		//alert("Successful");
		return true;
		
	}

}


//***************** Function for Advance search ****************//

//*************************** Function for validating form fields starts here*************************//

function searchcheck()
{
	var s='\n';
	var flag=true;
 //alert ("test+document.register.sex1.value");
if(document.search.sex1.selectedIndex=="")
	{
		alert("Choose an option from the gender list.");
		document.search.sex1.focus();
		return false;
	}
//validating Country Code
if(document.search.country_id.selectedIndex=="")
	{
		alert("You didn't choose an option from the country list.");
		document.search.country_id.focus();
		return false;
	}

if (document.search.ethnicity1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.ethnicity1.focus();
		return false;
	}
if (document.search.bodytype1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.bodytype1.focus();
		return false;
	}
if (document.search.maritals1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.maritals1.focus();
		return false;
	}
if (document.search.smoker1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.smoker1.focus();
		return false;
	}
if (document.search.education1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.education1.focus();
		return false;
	}

if (document.search.occupation.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.occupation.focus();
		return false;
	}
if (document.search.pet_name.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.search.pet_name.focus();
		return false;
	}
if(document.search.is_picture.checked=="0")
  {
	     alert("Please check terms & conditions");
         return false;
  }
 if(document.search.is_online.checked=="0")
  {
	     alert("Please check terms & conditions");
         return false;
  }
else
	{
		//alert("Sucessful");
		return true;
		
	}

}



//Forum Reply Posting Validation
function forumrep()
{ 
	if (document.new_article.post_head.value=='')
	{
		alert("Please enter a Title");
		document.new_article.post_head.focus();
		return false;
	}
	else if (document.new_article.post_desc.value=='')
	{
		alert("Please enter the Description");
		document.new_article.post_desc.focus();
		return false;
	}
	else
	{
		return true;
	}
}


//Registration Page Verification

function editcheck()
{
if (document.editfrm.fname.value=='')
	{
		alert("Please enter your First Name");
		document.editfrm.fname.focus();
		return false;
	}
else if (document.editfrm.lname.value=='')
	{
		alert("Please enter your Last Name");
		document.editfrm.lname.focus();
		return false;
	}
else if (document.editfrm.hair_color.selectedIndex=='')
	{
		alert("Please choose your hair color");
		document.editfrm.hair_color.focus();
		return false;
	}
else if (document.editfrm.eye_color.selectedIndex=='')
	{
		alert("Please choose your eye color");
		document.editfrm.eye_color.focus();
		return false;
	}
else if (document.editfrm.height1.selectedIndex=='')
	{
		alert("Please choose your height");
		document.editfrm.height1.focus();
		return false;
	}
else if (document.editfrm.children.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.children.focus();
		return false;
	}
else if (document.editfrm.ethnicity1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.ethnicity1.focus();
		return false;
	}
else if (document.editfrm.bodytype1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.bodytype1.focus();
		return false;
	}
else if (document.editfrm.maritals1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.maritals1.focus();
		return false;
	}
else if (document.editfrm.smoker1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.smoker1.focus();
		return false;
	}
else if (document.editfrm.education1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.education1.focus();
		return false;
	}
else if (document.editfrm.income1.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.income1.focus();
		return false;
	}
else if (document.editfrm.occupation.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.occupation.focus();
		return false;
	}
else if (document.editfrm.pet_name.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.pet_name.focus();
		return false;
	}
else if (document.editfrm.relation.selectedIndex=='')
	{
		alert("Please select an option from list");
		document.editfrm.relation.focus();
		return false;
	}
else
	{
		//alert('Congratulation!Successful validations');
		return true;
		
	}

}
  
  
//  profile form validation
function prof()
{
  if(document.edit_frm1.zip.value=="")
  {
    alert("Please enter Zipcode");
    document.edit_frm1.zip.focus();
	return false;
  }
  return true;
	
} 

//********************** Function for validating chat box starts here *********************//
 function open_chat_box(m_id,box_id)
 {
   window.open("chat_box.php?action=loadin&r_id="+box_id ,m_id+"pid"+box_id,"location=0,scrollbars=no,height=450,width=508,left=10,top=20");
 }

function close_chat_box(r_id,m_id)
{
var ajaxRequest;  // The variable that makes Ajax possible!
try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
  } catch (e){
    // Internet Explorer Browsers
    try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
      }
    }
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function()
   {
    if(ajaxRequest.readyState == 4)
     {  
      window.opener.document.location.reload();
      var mystat = ajaxRequest.responseText;
     }
   }
  var queryString = "?m_id=" + m_id + "&r_id=" + r_id;
  ajaxRequest.open("GET", "close_room.php" + queryString, true);
  ajaxRequest.send(null); 
}

 
//----- Function to view terms and condition -------//
 function op_win()
 {
   window.open("view_condition.php" ,"pid1","location=0,scrollbars=yes,height=420,width=780,left=10,top=20");
 }

//----- Function to view image instructions -------//
function op_win2()
 {
   window.open("image_instruction.php" ,"pid2","location=0,scrollbars=yes,height=300,width=600,left=10,top=20");
 }
//---- Function to verify the login form data starts here ------//
function loginverify()
 {
  if(document.loginFrm.user.value=="")
  {
	alert("Please fill Username.");
	document.loginFrm.user.focus();
	return false;
  }
  else if(document.loginFrm.pass.value=="")
  {
	alert("Please fill Password.");
	document.loginFrm.pass.focus();
	return false;
  }
  else
  {
  return true;
  }
 }
//---- Function to verify the login form data ends here ------//
//---- Function to verify the login form in header data starts here ------//
function loginverifyheader()
 {
  if(document.login.user.value=="")
  {
	alert("Please fill Username.");
	document.login.user.focus();
	return false;
  }
  else if(document.login.pass.value=="")
  {
	alert("Please fill Password.");
	document.login.pass.focus();
	return false;
  }
  else
  {
  return true;
  }
 }
//---- Function to verify the login form in header data ends here ------//
function checkpaytype()
 {
   if(document.addon.payment_type.value=="")
    {
      alert("Please select payment type.");
      document.addon.payment_type.focus();
      return false;
    }
   else
    return true;
 }

function getregion()
{
document.getElementById('div_state').style.position="absolute";
document.getElementById('div_state').style.visibility="hidden";  
document.getElementById('div_city').style.position="absolute";
document.getElementById('div_city').style.visibility="hidden";
var ajaxRequest;  // The variable that makes Ajax possible!
var country_id = document.getElementById('country_id').value;
try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
  } catch (e){
    // Internet Explorer Browsers
    try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
      }
    }
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function()
   {
    if(ajaxRequest.readyState == 4)
     {
      document.getElementById('div_state').style.position="relative";
      document.getElementById('div_state').style.visibility="visible";
      var ajaxDisplay = document.getElementById("div_state");
      ajaxDisplay.innerHTML = ajaxRequest.responseText;
     }
   }
  var country_id = document.getElementById('country_id').value;
  var queryString = "?action=region&country_id=" + country_id;
//  alert(country_id+queryString);
  //ajaxRequest.open("GET", "bank_rup.php", true);
  ajaxRequest.open("GET", "checkvalue.php" + queryString, true);
  ajaxRequest.send(null); 
}

function getcity4()
{
document.getElementById('div_city').style.position="absolute";
document.getElementById('div_city').style.visibility="hidden";
var ajaxRequest;  // The variable that makes Ajax possible!
var country_id = document.getElementById('country_id').value;
try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
  } catch (e){
    // Internet Explorer Browsers
    try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
      }
    }
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function()
   {
    if(ajaxRequest.readyState == 4)
     {
      document.getElementById('div_city').style.position="relative";
      document.getElementById('div_city').style.visibility="visible";
      var ajaxDisplay = document.getElementById("div_city");
      ajaxDisplay.innerHTML = ajaxRequest.responseText;
     }
   }
  var region_id = document.getElementById('region_id').value;
  var country_id = document.getElementById('country_id').value;
  var queryString = "?action=city&region_id=" + region_id+"&country_id=" + country_id;
  //ajaxRequest.open("GET", "bank_rup.php", true);
  ajaxRequest.open("GET", "checkvalue.php" + queryString, true);
  ajaxRequest.send(null); 
}

function getzip_code()
 {
   var country_id = document.getElementById('country_id').value;
   if(country_id == 254)
     {   
       document.getElementById('div_zip_code1').style.position="relative";
       document.getElementById('div_zip_code1').style.visibility="visible";
       document.getElementById('div_zip_code').style.position="relative";
       document.getElementById('div_zip_code').style.visibility="visible";
     }
   else
     {       
       document.getElementById('div_zip_code1').style.position="absolute";
       document.getElementById('div_zip_code1').style.visibility="hidden";
       document.getElementById('div_zip_code').style.position="absolute";
       document.getElementById('div_zip_code').style.visibility="hidden";
     }
  }


function getname()
{
document.getElementById('div_name').style.position="absolute";
document.getElementById('div_name').style.visibility="hidden";
var ajaxRequest;  // The variable that makes Ajax possible!
var country_id = document.getElementById('country_id').value;
if(country_id==254)
 {
   document.getElementById('div_cityname').style.position="absolute";
   document.getElementById('div_cityname').style.visibility="hidden";
 }
else
 {
  document.getElementById('div_cityname').style.position="relative";
  document.getElementById('div_cityname').style.visibility="visible";
 }
try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
  } catch (e){
    // Internet Explorer Browsers
    try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
      }
    }
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function()
   {
    if(ajaxRequest.readyState == 4)
     {
      document.getElementById('div_name').style.position="relative";
      document.getElementById('div_name').style.visibility="visible";
      var ajaxDisplay = document.getElementById("div_name");
      ajaxDisplay.innerHTML = ajaxRequest.responseText;
     }
   }
  var country_id = document.getElementById('country_id').value;
  var queryString = "?action=name&country_id=" + country_id;
  //ajaxRequest.open("GET", "bank_rup.php", true);
  ajaxRequest.open("GET", "checkvalue.php" + queryString, true);
  ajaxRequest.send(null); 
}


function deflt(img_id,m_id)
 {
  isconform=confirm("Do you really want to Change the Default Picture?");
  if(isconform)
   window.location="profile_picture.php?action=def&img_id=" + img_id + "&m_id="+m_id;
 }


function del(img_id)
 {
  isconform=confirm("Do you really want to Delete the Picture?");
  if(isconform)
   window.location="profile_picture.php?action=delete&img_id=" + img_id;
 }

function delmember(u_id)
 {
  isconform=confirm("Do you really want to Delete your Profile?");
  if(isconform)
   window.location="visitor_account.php?action=delete&u_id=" + u_id;
 }
 
  
 function search_lt()
 {
   document.page_limit_form.submit();
 }

 
function galleryname()
 {
   if(document.pic_gal.gal_name.value=="")
    {
      alert("Please insert gallery name.");
      document.pic_gal.gal_name.focus();
      return false;
    }
   if(document.pic_gal.is_public.checked==true)
   {
     if(document.pic_gal.pass.value=="")
      {
        alert("Please insert password.");
        document.pic_gal.pass.focus();
        return false;
      }
    }
   else
    return true;
 }


function del_gallery(gal_id)
 {
  isconform=confirm("Do you really want to Delete the Gallery?");
  if(isconform)
   window.location="picture_gallery.php?action=delete&gal_id=" + gal_id ;
 }



function del_gal_pic(gpic_id,id)
 {
  isconform=confirm("Do you really want to Delete the Picture?");
  if(isconform)
   window.location="gallery_pictures.php?action=delete&gpic_id=" + gpic_id +"&id="+id;
 }


 function del_friend(id)
 {
  isconform=confirm("Do you really want to remove your friend from friendlist?");
  if(isconform)
   window.location="myfriends.php?action=deletef&id=" + id;
 }

 
 function deflt_gal_pic(gpic_id,gal_id)
 {
  isconform=confirm("Do you really want to Change the Default Picture?");
  if(isconform)
   window.location="gallery_pictures.php?action=def_gal_pic&gpic_id=" + gpic_id + "&gal_id="+gal_id;
 }

function checkimage()
 {
   if(document.picture.pic_name.value=="")
    {
      alert("Please select a picture.");
      document.picture.pic_name.focus();
      return false;
    }
   else
    return true;
 }

 function checkpicture()
 {
   if(document.prof_pic.pic_name.value=="")
    {
      alert("Please select a picture.");
      document.prof_pic.pic_name.focus();
      return false;
    }
   else
    return true;
 }

function checkaudio()
 {
   if(document.audio.audio_name.value=="")
    {
      alert("Please select an audio file.");
      document.audio.audio_name.focus();
      return false;
    }
   else
    return true;
 }

 function del_audio(audio_id)
 {
  isconform=confirm("Do you really want to delete the audio file?");
  if(isconform)
   window.location="profile_audio.php?action=delete_audio&audio_id=" + audio_id ;
 }

function checkvideo()
 {
   if(document.video.video_name.value=="")
    {
      alert("Please select a video file.");
      document.video.video_name.focus();
      return false;
    }
   else
    return true;
 }

 function del_video(video_id)
 {
  isconform=confirm("Do you really want to delete the video file?");
  if(isconform)
   window.location="profile_video.php?action=delete_video&video_id=" + video_id ;
 }

function checkblog()
 {
   if(document.blog.blog_head.value=="")
    {
      alert("Please insert Blog heading.");
      document.blog.blog_head.focus();
      return false;
    }   
   if(document.blog.blog_desc.value=="")
    {
      alert("Please insert Blog descrition.");
      document.blog.blog_desc.focus();
      return false;
    }
   else
    return true;
 }

 function del_blog(blog_id)
 {
  isconform=confirm("Do you really want to delete this Blog?");
  if(isconform)
   window.location="myblog.php?action=delete_blog&story_id=" + blog_id ;
 }


 function op_image_win(path)
 {
   window.open("view_image.php?path="+ path ,"pid2","location=0,scrollbars=yes,height=620,width=780,left=10,top=20");
 }


function send_invitation(to_id)
 {
   window.open("invitation.php?action=invite&to_id="+ to_id ,"pid3","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }
function send_wink(to_id)
 {
   window.open("sendwink.php?action=sendwink&to_id="+ to_id ,"pid4","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }

function send_hotlist(to_id)
 {
   window.open("sendhotlist.php?action=sendhot_list&to_id="+ to_id ,"pid5","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }

function block_user(to_id)
 {
   window.open("blockuser.php?action=block&to_id="+ to_id ,"pid6","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }

function unblock_user(id)
 {
   window.open("blockuser.php?action=unblock&id="+ id ,"pid7","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }


 function invite_accept(from_id,id)
 {
   window.open("invitation_accept.php?action=accept&from_id="+ from_id +"&id="+id ,"pid8","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }

 function invite_reject(from_id,id)
 {
   window.open("invitation_accept.php?action=reject&from_id="+ from_id +"&id="+id ,"pid9","location=0,scrollbars=no,height=420,width=780,left=10,top=20");
 }

 function open_profile_pic(id)
 {
   window.open("view_profile_picture.php?id="+id ,"pid10","location=0,scrollbars=yes,height=620,width=780,left=10,top=20");
 }


function checkusername()
{
var ajaxRequest;  // The variable that makes Ajax possible!
var mail_to = document.getElementById('mail_to').value;
//alert(mail_to);
try{
    // Opera 8.0+, Firefox, Safari
    ajaxRequest = new XMLHttpRequest();
  } catch (e){
    // Internet Explorer Browsers
    try{
      ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e){
        // Something went wrong
        alert("Your browser broke!");
        return false;
      }
    }
  }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function()
   {
    if(ajaxRequest.readyState == 4)
     {  
      //document.getElementById('div_username').style.position="relative";
      //document.getElementById('div_username').style.visibility="visible";
      var ajaxDisplay = document.getElementById("div_username");
      ajaxDisplay.innerHTML = ajaxRequest.responseText;
     }
   }
  var mail_to = document.getElementById('mail_to').value;
  var queryString = "?mail_to=" + mail_to;
  ajaxRequest.open("GET", "checkusername.php" + queryString, true);
  ajaxRequest.send(null); 
}


function checkcompose()
 {
   if(document.send_msg.mail_to.value=="")
    {
      alert("Please insert username of your friends only.");
      document.send_msg.mail_to.focus();
      return false;
    }
   else
    document.send_msg.mail_to1.value=document.send_msg.mail_to.value;

   if(trimAll(document.send_msg.mail_sub.value)=="")
    {
      alert("Please insert subject.");
      document.send_msg.mail_sub.value="";
      document.send_msg.mail_sub.focus();
      return false;
    }
   if(trimAll(document.send_msg.mail_body.value)=="")
    {
      //alert("Please write your message.");
      document.send_msg.mail_body.focus();
      return false;
    }
   else
    return true;
 }



function check_all()
 {
   var tol_no=document.getElementById('tot_no').value;
   var i;
   for(i=1;i<tol_no;i++)
     document.getElementById('chek'+i).checked=true;
 }

function delete_all()
 {
   var tol_no=document.getElementById('tot_no').value;
   var i;
   var count=0;
   for(i=1; i<tol_no; i++)
    {
     var path=eval ("document.delete_mail.chek"+i);
     if(path.checked==true)
       count=count+1;
    }
   if(count==0)
    {
     alert('Please select mail which you want to delete.');
    }
   else
    {
     isconform=confirm("Do you really want to delete all items?");
     if(isconform)
       document.delete_mail.submit();
    }
 }


function rating_verify()
 {
   if(document.rating.rate_pt.value=="")
    {
      alert("Please select rate point.");
      document.rating.rate_pt.focus();
      return false;
    }
   if(document.rating.rate_comment.value=="")
    {
      alert("Please insert comments.");
      document.rating.rate_comment.focus();
      return false;
    }
   else
    return true;
 }


function op_priv_chat(from,to)
{
window.open("privatechat.php?action=loadin&to_id=" + to + "&from_id=" + from , from+"im"+to,"location=0,scrollbars=no,height=400,width=500,left=20,top=10");

}



function trimAll(sString)
 {
  while (sString.substring(0,1) == ' ')
  {
   sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
   sString = sString.substring(0,sString.length-1);
  }
  return sString;
 }
//-->

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}