function get_model(cat)
	{var s=document.createElement('script');s.src='/includes/models.asp?cat='+cat;s.type='text/javascript';document.getElementsByTagName('head')[0].appendChild(s)}
	
function get_prod(id,cat)
	{location.href='/product/'+id+'/'+cat.replace(/ /g,'_').replace(/\//g,'_')+'.html'}

function cursor_sniff(obj)
	{if (document.all)obj.cursor="hand";else obj.cursor="pointer"}

function event_handler()
	{
	var a = document.getElementsByTagName("INPUT")
	for (var b=0;b<a.length;b++)
		{
		if (a[b].className=="red btn" || a[b].className=="btn" || a[b].className=="red2 btn")
			{
			a[b].onmouseover = function(){cursor_sniff(this.style)}
			a[b].onmouseout  = function(){}
			if (a[b].className!="red2 btn")
				a[b].onclick	 = function(){if(this.id){num=this.id.replace(/b/,'');if(parseInt(num)){location.href='/shopcart.asp?mode=add&stock_id='+num}}}
			}
		}
		
	var e=document.getElementById("ddown")
	if (e)
		{
		var l=0
		document.body.onclick=function(){if(l==1){l=0;close_select()}}
		var s=document.getElementById("selbtn");
		var c=document.getElementById("catbox");
		s.onmouseover=function(){s.src="/images/select-over.gif"}
		s.onmouseout=function(){s.src="/images/select.gif";l=1}
		s.onclick=function(){e.style.left=c.offsetLeft+"px";e.style.top=(c.offsetTop+22)+"px";e.style.display="block"}
			
		var a=e.getElementsByTagName("LI");
		for(var b=0;b<a.length;b++)
			{
			a[b].onmouseover=function(){this.style.background="#316AC5";this.style.color="#fff"}
			a[b].onmouseout=function(){this.style.background="#fff";this.style.color="#000"}
			a[b].onclick=function(){if(document.all){document.stock.category.value=this.innerText}else{document.stock.category.value=this.textContent};close_select()}
			}	
		}
	
	var f=document.getElementById("ddown2")
	if (f)
		{
		var l=0
		document.body.onclick=function(){if(l==1){l=0;close_select()}}
		var t=document.getElementById("selbtn2");
		var y=document.getElementById("manbox");
		t.onmouseover=function(){t.src="/images/select-over.gif"}
		t.onmouseout=function(){t.src="/images/select.gif";l=1}
		t.onclick=function(){f.style.left=y.offsetLeft+"px";f.style.top=(y.offsetTop+22)+"px";f.style.display="block"}
			
		var a=f.getElementsByTagName("LI");
		for(var b=0;b<a.length;b++)
			{
			a[b].onmouseover=function(){this.style.background="#316AC5";this.style.color="#fff"}
			a[b].onmouseout=function(){this.style.background="#fff";this.style.color="#000"}
			a[b].onclick=function(){if(document.all){document.stock.manufacturer.value=this.innerText}else{document.stock.manufacturer.value=this.textContent};close_select()}
			}	
		}
	}
	
function close_select()
	{document.getElementById("ddown").style.display="none";document.getElementById("ddown2").style.display="none"}
	
function show_stock()
	{fm=document.stock;location.href='?stock_id='+fm.stock_id.options[fm.stock_id.selectedIndex].value}
	
function checkout(a)
	{
	var fm=document.details;mt=false;
	if (a==0)
		{fm.action='/geniusmouse/paypal.asp';fm.submit()}
	else
		{
		fm.action='confirmation.asp'
		checker(fm.fname,'You must enter your first name')
		checker(fm.surname,'You must enter your Surname')
		checker(fm.billingaddress1,'You must enter the first line of your address')
		checker(fm.billingaddress2,'You must enter the second line of your address')
		checker(fm.billpcode,'You must enter your Post Code')
		email(fm.email)
		checker(fm.tel,'You must enter a telephone number')
		mod_checker(fm)	
		if (mt==false)fm.submit()
		}
	}
		
function payment_select(a)
	{
	var fm=document.getElementById("checkoutbtn")
	if(a==0)fm.value="Checkout"
	else fm.value="Place Order"
	toggle_fieldset(a);fm.onclick = function(){checkout(a)}
	}
	
function toggle_fieldset(d)
	{
	var a=document.getElementsByTagName("FIELDSET");
		for(var b=0;b<a.length;b++)
			{
			if(a[b].className=="basket" && d==1)a[b].style.display="block"
			else if(a[b].className=="basket") a[b].style.display="none"
			}		
	}
	
function login()
	{
	var fm=document.admin;mt=false
	checker(fm.userid,'You must enter your user name')
	checker(fm.password,'You must enter your password')
	if(mt==false)fm.submit()
	}
	
function stock_update()
	{
	var fm=document.stock;mt=false
	if(mt==false)fm.submit()
	}
	
function checker(obj,msg)
	{if(obj.value=="" && mt==false){alert(msg);mt=true;obj.focus();}}

function email(obj)
	{
	var emailStr=obj.value;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 +")*$");var matchArray=emailStr.match(emailPat)
	if ((matchArray==null) && mt==false){alert("Email address seems incorrect (check @ and .'s)");mt=true;obj.focus()}
	if (mt==false){var user=matchArray [1];var domain=matchArray [2];if (user.match(userPat)==null){alert("The username doesn't seem to be valid.");mt=true;obj.focus()}}
	if (mt==false){var IPArray=domain.match(ipDomainPat);if (IPArray!=null){for (var j=1;j<=4;j++){if (IPArray[j]>255){alert("Destination IP address is invalid!");mt=true;obj.focus()}}}}
	if (mt==false){var domainArray=domain.match(domainPat);if (domainArray==null){alert("The domain name doesn't seem to be valid.");mt=true;obj.focus()}}
	if (mt==false){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>4){alert("The address must end in a two,three or four letter domain");mt=true;obj.focus()}}
	if ((len<2) && mt==false){alert("This address is missing a hostname!");mt=true;obj.focus()};
	}
	
