<!--hide this script from non-javascript-enabled browsers
<!--bu kısım rollover icin-->
function MM_findObj(n, d) 
{ //v3.0
  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); return x;
}
/* Functions that swaps images. */
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_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;
}

/* Functions that handle preload. */
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];}}
}

// Checks date
function CheckDateValue (DayValue,MonthValue,YearValue)
{
	var objDate
	objDate = new Date(YearValue,MonthValue-1,DayValue);
	if (objDate.getYear() != YearValue || 
		objDate.getMonth () + 1 != MonthValue || 
		objDate.getDate ()!= DayValue )
		return false;
		
	return true;
}

// Checks date
function CheckDueDate (day,month,year)
{
	var fDay = document.forms['BuyForm'].elements[day];
	var fMonth = document.forms['BuyForm'].elements[month];
	var fYear = document.forms['BuyForm'].elements[year];
	var DayValue= fDay.options[fDay.options.selectedIndex].value;
	var MonthValue = fMonth.options[fMonth.options.selectedIndex].value;
	var YearValue= fYear.options[fYear.options.selectedIndex].value;
	if(DayValue!="" && MonthValue!="" && YearValue!="") {
		var objDate
		objDate = new Date(YearValue,MonthValue-1,DayValue);
		if(objDate.getDay()==0 || objDate.getDay()==6) {
			alert("Ödeme tarihini hafta sonu seçmeyiniz.");
			return false;
		}
	}
	return true;
}

//opens window
function OpenWindow(URL,WIDTH,HEIGHT)
{
	var left=200;
	var top =0;
	window.open(URL,Math.floor(Math.random()*(100)),'left='+left+',top='+top+',width='+WIDTH+',height='+HEIGHT+',resizable=yes');
}

//opens window
function OpenWindow2(URL,WIDTH,HEIGHT,left,top)
{
	var left=0;
	var top =0;
	window.open(URL,Math.floor(Math.random()*(100)),'left='+left+',top='+top+',width='+WIDTH+',height='+HEIGHT+',resizable=yes');
}

function OpenWindow3(URL,WIDTH,HEIGHT)
{
	var left=100;
	var top =0;
	window.open(URL,Math.floor(Math.random()*(100)),'left='+left+',top='+top+',width='+WIDTH+',height='+HEIGHT+',scrollbars=yes,resizable=yes');
}

function OpenHPWindow()
{
	var left=0;
	var top =0;
	window.open('HP.asp','HpWindow','left=0,top=0,width=802,height=525,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes');
}

function Only_Digit(e) {
  var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13 || whichCode == 8 || whichCode == 46 || whichCode == 9) return true;  // Enter & Backspace & Delete & Tab
	if (whichCode == 37 || whichCode == 39) return true;  // Left & Right
	if(whichCode>=96 && whichCode<=105) return true;
	if(whichCode>=48 && whichCode<=57) return true;
	return false;
}

function AddToList(ProductID,ImgID,ListName) {
	var quantity = 1;
	var elem = document.getElementById("QUANTITY_"+ ProductID);
	if(elem!="") {
		quantity = elem.value
		if(!IsNumeric(quantity))
			quantity = 1;
	}
	document.images['LIST_'+ImgID].src='ListInv.asp?ProductID='+urlEncode(ProductID) + '&Quantity=' + quantity;
	alert("Ürün '"+ ListName +"' listenize eklendi.")
}

function AddSetToList(ProductID,ImgID,ListName) {
	var quantity = 1;
	var elem = document.getElementById("QUANTITY_"+ ProductID);
	if(elem!="") {
		quantity = elem.value
		if(!IsNumeric(quantity))
			quantity = 1;
	}
	document.images['LIST_'+ImgID].src='ListInv.asp?ProductID='+ProductID+'&ItemType=P&Quantity=' + quantity;
	alert("Paket '"+ ListName +"' listenize eklendi.")
}

function AddToBasket(ProductID, ImgID, BasketName) {
	var quantity = 1;
	var elem = document.getElementById("QUANTITY_"+ ProductID);
	if(elem!="") {
		quantity = elem.value
		if(!IsNumeric(quantity))
			quantity = 1;
	}
	document.images['BASKET_'+ImgID].src='BasketInv.asp?ProductID='+urlEncode(ProductID) + '&Quantity=' + quantity;
	alert("Ürün '"+ BasketName +"' sepetinize eklendi.")
}

