// ***************** general use functions ******************
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 YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}
function confirm_delete_but(formname,obj,button_name,button_value)
{
str="Do you really want to delete this " + obj +"?";
msg= confirm (str);
		if (msg)
		{
		str="document." + formname + "." + button_name + ".value= '" + button_value +"';" ;
		eval(str);
		str="document." + formname + ".submit()";
		eval(str);
		}
}
// confirmation on delete
function confirm_delete(url, obj)
{
str="Do you really want to delete " + obj +"?";
msg= confirm (str);
		if (msg)
		{
			window.location.href = url;
		}
}
function hide_div(obj) {
//190805 -  "hide_div" function is fixed in same manner as it is did in advanced search. - Start
var div_arr = document.getElementsByTagName("div");
		for(i=0;i<div_arr.length;i++)
		{
			if(div_arr[i].getAttribute("id") == "search")
			{
				div_arr[i].style.display="none";
			}
		}
//190805 -  "hide_div" function is fixed in same manner as it is did in advanced search. - End
		//search.style.display="none";
}
function show_div(obj) {
//190805 - Advanced link in search form on admin panel has been fixed. This is first done in ip. "hide_div" function is to be fixed in same manner. - Start
var div_arr = document.getElementsByTagName("div");
		for(i=0;i<div_arr.length;i++)
		{
			if(div_arr[i].getAttribute("id") == "search")
			{
				div_arr[i].style.display="inline";
			}
		}
//190805 - Advanced link in search form on admin panel has been fixed. This is first done in ip. "hide_div" function is to be fixed in same manner. - End
		//search.style.display="inline";
}
/**********************
Function for setting hidden values in the form
*************************/
function set_field(formname,fieldname,set_value)
{
	//	alert(formname + "|" + fieldname + "|" + set_value);
		str="document." + formname + "." + fieldname  + ".value='" + set_value + "'";
//		alert(str);
		eval(str);
}
/******************************************************************/
/******************************************************************/
/**********************
Function for setting the parent window that triggered the  select cat pop up
This goes in the parent window
*************************/
function set_cat(field_name,cat_name,field_id, cat_id,field_text,cat_text,field_page,cat_page,field_code,cat_code,form_name){
	str = "document." + form_name + "." + field_name + ".value = '" + cat_name + "';" ;
	eval (str);
	str = 'document.' + form_name + '.' + field_id + '.value = ' + cat_id + ';' ;
	eval (str);
	if(field_name=="c_name1")
	{
	str = "document." + form_name + "." + field_page + ".value = '" + cat_text + "';" ;
	eval(str);
	str = "document." + form_name + "." + field_text + ".value = '" + cat_page + "';" ;
	eval (str);
	str = "document." + form_name + "." + field_code + ".value = '" + cat_code + "';" ;
	eval (str);
	}
}
/******************************************************************/
/**********************
Function for setting the parent window that triggered the  select cat pop up
This goes in the pop up window
*************************/
function cat_set_parent(cat_id, cat_name,cat_text,cat_page,cat_code){
//alert(cat_id+ cat_name+cat_text+cat_page+cat_code);
		document.cat_pop_form.cat_id.value = cat_id;
		document.cat_pop_form.cat_name.value = cat_name;
		document.cat_pop_form.cat_text.value = cat_text;
		document.cat_pop_form.cat_page.value = cat_page;
		document.cat_pop_form.cat_code.value = cat_code;
	//alert(cat_code);
		field_name = document.cat_pop_form.field_name.value;
		field_id = document.cat_pop_form.field_id.value;
		field_text = document.cat_pop_form.field_text.value;
		field_page= document.cat_pop_form.field_page.value;
		field_code = document.cat_pop_form.field_code.value;
		form_name = document.cat_pop_form.form_name.value;
//	alert(field_text);
		window.opener.set_cat(field_name,cat_name,field_id,cat_id,field_text,cat_text,field_page,cat_page,field_code,cat_code,form_name);
		window.close();
}
/*********************************************************/
//	TO SELECT FROM SELECTION BOX
function show_selected(obj,val)
{
//obj = document.frmname.fieldname
//val=actual value <?php echo $obj->country; ?>
  var len=obj.options.length
  for(var i=0;i<len;i++)
  {
    if(obj.options[i].value==val)
     {
       obj.selectedIndex=i;
     }
  }
}
function win_open(obj,type,val){
	if(obj.value == val){
		window.open('../forms/choose_email_pop.php?hidden_purpose=paging&typ='+type);
	}
}
function pending_sub()
{
document.commonfrm.pending.value="Link.status_link_to_them='Pending Approval'";
document.commonfrm.show_button.value="Y";
document.commonfrm.submit();
}
/************************************************************************/
/********************* Function for customer ***********************/
function delete_cust(val){
	if(confirm("Do you really want to delete ?")){
		document.frm_search.deleteid.value = val;
		document.frm_search.editid.value = '';
		document.frm_search.id.value = val;
		document.frm_search.submit();
	}
}
function edit_cust(val){
		document.frm_search.deleteid.value = '';
		document.frm_search.editid.value = val;
		document.frm_search.id.value = val;
		document.frm_search.show_list.value = "N";
		document.frm_search.submit();
}
//modified on 17102003
function edit_link(frm_name,val){
		frm_name.linkdeleteid.value = '';
		frm_name.id.value = val;
		frm_name.editid.value = val;
		frm_name.show_list.value = "N";
		frm_name.submit();
}
//modified on 17102003
function delete_link(frm_name,val){
	if(confirm("Are you sure you want to delete?")){
		frm_name.linkdeleteid.value = val;
		frm_name.editid.value = '';
		frm_name.id.value = val;
		frm_name.submit();
	}
}
function pending_approval(){
	document.frm_search.search_status.value =  " Customer.status = 1";
	document.frm_search.start_with_key1.value = "";
	document.frm_search.contains_key1.value = "";
	document.frm_search.search_group_id.value = "";
	document.frm_search.contains_list.value = "";
	document.frm_search.search_news_letter.value = "";
	document.frm_search.search_customer_interest.value = "";
	document.frm_search.submit();
}
function stock_list(){
	document.frm_search.submit();
}
function stock_list(){
	document.frm_search.start_with_key1.value = "";
	document.frm_search.start_with_list.value = "";
	document.frm_search.submit();
}
function customer_list(){
	document.frm_search.search_status.value =  "";
	document.frm_search.start_with_key1.value = "";
	document.frm_search.contains_key1.value = "";
	document.frm_search.search_group_id.value = "";
	document.frm_search.contains_list.value = "";
	document.frm_search.search_customer_interest.value = "";
	document.frm_search.hidden_purpose.value =  "new";
	document.frm_search.submit();
}
function customer_search(val){
	if(val=="1"){
		document.frm_search.search_status.value =  "";
		document.frm_search.contains_key1.value = "";
		document.frm_search.search_group_id.value = "";
		document.frm_search.contains_list.value = "";
		document.frm_search.search_news_letter.value = "";
		document.frm_search.search_customer_interest.value = "";
		return true;
	}else{
		document.frm_search.start_with_key1.value = "";
		document.frm_search.start_with_list.value = "0";
		return true;
	}
return false;
}
/********************* Function for customer ***********************/
/****function to change the page in categories (customer/links) upon choosing a category to edit****/
function change_page(obj, actionpage)
{
	if(obj.value > 0)
	{
		str="window.location.href='" + actionpage + "?id=" + obj.value + "&hidden_purpose=paging'";
		//alert(str);
		eval(str);
	}
}
// used to set the values for category in link
function getvalues(obj) //changed on 170904
{
//get_val=obj.value;
get_val = obj; //170505
//if(obj.value.length > 1)
if(obj.length > 1) //170505
{
//alert(get_val);
a = get_val.split("|");
id = a[0];
link_page=a[2];
link_text=a[3];
link_code=a[4];
link_description=a[5];
catid=change_quotes(id,'primary_cat1');
link_page=change_quotes(link_page,'c_url');
link_text=change_quotes(link_text,'c_link_txt');
link_code=change_quotes(link_code,'c_link_code');
link_description=change_quotes(link_description,'link_description');
}//changed
else
{
link_page=change_quotes('','c_url');
link_text=change_quotes('','c_link_txt');
link_code=change_quotes('','c_link_code');
link_description=change_quotes('','link_description');
}
}
//modified on 20102003//
function change_quotes(abc,field_name)
{
	str = abc;
	do{
		count=new Array();
		str = str.replace("!~!","\\'");
		count = str.split("!~!");
	}while(count.length >1);
	do{
		count=new Array();
		str = str.replace("~@#","\"");
		count = str.split("~@#");
	}while(count.length >1);
	//str = str.replace("~@#","\"");
	chk_quote=str.split("\"");
	//alert("Count "+ chk_quote.length);
	if(chk_quote.length >1)
	{
		eval_str="window.opener.document.link_search."+field_name+".value='"+str+"'"; //170505 - window.opener added as the values should be set to the parent window.
	}
	else
	{
		eval_str="window.opener.document.link_search."+field_name+".value=\""+str+"\"";//170505 - window.opener added as the values should be set to the parent window.
	}
		eval(eval_str);
}
//update_config.php
function count_copies(val,cop){
ct = 0;
	for(i=1;i<=4;i++){
		if( eval("document.configform." + val + "" + i + ".value.length")>0 ){
			ct++;
		}
	}
	eval("document.configform." + cop + ".value = '" + ct + "'");
}
//links_list.php
function check_all(frm,sel,val)
{
	for(i=0;i<eval("document." + frm + ".elements.length");i++)
	{
	nam = eval("document." + frm + ".elements[" + i + "].name");
		if(nam.substring(0,3)==val)
		{
		eval("document." + frm + ".elements[" + i + "].checked = " + sel.checked);
		//14012004-for links also set the statusfield to "Active";
		if(frm=="link_search")
		{
				new_obj=eval("document." + frm + ".elements[" + i + "]");
				new_id=eval("document." + frm + ".elements[" + i + "].name");
				new_auto_id=new_id.substr(14,new_id.length-15);
//				chk_link_click(obj, id);
//				alert(new_obj + "-" + new_auto_id + "- " + new_id);
				chk_link_click(new_obj, new_auto_id);
		} //end if frm=="link_search";
		} //end if==val
	} //end for
} //end function
//choose_email_pop.php
function setid(obj,fld){
	if(obj.checked){
		//document.frm_search.checkids.value += obj.value+";";
		fld.value += obj.value+";";
	}else{
		//arr_str = document.frm_search.checkids.value;
		arr_str = fld.value;
		arr = arr_str.split(";");
		str = "";
		for(i=0;i<arr.length;i++){
			if(arr[i] != obj.value){
				if(arr[i].length > 0){
					str = str + arr[i] + ";";
				}
			}
		}
		//document.frm_search.checkids.value = str;
		fld.value = str;
	}
}
function set_cust_id(obj){
if(obj.checked){
	document.registrationform.customer_interest.value += obj.value+";";
}else{
	arr_str = document.registrationform.customer_interest.value;
	arr = arr_str.split(";");
	str = "";
	for(i=0;i<arr.length;i++){
		if(arr[i] != obj.value){
			if(arr[i].length > 0){
				str = str + arr[i] + ";";
			}
		}
	}
	document.registrationform.customer_interest.value = str;
}
}
function set_newsletter_id(obj,frm){
if(obj.checked){
	frm.value += obj.value + ",";
}else{
	arr_str = frm.value;
	arr = arr_str.split(",");
	str = "";
	for(i=0;i<arr.length;i++){
		if(arr[i] != obj.value){
			if(arr[i].length > 0){
				str = str + arr[i] + ",";
			}
		}
	}
	frm.value = "," + str;
}
}
function goTo(url){
	window.location = url;
}
///--------- newly added 27 - 09 - 2003
function delete_record(frm,fld,val)
{
	if(confirm('Do you really want to delete ?'))
	{
		set_field(frm,fld,val);
		str = "document." + frm + ".submit()";
		eval(str);
	}
}
function delete_newsletter(frm,fld,val)
{
	if(confirm('Deleting this newsletter will also delete any issues that belong to it. \nAre you sure you want to delete?'))
	{
		set_field(frm,fld,val);
		str = "document." + frm + ".submit()";
		eval(str);
	}
}
///--------- newly added 27 - 09 - 2003
///--------- newly added 29 - 09 - 2003
function delete_image_flex(val)
{
	if( confirm('Do you really want to delete ?') )
	{
	set_field('frm_image_delete','img_del_id',val);
	document.frm_image_delete.submit();
	}
}
///--------- newly added 29 - 09 - 2003
///--------- Start newly added 06 - 10 - 2003
function set_product_parent(val1,val2,val3)
{
	if(val1.value==0 && val2.value==0 && val3.value==0)
	{
		document.frm_product_detail.parent_id.value="0";
	}
	else if(val1.value!=0 || val2.value!=0 || val3.value!=0)
	{
		document.frm_product_detail.parent_id.value="-1";
	}
}
///--------- end newly added 06 - 10 - 2003
//--------- newly added 07 - 10 - 2003
function fun_on_special(textbox)
{
/*
	if(!document.frm_product_detail.on_special.checked)
	{
		alert('you must tick the on special tick box before you can specify a special price');
		textbox.blur();
	}
	*/
}
//--------- end newly added 07 - 10 - 2003
//********************Newly added on 18-10-2003
function check_options(frm)
{
	var str = has_options(frm,"pro_",4);
	if(str.length <= 0 && eval("document."+frm+".qty.value") >0)
	{
		//frm.submit();
		return true;
	}
	var select_option = false;
	var str_arr = str.split(",");
	for(i=0;i<str_arr.length-1;i++)
	{
		if(eval("document."+frm+".elements[str_arr[i]].value") == 0)
		{
			select_option = true;
		}
	}
	if(select_option)
	{
		alert("Please select all available options");
		return false;
	}
	else
	{
		//product_option
		var str_option = has_options(frm,"product_option",14);
		var str_option_arr = str_option.split(",");
		//alert(str_arr.length);
		selected_str = "";
			for(i=0;i<str_arr.length-1;i++)
			{
				selected_str += eval("document."+frm+".elements[str_arr[i]].value") + ";";
			}
			for(i=str_arr.length-1;i<3;i++)
			{
				selected_str += "0;";
			}
			selected_option_has = false;
		for(i=0;i<str_option_arr.length-1;i++)
		{
			if(eval("document."+frm+".elements[str_option_arr[i]].value") == selected_str)
			{
				selected_option_has = true;
				break;
			}
		}
		if(selected_option_has)
		{
			//frm.submit();
			return true;
		}
		else
		{
			alert("Selected option is not available");
			return false;
		}
	}
}
function has_options(frm,fld_name_letters,chk_length)
{
var str = "";
	var temp_str = "document." + frm + ".elements.length";
	len=eval(temp_str);
	for(i=0;i<len;i++)
	{
		fld_name = eval("document." + frm + ".elements[i].name");
		if(fld_name.substring(0,chk_length) == fld_name_letters )
		{
			str += fld_name + ",";
		}
	}
	return(str);
}
//********************end of newly added on 18-10-2003
//********************Newly added on 21-10-2003
function check_number(val, frmpage)
{
	if( isNaN(val.value) )
	{
		alert("Please enter in digits.");
		val.value = 1;
	}
	if( val.value <= 0 && frmpage!="admin")//240204 - admin price management - price can be 0)
	{
		msg="";
		msg+="Please enter quantity greater than 0.";
		if(frmpage=="cart")
		{
			msg+="\n(if you wish to remove this product from your shopping cart,\n use the 'delete' button)";
		}
		alert(msg);
		val.value = 1;
	}
}
//********************end of newly added on 21-10-2003
//********************newly added on 22-10-2003
  function check_rewardpoints(val,val_has)
  {
/*
  	if(isNaN(val_has))
	  	alert(val.value + "-" + val_has);
*/
	if( isNaN(val.value) )
	{
		alert("Please enter in digits.");
		val.value = 0;
		return false;
	}
	else if( val.value < 0 )
	{
		alert("Please enter greater than zero.");
		val.value = 0;
		return false;
	}
	else if( val.value > val_has )
	{
		alert("Please enter reward point less than you have.");
		val.value = 0;
		return false;
	}
	document.forms["submitorder"].submit_action.value = 'recalculate';
	document.forms["submitorder"].submit();
  }