function mod_checker(fm)
	{
	failed=false;
	Str=fm.creditcard.value;
	newStr='';card_index='';card='';
	exp_month = fm.expirymonth.options[fm.expirymonth.selectedIndex].text;
	exp_year = fm.expiryyear.options[fm.expiryyear.selectedIndex].text;
	val_month = fm.startmonth.options[fm.startmonth.selectedIndex].text;
	val_year = fm.startyear.options[fm.startyear.selectedIndex].text;
	card = fm.card.options[fm.card.selectedIndex].text;
	d=new Date();cur_month = d.getMonth() + 1;cur_year = d.getFullYear()
	if (card=='Select' && mt==false){alert("You must select a Card Type");mt = true;fm.card.focus()}
	//Remove Dashes and Spaces & Numeric Check
	for (var k = 0; k < parseInt(Str.length); k++){var a = Str.charAt(k);if ((a != " ") && (a != "-")){newStr += Str.charAt(k);}};for (var k = 0; k < parseInt(newStr.length); k++){var a = newStr.charAt(k);if (((a < "0") || (a > "9")) && mt==false){alert("Numbers only Please");mt=true;fm.creditcard.focus();}};if((Str == ""  || newStr.length < "10") && mt ==false){alert("Incorrect Number of Digits");mt=true;fm.creditcard.focus()}
	//Modulus 10 Checker
	if(newStr.length % 2 == "0" && mt==false)even(fm)
	if(newStr.length % 2 != "0" && mt==false)odd(fm)
	if (((val_year==cur_year && val_month>cur_month)||(val_year>cur_year)) && mt==false){alert("Your start date is incorrect");mt=true;fm.startmonth.focus()}
	if ((exp_year < cur_year)||(exp_year == cur_year && exp_month < cur_month) && mt==false){alert("Your Card has expired");mt=true;fm.expirymonth.focus();}
	checker(fm.cv2,'You must enter your card signature code on the back of your card')
	//End Modulus 10 Checker
	}
	
function even(fm)
	{tot=0;z=parseInt(newStr.charAt(0));bigger_than_5();x=1;y=parseInt(newStr.length);while(x<y){z=parseInt(newStr.charAt(x));if(x % 2 != 0) tot=tot+z;else bigger_than_5();x++};invalid(fm)}
	
function odd(fm)
	{tot=0;z=parseInt(newStr.charAt(0));tot=tot + z;x=1;y=parseInt(newStr.length);while (x<y){z=parseInt(newStr.charAt(x));if(x%2!= 0)bigger_than_5();else tot=tot+z;x++};invalid(fm)}
	
function bigger_than_5()
	{if(z*2>=10){num=z*2;n=num.toString();n1=parseInt(n.charAt(0));n2=parseInt(n.charAt(1));tot=tot + n1 + n2;}else tot=tot + (z*2)}
	
function invalid(fm)
	{if(tot%10!=0){alert("Invalid Card Number");mt=true;fm.creditcard.focus()}}

function ch_i()
	{fm=document.details;cc=fm.card.options[fm.card.selectedIndex].text;if(document.images)document.ccard.src='/images/' + cc + '.gif'}
	
function get_days(fm)
	{
	a=new Date(fm.ydate.options[fm.ydate.selectedIndex].text,fm.mdate.options[fm.mdate.selectedIndex].value,0);
	b=a.getDate();fm.ddate.options.length=b;
	for(x=1;x<=b;x++){fm.ddate.options[x-1].text=x}
	}

function get_days2(fm)
	{
	a=new Date(fm.ydate2.options[fm.ydate2.selectedIndex].text,fm.mdate2.options[fm.mdate2.selectedIndex].value,0);
	b=a.getDate();fm.ddate2.options.length=b;
	for(x=1;x<=b;x++){fm.ddate2.options[x-1].text=x}
	}
	

//microsoft adcenter
microsoft_adcenterconversion_domainid 	= 19173;  
microsoft_adcenterconversion_cp 		= 5050; 
		
window.onload=event_handler