function AddSetToBasket(ProductID, ImgID, BasketName) {
	var quantity = 1;
	var elem = document.getElementById("QUANTITY_"+ ProductID);
	if(elem!="") {
		quantity = elem.value
		if(!IsNumeric(quantity))
			quantity = 1;
	}
	document.images['BASKET_'+ImgID].src='BasketInv.asp?ProductID='+ProductID+'&ItemType=P&Quantity=' + quantity;
	alert("Paket '"+ BasketName +"' sepetinize eklendi.")
}


/* Functions checks form fields. */
function IsOnlySpace(form,fieldname,errmsg)
{
	re = /\s*/;
	val = form.elements[fieldname].value;
	if ( re.exec(val) == val && val != "")
	{
		alert(errmsg);
		form.elements[fieldname].value = "";
		form.elements[fieldname].focus();
		return(true);
	}
	return(false);
}

//urlencode
function urlEncode(inStr) 
{
	outStr=' '; //not '' for a NS bug!
	for (i=0; i < inStr.length; i++) 
	{
		aChar=inStr.substring (i, i+1);
		switch(aChar)
		{
			case '%': outStr += "%25"; break; case ',': outStr += "%2C"; break;
			case '/': outStr += "%2F"; break; case ':': outStr += "%3A"; break;
			case '~': outStr += "%7E"; break; case '!': outStr += "%21"; break;
			case '"': outStr += "%22"; break; case '#': outStr += "%23"; break;
			case '$': outStr += "%24"; break; case "'": outStr += "%27"; break;
			case '`': outStr += "%60"; break; case '^': outStr += "%5E"; break;
			case '&': outStr += "%26"; break; case '(': outStr += "%28"; break;
			case ')': outStr += "%29"; break; case '+': outStr += "%2B"; break;
			case '{': outStr += "%7B"; break; case '|': outStr += "%7C"; break;
			case '}': outStr += "%7D"; break; case ';': outStr += "%3B"; break;
			case '<': outStr += "%3C"; break; case '=': outStr += "%3D"; break;
			case '>': outStr += "%3E"; break; case '?': outStr += "%3F"; break;
			case '[': outStr += "%5B"; break; case '\\': outStr += "%5C"; break;
			case ']': outStr += "%5D"; break; case ' ': outStr += "+"; break;
			default: outStr += aChar;
		}
	}
	return outStr.substring(1, outStr.length);
}

//urlencode
function TopBannerClick() 
{
	document.location = 'default.asp';
}
//-->


