function spawnl(URL,winName,features)

{
//alert(" OI am here in spawn ");
//features example - note you must pass in width & height first (IE 4+ Mac bug) width=700,height=600,directories=no,location=no,menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=no,top=0,left=0
var newWindow=window.open(URL,winName,features);
}


function spawnp(URL,winName,features)

{
//alert(" OI am here in spawn ");
//features example - note you must pass in width & height first (IE 4+ Mac bug) width=700,height=600,directories=no,location=no,menubar=no,scrollbars=yes,toolbar=no,status=no,resizable=no,top=0,left=0
var newWindow=window.open(URL,winName,features);
}



var strValidChars = '0123456789.,';
var returnbol = false;

function checkscript(numbertransrecords)
{





//alert(' I am here in trans rec test and trans count = ' + numbertransrecords);

	if (numbertransrecords == 0)
	{
		// something is wrong
		alert('You have selected checkout but your shopping basket is empty');
		return false;
	}


	// If the script makes it to here, everything is OK,
	// so you can submit the form

	return true;
}

function newWindow(largephoto) {

//alert(" largephoto = " + largephoto);
		photoWindow = window.open(largephoto, "photoWin", "width=300,height=600,left=300,top=60")

}


function newWindowmap() {
		mapWindow = window.open("wh_images/bigmap.gif", "mapWin", "width=500,height=350,left=180,top=60")

}


function confRemove(strName)
{
	var strConf = confirm('Are you sure you wish to remove ' + strName + ' from your cart ?')
	return strConf
}

function confempty(strName)
{
	var strConf = confirm('Are you sure you wish to empty your cart ?')
	return strConf
}




function IsNumeric(strString){
	//  check for valid numeric strings
	var strChar;
	var blnResult = true;
	var i;
	if (strString.length == 0) return returnbol;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
		{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
			{
			blnResult = false;
			}
		}
	return blnResult;
}

function windowpopup(url)

{
	newwindow=window.open(url,'largelookup','height=450,width=600,top=0,left=100');
	if (window.focus) {newwindow.focus()}

}

function windowpopup2(url)

{
	newwindow=window.open(url,'largemaplookup','height=450,width=600,top=50,left=100');
	if (window.focus) {newwindow.focus()}

}


function UpdateProdQty()
{
	var formok = true ;
	var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
	var nums = "0123456789.-" ;
	var msg = "" ;
	var onechar ;

	var objH = document.frmUpdateCartQtys.intQty;

	if(objH.value) //object is not an array
	{ for (x = 0; x < objH.value.length; x++)
		{ if (nums.indexOf(objH.value.charAt(x)) == -1)
			{ msg += "\n   Quantity Entered Must Be Numeric" ;
			  formok = false ;
			}
		}
	}

	else

	{ for(var i=0;i<objH.length;i++)
		{ for (x = 0; x < objH[i].value.length; x++)
				{ if (nums.indexOf(objH[i].value.charAt(x)) == -1)
					{ msg += "\n   All Quantities Entered Must Be Numeric" ;
					  formok = false ;
					}
				}
		}
	}

	if ( ! formok )
	{
		alert("Form validation failed :\n" + msg) ;
	}
	else
	{
		document.frmUpdateCartQtys.submit();
	}

}

function UpdateProdQty2()
{
	var formok = true ;
	var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
	var nums = "0123456789.-" ;
	var msg = "" ;
	var onechar ;

	var objH = document.frmUpdateCartQtys2.intQty;

	if(objH.value) //object is not an array
	{ for (x = 0; x < objH.value.length; x++)
		{ if (nums.indexOf(objH.value.charAt(x)) == -1)
			{ msg += "\n   Quantity Entered Must Be Numeric" ;
			  formok = false ;
			}
		}
	}

	else

	{ for(var i=0;i<objH.length;i++)
		{ for (x = 0; x < objH[i].value.length; x++)
				{ if (nums.indexOf(objH[i].value.charAt(x)) == -1)
					{ msg += "\n   All Quantities Entered Must Be Numeric" ;
					  formok = false ;
					}
				}
		}
	}

	if ( ! formok )
	{
		alert("Form validation failed :\n" + msg) ;
	}
	else
	{
		document.frmUpdateCartQtys2.submit();
	}

}






