// JavaScript Document
document.oncontextmenu = new Function("return false");
document.onselectstart=new Function('return false');
function MM_openBrWindow_mid(theURL,winName,features) { //v2.0

  features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=auto,resizable=yes,width=500,height=400';

  window.open(theURL,winName,features);

}

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];}

}



function MM_jumpMenu(targ,selObj,restore){ //v3.0

  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");

  if (restore) selObj.selectedIndex=0;

}

function menu_select(s,s1,s2)

{

	if(s.value!="")

	{

		

		s3="gallery_1.php?id="+s.value

		ss="<iframe frameborder='0' src='"+s3+"' height='100' width='420'  name='sone' id='sone'></iframe>"

		//alert(s3)

		s2.innerHTML=ss

	}

}

function menu_select_viewprofile(s){

	location.href="view_profile.php?id=0&mid="+s.value+"&slno=0"

}

function menu_select_home(s,s1,s2)

{

	if(s.value!="")

	{

		

		s3="gallery_1.php?id="+s.value

		ss="<iframe frameborder='0' src='"+s3+"' height='90' width='100%'  name='sone' id='sone'></iframe>"

		//alert(s3)

		s2.innerHTML=ss

	}

}

function menu_select_req(s,s1,s2)

{

	if(s.value!="")

	{

		

		s3="gallery_2.php?id="+s.value

		ss="<iframe frameborder='0' src='"+s3+"' height='160' width='100%'  name='sone' id='sone'></iframe>"

		//alert(s3)

		s2.innerHTML=ss

	}

}

function menu_select2(s)

{

	if(s.value!="")

	{

		

		ss=s.value;

		s2=ss.split("-");

		location.href="view_profile.php?id="+s2[1]+"&mid="+s2[0]+"&slno=0&mode=normal"

		

	}

}
function validate_pwd1(s1)

{

	if(trim(s1.user.value)==""){

		alert("please enter your userid")

		s1.user.focus()

	}else {

		location.href="forgot_pwd1.php?uid="+s1.user.value

	}

}
function validate_pwd(s1)

{

	if(trim(s1.user.value)==""){

		alert("please enter your userid")

		s1.user.focus()

	}else {

		location.href="forgot_pwd.php?uid="+s1.user.value

	}

}

function form_validate(s1)

{



	if(trim(s1.name.value)=="")

	{

	

		alert("Plese enter your name")

		s1.name.focus()

		return false

	}

	if(trim(s1.email.value)=="")

	{

		alert("Plese enter your emailid")

		s1.email.focus()

		return false

	} else {

			

					st=s1.email.value;

					if(checkEmail(st)==false)

					{

						alert("Please Enter Correct Email")

						s1.email.focus();

						return false

					}

	

	}

	if(trim(s1.f_name.value)=="")

	{

		alert("Plese enter your friend name")

		s1.f_name.focus()

		return false

	}

	if(trim(s1.f_email.value)=="")

	{

		alert("Plese enter your friend emailid")

		s1.f_email.focus()

		return false

	} else {

			

					st=s1.f_email.value;

					if(checkEmail(st)==false)

					{

						alert("Please Enter Correct Email")

						s1.f_email.focus();

						return false

					}

	

	}

}

function checkEmail(str)

	{

		if((str.indexOf("@")==-1) || (str.indexOf(".")==-1))

		{

			fstr="Please Enter @ or .";

			return false;

		}

		else

		{

		if((str.indexOf("@") == 0) || (str.indexOf(".") == 0))

		{

			fstr="@ or . Cannot Be first";

			return false;

		}

		if((str.indexOf("@") == (str.length-1)) || (str.indexOf(".") == (str.length-1)))

		{

			fstr="@ or . Cannot Be Last";

			return false;

		}



	/*	if(str.indexOf(",") > str.indexOf("."))

		{

			fstr="No Commas or Semi-Colons Allowed";

			return false;

		}*/

		if((str.indexOf("@")+1) == str.indexOf("."))

		{

			fstr="@. IS Invalid Email";

			return false;

		}

		}

		var cp=0;					

	

		if(cp==2)

		{

			fstr="@ cannnot be repeated";

			return false;

		}

		return true;

	}

function LTrim(str)

