//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function popup(mylink, windowname)
	{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	 {
	   href=mylink.href;
	   window.open(href, windowname, 'width=400,height=400,scrollbars=no top=50 left=200');
	   return false;
	 }  
	}
	
	
	function pricepopup(mylink, windowname)
	{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	   href=mylink;
	else
	 {
	   href=mylink.href;
	   window.open(href, windowname, 'width=700,height=750,scrollbars=yes top=50 left=200');
	   return false;
	 }  
	}
	
	
	
	function valform(){
	if (trimString(document.form1.email.value)=="")
	{
		alert("Please Enter Your Email Address :");
		document.form1.email.focus();
		return false;
	}
	if(document.form1.email.value !="")
	{
		
		if(form1.email.value.indexOf(".")==-1 || form1.email.value.indexOf("@")==-1 || form1.email.value.indexOf("'")!==-1)
		{
			alert("Invalid Email Address !! The Email Address You Entered is Not Valid");
			//form1.email.select();
			form1.email.focus();
			return false;
		}
    }
	
	return true;
}

function trimString (str)
{
while (str.charAt(0) == ' ')
str = str.substring(1);
while (str.charAt(str.length - 1) == ' ')
str = str.substring(0, str.length - 1);
return str;
}

function check_password()
{
if (trimString(document.form1.oldpass.value)=="")
	{
		alert("Please Enter Your Old Password :");
		document.form1.oldpass.focus();
		return false;
	}
	
	if (trimString(document.form1.newpass.value)=="")
	{
		alert("Please Enter Your New Password :");
		document.form1.newpass.focus();
		return false;
	}
	
	if (trimString(document.form1.confirmpass.value)=="")
	{
		alert("Please Enter confirm Password :");
		document.form1.confirmpass.focus();
		return false;
	}
	
	if (document.form1.newpass.value!=document.form1.confirmpass.value)
	{
		alert(" Confirm password should be same as new password ");
		document.form1.confirmpass.focus();
		return false;
	}
}

function callpicture(pkid)
	{
	var idval=pkid;
	//alert(idval);
	window.open ("view_picture.asp?id="+idval,"mywindow","menubar=1,resizable=1,width=450,height=550");

	}
	