function validateProdQty(frmF)
{
	var formok = true ;
	var numchk = true ;
	var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
	var nums = "0123456789" ;
	var msg = "" ;
	var onechar ;

	var qty_new = document.forms[frmF].elements["intQty"]
	var stk_qty = document.forms[frmF].elements["stock_quantity"];
	var qty_old = document.forms[frmF].elements["intQty_original"];
	var qty_tot = document.forms[frmF].elements["total_intqty"];
	var prod_view_status = document.forms[frmF].elements["prodview"];
	//alert("I am here re prodview  = " + prod_view_status.value);
	//alert("I am here re qty before  = " + qty_new.value);
	//alert("I am here re total qty before  = " + qty_tot.value);
	//alert("I am here re original qty before  = " + qty_old.value);

	if (qty_new.value.length == 0)
		{
		msg += "\n   Please enter a order quantity." ;
					formok = false ;
					numchk = false ;
   	}
			else
		{
				charcheck = true;
				for (i = 0; i < qty_new.value.length; i++)
				{
					if (nums.indexOf(qty_new.value.charAt(i)) == -1)
					{
						charcheck = false ;
					}
				}
				if ( ! charcheck )
				{
					msg += "\n order quantity must be numeric." ;
					formok = false ;
					numchk = false ;
				}
				else
				{
					if (qty_new.value <= 0)
					{
						msg += "\n order quantity must greater then zero." ;
						formok = false ;
						numchk = false ;
					}
				}
	}

	if (formok)
	{
		var qty_new_int = parseFloat(qty_new.value) ;
		var stk_qty_int = parseFloat(stk_qty.value) ;
		var qty_tot_int = parseFloat(qty_tot.value) ;
		var qty_old_int = parseFloat(qty_old.value) ;


		if (prod_view_status.value == "yes")
		{
			qty_all_int =  qty_new_int +  qty_tot_int;
			//alert("I am here qty_all_int = " + qty_all_int);

	   	}
	   	else
	   	{
	   		qty_all_int = qty_new_int;
	   	}

		//alert("I am here re after prod_view_status chk - qty_all_int= " + qty_all_int);

		if (qty_all_int > stk_qty_int)
		{
			var qty_diff = qty_all_int - stk_qty_int;
			var qty_diff2 = qty_new_int - qty_diff;
			//alert("I am here qty diff = " + qty_diff);
			//alert("I am here qty diff2 = " + qty_diff2);
			if ( qty_diff2 == 0 )
			{
			msg += "\n Sorry  your total order quantity of " + qty_all_int + " exceeds our available stock quantity of  " + stk_qty_int;
			document.forms[frmF].elements["intQty"].value = qty_diff2;
			formok = true ;
			alert("Form validation failed :\n" + msg) ;

			}
			else
			{
			msg += "\n Sorry only " + stk_qty_int + " stock available & your total order quantity is " + qty_all_int + " therefore your order quantity reduced to " + qty_diff2 + "                                      Please select 'Buy' again to confirm new order quantity" ;
			document.forms[frmF].elements["intQty"].value = qty_diff2;
			formok = true ;
			alert("Form validation failed :\n" + msg) ;

			}
		}
	}

	if ( ! formok )
	{
		alert("Form validation failed :\n" + msg) ;
		return false;
	}
	else
		return formok;

}

function validateProdQty2(frmF)
{
	var formok = true ;
	var numchk = true ;
	var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
	var nums = "0123456789" ;
	var msg = "" ;
	var onechar ;

	var qty_new = document.forms[frmF].elements["intQty"]
	var stk_qty = document.forms[frmF].elements["stock_quantity"];
	var qty_old = document.forms[frmF].elements["intQty_original"];
	var qty_tot = document.forms[frmF].elements["total_intqty"];
	var prod_view_status = document.forms[frmF].elements["prodview"];
	//alert("I am here re prodview  = " + prod_view_status.value);
	//alert("I am here re qty before  = " + qty_new.value);
	//alert("I am here re total qty before  = " + qty_tot.value);
	//alert("I am here re original qty before  = " + qty_old.value);

	if (qty_new.value.length == 0)
		{
		msg += "\n   Please enter a order quantity." ;
					formok = false ;
					numchk = false ;
   	}
			else
		{
				charcheck = true;
				for (i = 0; i < qty_new.value.length; i++)
				{
					if (nums.indexOf(qty_new.value.charAt(i)) == -1)
					{
						charcheck = false ;
					}
				}
				if ( ! charcheck )
				{
					msg += "\n order quantity must be numeric." ;
					formok = false ;
					numchk = false ;
				}
				else
				{
					if (qty_new.value <= 0)
					{
						msg += "\n order quantity must greater then zero." ;
						formok = false ;
						numchk = false ;
					}
				}
	}

	if (formok)
	{
		var qty_new_int = parseFloat(qty_new.value) ;
		var stk_qty_int = parseFloat(stk_qty.value) ;
		var qty_tot_int = parseFloat(qty_tot.value) ;
		var qty_old_int = parseFloat(qty_old.value) ;


		if (prod_view_status.value == "yes")
		{
			qty_all_int =  qty_new_int +  qty_tot_int;
			//alert("I am here qty_all_int = " + qty_all_int);

	   	}
	   	else
	   	{
	   		qty_all_int = qty_new_int;
	   	}

		//alert("I am here re after prod_view_status chk - qty_all_int= " + qty_all_int);

		if (qty_all_int > stk_qty_int)
		{
			var qty_diff = qty_all_int - stk_qty_int;
			var qty_diff2 = qty_new_int - qty_diff;
			//alert("I am here qty diff = " + qty_diff);
			//alert("I am here qty diff2 = " + qty_diff2);
			msg += "\n Sorry only " + stk_qty_int + " stock available & your total order quantity of " + qty_all_int + " exceeds available stock ";
			document.forms[frmF].elements["intQty"].value = qty_diff2;
			formok = true ;
			alert("Form validation failed :\n" + msg) ;
		}
	}

	if ( ! formok )
	{
		alert("Form validation failed :\n" + msg) ;
		return false;
	}
	else
		return formok;

}

	