{

   var whitespace = new String("\t\n\r");



   var s = new String(str);



   if (whitespace.indexOf(s.charAt(0)) != -1) {

      // We have a string with leading blank(s)...



      var j=0, i = s.length;



      // Iterate from the far left of string until we

      // don't have any more whitespace...

      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)

         j++;



      // Get the substring from the first non-whitespace

      // character to the end of the string...

      s = s.substring(j, i);

   }

   return s;

}



function RTrim(str)

{

   // We don't want to trip JUST spaces, but also tabs,

   // line feeds, etc.  Add anything else you want to

   // "trim" here in Whitespace

   var whitespace = new String(" \t\n\r");



   var s = new String(str);



   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

      // We have a string with trailing blank(s)...

     var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we

      // don't have any more whitespace...

      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)

         i--;

      // Get the substring from the front of the string to

      // where the last non-whitespace character is...

      s = s.substring(0, i+1);

   }



   return s;

}





function trim(str)

{

   return RTrim(LTrim(str));

}

function valid_login(login)

{

	if(login.user.value == "")

	{

		alert("please enter username");

		login.user.focus();

		return(false);

	}

	

	if(login.pass.value == "")

	{

		alert("please enter password");

		login.pass.focus();

		return(false);

	}

	return true;

}


function check_login(s1,s2,s3,s4,s5){

	//alert("ok")

	if (s1==""){

		alert("first you have to login before adding to wishlist")

		location.href="checkout_step1.php"

	}else{

		window.open("add_towhislist.php?id="+s1 +"&id1="+s2 +"&pchk="+s3+"&fchk="+s4+"&schk="+s5,'s','toolbar=no,location=no,status=yes,menubar=no,scrollbars=auto,resizable=yes,width=300,height=300')

	}

}





function valid_registration(regis)

{

	if(trim(regis.name.value) == "")

	{

		alert("please enter first name");

		regis.name.focus();

		return(false);

	}

	

	if(trim(regis.add.value) == "")

	{

		alert("please enter Address");

		regis.add.focus();

		return(false);

	}

	

	if(trim(regis.city.value) == "")

	{

		alert("please enter City");

		regis.city.focus();

		return(false);

	}

	

	if((regis.state.value == "")&&(trim(regis.other.value) ==""))

	{

		alert("please enter State");

		regis.state.focus();

		return(false);

	}

	

	if((regis.country.value == "")&&(trim(regis.othrcountry.value) == ""))

	{

		alert("please enter country");

		regis.country.focus();

		return(false);

	}

	

	if(trim(regis.zpcode.value) == "")

	{

		alert("please enter Zipcode");

		regis.zpcode.focus();

		return(false);

	}

	
	if(isNaN(regis.zpcode.value))

	{

		alert("please enter valid Zipcode");

		regis.zpcode.focus();

		return(false);

	}

	

	if(trim(regis.phone.value) == "")

	{

		alert("please enter Phone Number");

		regis.phone.focus();

		return(false);

	}

	

	if(isNaN(regis.phone.value))

	{

		alert("please enter valid Phone Number");

		regis.phone.focus();

		return(false);

	}

	

	if(trim(regis.email.value) == "")

	{

		alert("please enter email");

		regis.email.focus();

		return(false);

	}	

	if(checkEmail(regis.email.value)==false)

	{

		alert("please enter valid email");

		regis.email.focus();

		return(false);

	}	

	

	if(trim(regis.userid.value) == "")

	{

		alert("please enter user Id");

		regis.userid.focus();

		return(false);

	}

	

	if(trim(regis.password.value) == "")

	{

		alert("please enter Password");

		regis.password.focus();

		return(false);

	}

	

	if(regis.password.value != regis.cpass.value)

	{

		alert("Password and Confirm Password are not same");

		regis.cpass.focus();

		return(false);

	}

	return true;

}



function validate_this(s1){



	if(trim(s1.textfield.value)==""){

		alert("please enter name")

		s1.textfield.focus()

		return false

	}

	if(trim(s1.textfield2.value)==""){

		alert("please enter email id")

		s1.textfield2.focus()

		return false

	} else {

			st=s1.textfield2.value;

			if(checkEmail(st)==false)

			{

					alert("Invalid Email Id \n"+st);

					s1.textfield2.focus();

					return false;

			}

	}

	if(trim(s1.textfield3.value)==""){

		alert("please enter phone no")

		s1.textfield3.focus()

		return false

	}

	if(trim(s1.textfield4.value)==""){

		alert("please enter message")

		s1.textfield4.focus()

		return false

	}

}