//********************end of newly added on 22-10-2003
function delete_cart(frm,fld,val)
{
	if(confirm('Are you sure you want to empty you shopping cart?'))
	{
		set_field(frm,fld,val);
		str = "document." + frm + ".submit()";
		eval(str);
	}
}
/*** to open converter.php ***/
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/** to manage and validate page name and category or item name **/
function set_pname(obj1, obj2){
obj2.value = obj1.value;
clean_chars(obj2);
}
function clean_chars(obj) {
// will remove any non alphanumeric char from string except for space which it will replace with undesrcor, and set the obj value to the fixed string
	var string = obj.value
		for (var i=0, output='', valid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"; i<string.length; i++)
			if (string.charAt(i)==" "){
				output += "-";
			} else {
				if (valid.indexOf(string.charAt(i)) != -1){
					 output += string.charAt(i);
				}
			}
//230304
	output = output.replace( "--", "-");
	output = output.replace( "--", "-");
	obj.value=output.toLowerCase();
}
//13122003 - selectionpage.php
function set_all(frm, sel, fld)
{
//	alert(frm + " *" + sel.checked + " *" + fld);
		for(i=0;i<eval("document." + frm + ".elements.length");i++)
			{
			fld_type = eval("document." + frm + ".elements[" + i + "].type");
			temp_str="-";
			if(fld_type=="checkbox")
				{
				nam = eval("document." + frm + ".elements[" + i + "].name");
				obj=eval("document." + frm + ".elements[" + i + "]");
				if(sel.checked)
				{
					setid(obj, fld);
				}
				temp_str += obj.value;
			/*
				fld_value = eval("document." + frm + ".elements[" + i + "].value");
				alert(fld_value);
				*/
				} //end if type chkbox
			} //end for
		if(sel.checked)
		{
		} //end if sel.checked
		else
		{
			arr_str = fld.value;
			alert(temp_str + "****" + arr_str);
			arr = arr_str.split(";");
			str = "";
			for(i=0;i<arr.length;i++){
				if(arr[i] != obj.value){
					if(arr[i].length > 0){
						str = str + arr[i] + ";";
					}
				}
			}
			//document.frm_search.checkids.value = str;
			fld.value = str;
		}	//end else .checked
}
 /**************************EMAIL CHECKING***************************/
function chk_email(fldname)
{
	var bool=true;
	email = fldname.value;
	var len = email.length;
	if(len<5)
		{
//			alert("Invalid Email - id")
//            fldname.value="";
			bool=false;
		}
	else
		{
	var index1 = email.indexOf('@');
	var subind = email.substring(0,index1);
	var indlen = subind.length;
	var index2 = email.indexOf('.');
	var subind1=email.substring(indlen+1,index2);
	var indlen1 = subind1.length;
	var index3 = email.indexOf(' ');
	var subind3=email.substring(index2+1,len)
	var indlen2 = subind3.length;
	if((index1!= -1)&&(index2!= -1)&&(index3==-1))
	{
		if((indlen!=0)&&(indlen1!=0)&&(indlen2!=0))
		{
//   			alert("valid Email -id");
		}
        else
		{
//			alert("Invalid Email - id")
//            fldname.value="";
		}
	}
	else
	{
//   		alert("Invalid Email - id");
//        fldname.value="";
			bool=false;
	}
	} // end of else if len<5
	return(bool);
}
//while adding to cart validation...
function chk_specification(formname, has_spec)
{
//******** 280705 - check for quantity to be the integer oly in the onclick of the  order now button
var temp_numcheckstr="document."+formname+".qty.value"
	var qty_val = eval(temp_numcheckstr);
	if( isNaN(qty_val) || qty_val <= "0" || qty_val.length == 0)
	{
		alert("Please enter quantity greater than 0.");
		eval(temp_numcheckstr + "=1");
		return false;
	}
	chk_options = check_options(formname);
//	return false;
	if(chk_options)
	{
		if(has_spec > 0)
		{
			var temp_msg="";
			for(i=1;i<=has_spec;i++)
			{
				var temp_str="document."+formname+".specification_id" + i + ".value"
				if(eval(temp_str)==0)
				{
					temp_msg+="Please Choose Specification " + i;
				}
			}
			if(temp_msg.length > 0)
			{
//				alert("Please Choose a Specification");
				alert("Please select all available specifications");
				return false;
			}
			else
			{
	//			return true;
				eval("document." + formname + ".submit()");
			}
		}//end if
		else
		{
				eval("document." + formname + ".submit()");
		}
	}//end if chk_options
	else
	{
		return false;
	}
}
function printPage() {
  if (window.print)
    window.print()
  else
    alert("Sorry, your browser doesn't support this feature.");
}
// 05022004 general delete function to return true or false
function alert_delete()
{
	c=confirm("Are you sure you want to delete?");
	if(c)
		return true;
	else
		return false;	
}
//180406 - site specific - the qty box alert should be in the onclick event of the update cart button.
function update_cart(frmname)
{
var is_num = 0, is_zero = 0;
var msg = "", dc, str = "";
dc = eval("document." + frmname);
	for(i = 0; i < dc.elements.length; i++)
	{
		str = dc.elements[i].getAttribute('name').substring(0,7);
		if(str == "cartqty")
		{
			if(isNaN(dc.elements[i].value) )
			{
				is_num = 1;
				dc.elements[i].value = 1;
			}
			if(dc.elements[i].value == 0 || dc.elements[i].value.length == 0)
			{
				is_zero = 1;
				dc.elements[i].value = 1;
			}
			/*
			if(is_num == 1 && is_zero == 1)
				break;
			*/
		}
	} //end for
	if(is_num == 1)
			msg+="Please enter quantity greater than 0.";
	if(is_zero == 1)
			msg+="Please enter quantity greater than 0.\n(if you wish to remove a product from your shopping cart,\n use the 'delete' button)";
	if(msg.length > 0)
	{
		alert(msg);
	}
	else
	{
		set_field(frmname,'submit_action','update');
		dc.submit();
	}
}