var errEmail = 'E-posta adresi name@domain formatında olmalı ve Türkçe karakter içermemelidir.';
// Email check start
function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
/* Finally, let's start trying to figure out if the supplied address is
   valid. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
		return false
	    }
    }
    return true
}
// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
    return false
}
/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   return false
}
// Make sure there's a host name preceding the domain.
if (len<2) {
   return false
}
// If we've gotten this far, everything's valid!
return true;
}
// Email check End


function IsNumeric(str)
{
	var len =str.length;
    for (var i = 0; i < len; i++) 
    {
      var ch = str.substring(i, i + 1);
      if ((ch < "0" )||( ch > "9" )) 
      {
        return false;
      }
    }
    return true; 
}

function IsFloat(str)
{
	var len =str.length;
    for (var i = 0; i < len; i++) 
    {
      var ch = str.substring(i, i + 1);
      if ((ch < "0" )||( ch > "9" )) 
      {
		if (ch != "," && ch != ".")
			return false;
      }
    }
    return true; 
}

// Checks text box whether is valid date
function checkdate(objName) {
var datefield = objName;
if (chkdate(objName) == false) {
datefield.select();
alert("Girdiğiniz tarih doru değil lütfen tekrar deneyin.");
datefield.focus();
return false;
}
else {
return true;
   }
}
function chkdate(objName) {
//var strDatestyle = "US"; //United States date style
var strDatestyle = "EU";  //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Oca";
strMonthArray[1] = "Şub";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Nis";
strMonthArray[4] = "May";
strMonthArray[5] = "Haz";
strMonthArray[6] = "Tem";
strMonthArray[7] = "Ağu";
strMonthArray[8] = "Eyl";
strMonthArray[9] = "Eki";
strMonthArray[10] = "Kas";
strMonthArray[11] = "Aralık";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
if (strDatestyle == "US") {
 // datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
// datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
function doDateCheck(from, to) {
if (Date.parse(from.value) <= Date.parse(to.value)) {
alert("The dates are valid.");
}
else {
if (from.value == "" || to.value == "") 
alert("Both dates must be entered.");
else 
alert("To date must occur after the from date.");
   }
}

function getBrandsFromArray(arr, group) {
	var i, retArr = new Array();
	for(i=0;i<arr.length;i++) {
		if(arr[i][0]==group) {
			retArr[retArr.length] = arr[i];
		}
	}
	return retArr;
}

function getBrandsFromArrayWithMainGroups(arr, group, main) {
	var i, retArr = new Array();
	for(i=0;i<arr.length;i++) {
		if(arr[i][0]==group && arr[i][4]==main) {
			retArr[retArr.length] = arr[i];
		}
	}
	return retArr;
}
function getGroupsFromArray(arr, brand) {
	var i, retArr = new Array();
	for(i=0;i<arr.length;i++) {
		if(arr[i][1]==brand) {
			retArr[retArr.length] = arr[i];
		}
	}
	return retArr;
}

function getGroupsFromArrayWithMainGroups(arr, brand, main) {
	var i, retArr = new Array();
	for(i=0;i<arr.length;i++) {
		if(arr[i][1]==brand && arr[i][4]==main) {
			retArr[retArr.length] = arr[i];
		}
	}
	return retArr;
}

function ReCreateProductSearchGroupBox(f,f2) {
	if(f.options[f.selectedIndex].value=="0" && f2.selectedIndex=="0")
		ResetProductSearchGroupBoxes(f,f2);
	if(f.options[f.selectedIndex].value!="" && f2.selectedIndex=="0") {
		var i,newitem,arr = getGroupsFromArray(groupbrandlist, f.options[f.selectedIndex].value);
		if(arr.length == 0) return;
		for(i=f2.options.length;i>-1;i--) {
			f2[i] = null;
		}
		newitem = new Option("", "0", false, false);
		f2.options[0] = newitem;
		for(i=0;i<arr.length;i++) {
			newitem = new Option(arr[i][2], arr[i][0], false, false);
			f2.options[i+1] = newitem;
		}
	}
}

function ResetProductSearchGroupBoxes(p,g) {
	var i,newitem;
	
	arr = brandlist;
	for(i=p.options.length;i>-1;i--) {
		p[i] = null;
	}
	newitem = new Option("", "0", false, false);
	p.options[0] = newitem;
	for(i=0;i<arr.length;i++) {
		newitem = new Option(arr[i][1], arr[i][0], false, false);
		p.options[i+1] = newitem;
	}
	
	arr = grouplist;
	for(i=g.options.length;i>-1;i--) {
		g[i] = null;
	}
	newitem = new Option("", "0", false, false);
	g.options[0] = newitem;
	for(i=0;i<arr.length;i++) {
		newitem = new Option(arr[i][1], arr[i][0], false, false);
		g.options[i+1] = newitem;
	}	
}

function ReCreateProductSearchBrandBox(f,f2) {
	if(f.options[f.selectedIndex].value=="0" && f2.selectedIndex=="0")
		ResetProductSearchGroupBoxes(f2,f);
	if(f.options[f.selectedIndex].value!="" && f2.selectedIndex=="0") {
		var i,newitem,arr = getBrandsFromArray(groupbrandlist, f.options[f.selectedIndex].value);
		if(arr.length == 0) return;
		for(i=f2.options.length;i>-1;i--) {
			f2[i] = null;
		}
		newitem = new Option("", "0", false, false);
		f2.options[0] = newitem;
		for(i=0;i<arr.length;i++) {
			newitem = new Option(arr[i][3], arr[i][1], false, false);
			f2.options[i+1] = newitem;
		}
	}
}

function ProductsSearch_OnMainChange(main,group,brand) {
	var mainVal;
	if(main.selectedIndex>-1)
		mainVal = main.options[main.selectedIndex].value;
	else
		mainVal = "";
	var groupVal;
	if(group.selectedIndex>-1)
		groupVal = group.options[group.selectedIndex].value;
	else
		groupVal = "";
	var brandVal;
	if(brand.selectedIndex>-1)
		brandVal = brand.options[brand.selectedIndex].value;
	else
		brandVal = "";
	if(mainVal!="0" && mainVal!="") {
		var i,j=0,newitem;
		for(i=group.options.length;i>-1;i--) {
			group.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		group.options[j] = newitem;
		for(i=0;i<maingrouplist.length;i++) {
			if(maingrouplist[i][0]==mainVal) {
				j++;
				newitem = new Option(maingrouplist[i][2], maingrouplist[i][1], false, false);
				group.options[j] = newitem;
			}
		}
	} else {
		var i,newitem;
		for(i=group.options.length;i>-1;i--) {
			group.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		group.options[0] = newitem;
		for(i=0;i<grouplist.length;i++) {
				newitem = new Option(grouplist[i][1], grouplist[i][0], false, false);
				group.options[i+1] = newitem;
		}
	}

	var i,newitem;
	for(i=brand.options.length;i>-1;i--) {
		brand.options[i] = null;
	}
	newitem = new Option("", "0", false, false);
	brand.options[0] = newitem;
	for(i=0;i<brandlist.length;i++) {
			newitem = new Option(brandlist[i][1], brandlist[i][0], false, false);
			brand.options[i+1] = newitem;
	}

}

function ProductsSearch_OnGroupChange(main,group,brand) {
	var mainVal;
	if(main.selectedIndex>-1)
		mainVal = main.options[main.selectedIndex].value;
	else
		mainVal = "";
	var groupVal;
	if(group.selectedIndex>-1)
		groupVal = group.options[group.selectedIndex].value;
	else
		groupVal = "";
	var brandVal;
	if(brand.selectedIndex>-1)
		brandVal = brand.options[brand.selectedIndex].value;
	else
		brandVal = "";
	
	if(brandVal!="" && brandVal!="0") return;
	
	if(groupVal!="0" && groupVal!="") {
		var i,newitem,arr;
		if(mainVal=="" || mainVal=="0") 
			arr = getBrandsFromArray(groupbrandlist, groupVal);
		else
			arr = getBrandsFromArrayWithMainGroups(groupbrandlistwithgroups, groupVal, mainVal);
		if(arr.length == 0) return;
		for(i=brand.options.length;i>-1;i--) {
			brand.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		brand.options[0] = newitem;
		for(i=0;i<arr.length;i++) {
			newitem = new Option(arr[i][3], arr[i][1], false, false);
			brand.options[i+1] = newitem;
		}
	} else if(brandVal=="" || brandVal=="0") {
		var i,newitem;
		for(i=group.options.length;i>-1;i--) {
			group.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		group.options[0] = newitem;
		group.options[0].selected=true;
		if(mainVal=="" || mainVal=="0") {
			for(i=0;i<grouplist.length;i++) {
					newitem = new Option(grouplist[i][1], grouplist[i][0], false, false);
					group.options[i+1] = newitem;
			}
		} else {
			var j=0;
			for(i=0;i<maingrouplist.length;i++) {
				if(maingrouplist[i][0]==mainVal) {
					j++;
					newitem = new Option(maingrouplist[i][2], maingrouplist[i][1], false, false);
					group.options[j] = newitem;
				}
			}
		}

		var i,newitem;
		for(i=brand.options.length;i>-1;i--) {
			brand.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		brand.options[0] = newitem;
		brand.options[0].selected = true;
		for(i=0;i<brandlist.length;i++) {
				newitem = new Option(brandlist[i][1], brandlist[i][0], false, false);
				brand.options[i+1] = newitem;
		}
	}
}


function ProductsSearch_OnBrandChange(main,group,brand) {
	var mainVal;
	if(main.selectedIndex>-1)
		mainVal = main.options[main.selectedIndex].value;
	else
		mainVal = "";
	var groupVal;
	if(group.selectedIndex>-1)
		groupVal = group.options[group.selectedIndex].value;
	else
		groupVal = "";
	var brandVal;
	if(brand.selectedIndex>-1)
		brandVal = brand.options[brand.selectedIndex].value;
	else
		brandVal = "";
	
	if(groupVal!="" && groupVal!="0") return;
	
	if(brandVal!="0" && brandVal!="") {
		var i,newitem,arr;
		if(mainVal=="" || mainVal=="0") 
			arr = getGroupsFromArray(groupbrandlist, brandVal);
		else
			arr = getGroupsFromArrayWithMainGroups(groupbrandlistwithgroups, brandVal, mainVal);
		if(arr.length == 0) return;
		for(i=group.options.length;i>-1;i--) {
			group.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		group.options[0] = newitem;
		for(i=0;i<arr.length;i++) {
			newitem = new Option(arr[i][2], arr[i][0], false, false);
			group.options[i+1] = newitem;
		}
	} else if(groupVal=="" || groupVal=="0") {
		var i,newitem;
		for(i=group.options.length;i>-1;i--) {
			group.options[i] = null;
		}
		newitem = new Option("", "0", false, false);
		group.options[0] = newitem;
		group.options[0].selected = true;
		if(mainVal=="" || mainVal=="0") {
			for(i=0;i<grouplist.length;i++) {
					newitem = new Option(grouplist[i][1], grouplist[i][0], false, false);
					group.options[i+1] = newitem;
			}
		} else {
			var j=0;
			for(i=0;i<maingrouplist.length;i++) {
				if(maingrouplist[i][0]==mainVal) {
					j++;
					newitem = new Option(maingrouplist[i][2], maingrouplist[i][1], false, false);
					group.options[j] = newitem;
				}
			}
		}
	}
}

function MainGroupOnChange(val, main, group, brand) {
	/*
	var i=0,empty=0;
	if(val=="0")empty=1;
	for(i=1;i<=3;i++) {
		tmp = "M" + i;
		if(tmp==val || empty==1) {
			document.getElementById(tmp).style.filter="alpha(opacity=100)";
		} else {
			document.getElementById(tmp).style.filter="alpha(opacity=20)";
		}
	}*/
	
	var f = document.forms['Search'].elements[main];
	for(i=0;i<f.options.length;i++) {
		if(f.options[i].value==val){
			f.selectedIndex = i;
			ProductsSearch_OnMainChange(document.forms['Search'].elements[main],document.forms['Search'].elements[group],document.forms['Search'].elements[brand]);
			break;
		}
	}
}