function checkoutform()
	{
	if (trimString(document.form1.fname.value)=="")
	{
		alert("Please Enter Billing First name :");
		document.form1.fname.focus();
		return false;
	}
	
	if (trimString(document.form1.lname.value)=="")
	{
		alert("Please Enter Billing Last name :");
		document.form1.lname.focus();
		return false;
	}
	
	if (trimString(document.form1.address1.value)=="")
	{
		alert("Please Enter Billing Address1 :");
		document.form1.address1.focus();
		return false;
	}
	
	
	
	if (trimString(document.form1.city.value)=="")
	{
		alert("Please Enter Billing City:");
		document.form1.city.focus();
		return false;
	}
	
	if (trimString(document.form1.state.value)=="")
	{
		alert("Please Enter Billing State :");
		document.form1.state.focus();
		return false;
	}
	
	if (trimString(document.form1.country.value)=="")
	{
		alert("Please Enter Billing Country :");
		document.form1.country.focus();
		return false;
	}
	
	
	if (trimString(document.form1.zipval.value)=="")
	{
		alert("Please Enter Billing Zipcode in numeric format :");
		document.form1.zipval.focus();
		return false;
	}
	
	if (isNaN(document.form1.zipval.value))
	{
		alert("Please Enter Billing Zipcode in numeric format :");
		document.form1.zipval.focus();
		return false;
	}
	
	
	if (trimString(document.form1.phone.value)=="")
	{
		alert("Please Enter Billing Phone :");
		document.form1.phone.focus();
		return false;
	}
	if (trimString(document.form1.email.value)=="")
	{
		alert("Please Enter Billing email :");
		document.form1.email.focus();
		return false;
	}
	
	else
	{
	      var email=document.form1.email.value;
		var emailPat =/^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)$/;
		var matchArray = document.form1.email.value.match(emailPat);
		if (matchArray == null) {
		alert("Invalid billing email address ");
		document.form1.email.focus();
		return false;
		}
	}
	
	/////////////shipping//////////////
	
	if (trimString(document.form1.sfname.value)=="")
	{
		alert("Please Enter Shipping First name :");
		document.form1.sfname.focus();
		return false;
	}
	
	if (trimString(document.form1.slname.value)=="")
	{
		alert("Please Enter Shipping Last name :");
		document.form1.slname.focus();
		return false;
	}
	
	if (trimString(document.form1.saddress1.value)=="")
	{
		alert("Please Enter Shipping Address1 :");
		document.form1.saddress1.focus();
		return false;
	}
	
	if (trimString(document.form1.poption.value)=="none")
	{
		alert("Please select one of the Delivery option:");
		document.form1.poption.focus();
		return false;
	}
	
	if (trimString(document.form1.scity.value)=="")
	{
		alert("Please select Shipping City:");
		document.form1.scity.focus();
		return false;
	}
	
	if (trimString(document.form1.sstate.value)=="")
	{
		alert("Please Enter Shipping State :");
		document.form1.sstate.focus();
		return false;
	}
	
	if (isNaN(document.form1.szipval.value))
	{
		alert("Please Enter Shipping Zipcode in numeric format :");
		document.form1.szipval.focus();
		return false;
	}
	
	if (trimString(document.form1.sphone.value)=="")
	{
		alert("Please Enter Shipping Phone :");
		document.form1.sphone.focus();
		return false;
	}
	
	
	return true;
	}
	
	function smeasbilling()
	{
	if(document.form1.sameval.checked==true)
	{
	document.form1.sfname.value=document.form1.fname.value;
	document.form1.slname.value=document.form1.lname.value;
	document.form1.saddress1.value=document.form1.address1.value;
	document.form1.saddress2.value=document.form1.address2.value;
	document.form1.scity.value=document.form1.city.value;
	document.form1.sstate.value=document.form1.state.value;
	document.form1.scountry.value=document.form1.country.value;
	document.form1.szipval.value=document.form1.zipval.value;
	document.form1.sphone.value=document.form1.phone.value;
	document.form1.semail.value=document.form1.email.value;
	}
	else
	{
	document.form1.sfname.value="";
	document.form1.slname.value="";
	document.form1.saddress1.value="";
	document.form1.saddress2.value="";
	//document.form1.city.value=document.form1.scity.value;
	document.form1.sstate.value="";
	document.form1.scountry.value="";
	document.form1.szipval.value="";
	document.form1.sphone.value="";
	document.form1.semail.value="";
	
	}
	}
	
	
	function chkNumeric(objName)
{
	// only allow 0-9 be entered, plus any values passed
	// (can be in any order, and don't have to be comma, period, or hyphen)
	// if all numbers allow commas, periods, hyphens or whatever,
	// just hard code it here and take out the passed parameters
	var checkOK = "0123456789.";
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	 ch = checkStr.charAt(i);
	 for (j = 0;  j < checkOK.length;  j++)
	 if (ch == checkOK.charAt(j))
	 break;
	 if (j == checkOK.length)
	 {
	  allValid = false;
	  break;
	 }
	if (ch != ",")allNum += ch;
   }
   return (allValid);
}	
	
	
	function chkcard(y,m)
	{
	if(document.form1.cardno.value=="")
	{
	alert("Plase Enter Credt card No");
	document.form1.cardno.focus();
	return false;
	}
	if(!chkNumeric(document.form1.cardno.value))
	{
	alert("Plase Enter valid credit card No");
	document.form1.cardno.focus();
	return false;
	}
	
	if(document.form1.expmonth.value==m && parseInt(document.form1.expyear.value)==parseInt(y))
	{
	alert("Your Credit Card Has been Expired");
	document.form1.expmonth.focus();
	return false;
	}
	return true;
	}
	