function ProductSearchHelp() {
	window.open('SearchHelp.html','stock','left=300,top=100,width=425,height=350,scrollbars=1,resizable=yes');
}

function CheckStock(pId) {
	window.open('CheckStock.asp?ProductID=' + urlEncode(pId),'stock','left=300,top=100,width=400,height=250,scrollbars=1,resizable=yes');
}

function CheckStockInWarehouse(pId, itemType, warehouse) {
	window.open('CheckStock.asp?ProductID=' + urlEncode(pId) + '&ItemType='+ itemType +'&Warehouse=' + warehouse,'stock','left=300,top=100,width=400,height=250,scrollbars=1,resizable=yes');
}

function CheckSetStock(pId) {
	window.open('CheckStock.asp?SetID=' + pId,'stock','left=300,top=100,width=400,height=250,scrollbars=1,resizable=yes');
}

function CheckBasketStock(Id) {
	window.open('CheckStock.asp?BasketID=' + Id,'stock','left=300,top=100,width=450,height=300,scrollbars=1,resizable=yes');
}

function CheckListStock(Id,items) {
	window.open('CheckStock.asp?ListID='+Id+'&'+items,'stock','left=300,top=100,width=450,height=300,scrollbars=1,resizable=yes');
}

////////////////////
function NumberFormat(num)
{
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-'; 
this.LEFT_PAREN = '('; 
this.RIGHT_PAREN = ')'; 
this.LEFT_OUTSIDE = 0; 
this.LEFT_INSIDE = 1;  
this.RIGHT_INSIDE = 2;  
this.RIGHT_OUTSIDE = 3;  
this.LEFT_DASH = 0; 
this.RIGHT_DASH = 1; 
this.PARENTHESIS = 2; 
this.num;
this.numOriginal;
this.hasSeparators = false;  
this.separatorValue;  
this.inputDecimalValue; 
this.decimalValue;  
this.negativeFormat; 
this.negativeRed; 
this.hasCurrency;  
this.currencyPosition;  
this.currencyValue;  
this.places;
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF; 
this.setSeparators = setSeparatorsNF; 
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF; 
this.setNegativeRed = setNegativeRedNF; 
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF; 
this.setCurrencyPosition = setCurrencyPositionNF; 
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.setInputDecimal(this.PERIOD); 
this.setNumber(num); 
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH); 
this.setNegativeRed(false); 
this.setCurrency(true);
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num)
{
this.numOriginal = num;
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.numOriginal);
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal)
{
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
}
else
{
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p)
{
this.places = p;
}
function toFormattedNF()
{
var pos;
var nNum = this.num; 
var nStr;            
var splitString = new Array(2);   
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum)); 
if (nStr.indexOf(this.PERIOD) == -1)
{
splitString[0] = nStr;
splitString[1] = '';
}
else
{
splitString = nStr.split(this.PERIOD, 2);
}
if (this.hasSeparators)
{
pos = splitString[0].length;
while (pos > 0)
{
pos -= 3;
if (pos <= 0) break;
splitString[0] = splitString[0].substring(0,pos)
+ this.separatorValue
+ splitString[0].substring(pos, splitString[0].length);
}
}
if (splitString[1].length > 0)
{
nStr = splitString[0] + this.decimalValue + splitString[1];
}
else
{
nStr = splitString[0];
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE)
{
if (nNum < 0)
{
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c0 = this.currencyValue;
}
else if (this.currencyPosition == this.LEFT_INSIDE)
{
if (nNum < 0)
{
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE)
{
if (nNum < 0)
{
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE)
{
if (nNum < 0)
{
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0)
{
nStr = '<font color="red">' + nStr + '</font>';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getRoundedNF(val)
{
var factor;
var i;
factor = 1;
for (i=0; i<this.places; i++)
{	factor *= 10; }
val *= factor;
val = Math.round(val);
val /= factor;
return (val);
}
function preserveZerosNF(val)
{
var i;
val = val + '';
if (this.places <= 0) return val; 
var decimalPos = val.indexOf('.');
if (decimalPos == -1)
{
val += '.';
for (i=0; i<this.places; i++)
{
val += '0';
}
}
else
{
var actualDecimals = (val.length - 1) - decimalPos;
var difference = this.places - actualDecimals;
for (i=0; i<difference; i++)
{
val += '0';
}
}
return val;
}
function justNumberNF(val)
{
val = (val==null) ? 0 : val;
var newVal = val + ""; 
var isPercentage = false;
var isFormattedNeg = false;
if (newVal.indexOf('%') != -1)
{
newVal = newVal.replace(/\%/g, '');
isPercentage = true;
}
if (newVal.indexOf(this.DASH) != -1
|| (newVal.indexOf(this.LEFT_PAREN) != -1 && newVal.indexOf(this.RIGHT_PAREN) != -1))
{
newVal = newVal.replace(/[\-\(\)]/g, '');
isFormattedNeg = true;
}
if (this.inputDecimalValue != this.PERIOD)
{
newVal = newVal.replace(/\./g, '');
}
var itrDecimal;
var tempVal = '';
var foundDecimal = false;
for (itrDecimal=0; itrDecimal<newVal.length; itrDecimal++)
{
if (newVal.charAt(itrDecimal) == this.inputDecimalValue)
{
if (foundDecimal)
{
}
else
{
tempVal = tempVal + this.PERIOD;
foundDecimal = true;
}
}
else
{
tempVal = tempVal + newVal.charAt(itrDecimal);
}
}
newVal = tempVal;
if (isFormattedNeg) newVal = '-' + newVal;
if (isNaN(newVal))
{
newVal = parseFloat(newVal.replace(/[^\d\.\-]/g, ''));
newVal = (isNaN(newVal) ? 0 : newVal); 
}
else if (!isFinite(newVal))
{
newVal = 0;
}
if (isPercentage)
{
newVal = newVal / 100;
}
return newVal;
}




