//browser detection
var ns = (navigator.appName == "Netscape");//Netscape browser
var ns6 = false;
var ua = navigator.userAgent;
if (document.getElementById) ns6 = true; //Netscape 6 or above

if (!ns || ns6) document.write('<LINK rel="stylesheet" href="a1_ie.css">');
else document.write('<LINK rel="stylesheet" href="a1_ns.css">');

//images arrays
var imgNamesOff = new Array("images/mnu_0_off.gif", "images/mnu_1_off.gif", "images/mnu_2_off.gif", "images/mnu_3_off.gif", "images/mnu_4_off.gif", "images/mnu_5_off.gif", "images/smnu_0_off.gif", "images/smnu_1_off.gif", "images/smnu_2_off.gif", "images/scr_up_off.gif", "images/scr_down_off.gif", "images/btn_left_off.gif", "images/btn_right_off.gif");
var imgNamesOn = new Array("images/mnu_0_on.gif", "images/mnu_1_on.gif", "images/mnu_2_on.gif", "images/mnu_3_on.gif", "images/mnu_4_on.gif", "images/mnu_5_on.gif", "images/smnu_0_on.gif", "images/smnu_1_on.gif", "images/smnu_2_on.gif", "images/scr_up_on.gif", "images/scr_down_on.gif", "images/btn_left_on.gif", "images/btn_right_on.gif");
var imgOff = new Array(imgNamesOff.length);
var imgOn = new Array(imgNamesOn.length);

//preload images
for (i=0; i<imgNamesOff.length; i++){
	imgOff[i] = new Image();
	imgOff[i].src = imgNamesOff[i];
	imgOn[i] = new Image();
	imgOn[i].src = imgNamesOn[i];
}

//mouseover
function swapIn(objName){
	var obj = eval("document." + objName);
	for(i=0; i<imgNamesOff.length; i++)
		if (obj.src == imgOff[i].src){
			obj.src = imgOn[i].src;
			break;
		}
}

//mouseout
function swapOut(objName){
	var obj = eval("document." + objName);
	for(i=0; i<imgNamesOn.length; i++)
		if (obj.src == imgOn[i].src){
			obj.src = imgOff[i].src;
			break;
		}
}

// START: fixing the page content on resize >>>
FixNSWindow();
function FixNSWindow() {
	if (ns6 || ns && (parseInt(navigator.appVersion) == 4)) {
		if (typeof document.NS == 'undefined') document.NS = new Object;
		if (typeof document.NS.NS_scaleFont == 'undefined') {
			document.NS.FixCssInNS = new Object;
			document.NS.FixCssInNS.initWindowWidth = window.innerWidth;
			document.NS.FixCssInNS.initWindowHeight = window.innerHeight;
		}
		window.onresize = FixCssInNS;
	}
}
function FixCssInNS() {
	if (document.NS.FixCssInNS.initWindowWidth != window.innerWidth || document.NS.FixCssInNS.initWindowHeight != window.innerHeight) document.location = document.location;
}
// <<< END: fixing the page content on resize


//Functions for scrolling Terms content
var timer;

function scrollDown(){
	if (!ns) { //Explorer
		if(document.all.scroller.style.pixelTop<0){
		   document.all.scroller.style.pixelTop+=5;
		   //position scroll bar
		   if (Math.round( (340/(document.all.scroller.offsetHeight-406))*Math.abs(document.all.scroller.style.pixelTop) ) > 340)
		   		document.all.scrLine.style.pixelTop = 341;
		   else 
		   		document.all.scrLine.style.pixelTop = Math.round( (340/(document.all.scroller.offsetHeight-406))*Math.abs(document.all.scroller.style.pixelTop) ); 
		}	
	   }
	   else { //Netscape
	    if (!ns6) {
			if(document.tata.document.scroller.top<0){
		   	   document.tata.document.scroller.top+=5;
			   //position scroll bar
			   if (Math.round( (340/(document.tata.document.scroller.clip.height-406))*Math.abs(document.tata.document.scroller.top) ) > 340)
			   		document.scrollBar.document.scrLine.top = 341;
			   else 
			   		document.scrollBar.document.scrLine.top = Math.round( (340/(document.tata.document.scroller.clip.height-406))*Math.abs(document.tata.document.scroller.top) );
			  }
		   }
		   else { //Netscape 6
		    obj = document.getElementById("scroller");
			if(parseInt(obj.style.top)<0){
			   obj.style.top = parseInt(obj.style.top)+10;
			   //position scroll bar
			   if (Math.round((340/(document.getElementById("scroller").offsetHeight-406)*Math.abs(parseInt(document.getElementById("scroller").style.top)))) > 340)
			   		document.getElementById("scrLine").style.top = "0px;"
				else
					document.getElementById("scrLine").style.top=Math.round((340/(document.getElementById("scroller").offsetHeight-406)*Math.abs(parseInt(document.getElementById("scroller").style.top)))) + "px";
			  }
		   }
	   }
	timer = setTimeout("scrollDown()", 20);
  }
  
  function scrollUp(){
  	if (!ns) { //Explorer
		if(document.all.scroller.style.pixelTop>-(document.all.scroller.offsetHeight-398))
		   document.all.scroller.style.pixelTop-=5;
		   //position scroll bar
		   if (Math.round( (340/(document.all.scroller.offsetHeight-406))*Math.abs(document.all.scroller.style.pixelTop) ) > 340)
		   		document.all.scrLine.style.pixelTop = 341;
		   else 
		   		document.all.scrLine.style.pixelTop = Math.round( (340/(document.all.scroller.offsetHeight-406))*Math.abs(document.all.scroller.style.pixelTop) );
	   }
	   else { //Netscape
	   	if (!ns6) {
			if(document.tata.document.scroller.top>-(document.tata.document.scroller.clip.height-398)){
			   document.tata.document.scroller.top-=5;
			   //position scroll bar
			   if (Math.round( (340/(document.tata.document.scroller.clip.height-406))*Math.abs(document.tata.document.scroller.top) ) > 340)
			   		document.scrollBar.document.scrLine.top = 341;
			   else
			   		document.scrollBar.document.scrLine.top = Math.round( (340/(document.tata.document.scroller.clip.height-406))*Math.abs(document.tata.document.scroller.top) );
			  } 
		   }
		   else { //Netscape 6
		    obj = document.getElementById("scroller");
			if(parseInt(obj.style.top)>-(obj.offsetHeight-398)){
			   obj.style.top = parseInt(obj.style.top)-10;
			   //position scroll bar
			   if (Math.round((340/(document.getElementById("scroller").offsetHeight-406)*Math.abs(parseInt(document.getElementById("scroller").style.top)))) > 340)
			   		document.getElementById("scrLine").style.top = "341px;"
				else
					document.getElementById("scrLine").style.top=Math.round((340/(document.getElementById("scroller").offsetHeight-406)*Math.abs(parseInt(document.getElementById("scroller").style.top)))) + "px";
			  }
		   }
	   }
	timer = setTimeout("scrollUp()", 20);
  }

  function doneScrolling(){
  	clearTimeout(timer);
  }

  function confirmThis(confirmMsg)
{
    var is_confirmed = confirm(confirmMsg);
    return is_confirmed;
}

function checkBForm(form)
{
	strsd = "Folowing fields are wrong:\n";

	if (form.bName.value == "")
	{
		strsd += "- Billing Name\n";
	}

	if (form.bAddress.value == "")
	{
		strsd += "- Billing Address\n";
	}

	if (form.bTel.value == "")
	{
		strsd += "- Billing Telephone\n";
	}

	 if (form.bCountry.value == "")
	 {
	 	strsd += "- Billing Country\n";
	}

	if (form.bEmail.value.search(/^[-\.\w\&_]*@[a-zA-Z0-9\&_][-\.\w\&_]*\.[a-zA-Z]{2,3}$/) < 0)
	{
		strsd += '- Billing Email!\n';
	}
		
	if (form.sName.value == "")
	{
		strsd += "- Shipping Name\n";
	}

	if (form.sAddress.value == "")
	{
		strsd += "- Shipping Address\n";
	}

	if (form.sTel.value == "")
	{
		strsd += "- Shipping Telephone\n";
	}

	 if (form.sCountry.value == "")
	 {
	 	strsd += "- Shipping Country\n";
	}

//	if (form.sEmail.value.search(/^[-\.\w\&_]*@[a-zA-Z0-9\&_][-\.\w\&_]*\.[a-zA-Z]{2,3}$/) < 0)
//	{
//		strsd += '- Shipping Email!\n';
//	}
	 if (!form.terms.checked)
	 {
	 	strsd += "- You must agree to Terms  Conditions\n";
	}

	 if (strsd == "Folowing fields are wrong:\n")
	 {
	 	form.submit();
		return true;
	}
	else
	{
		alert(strsd);
		return false;
	}
}

function copyBilling(form)
{
	form.sName.value=form.bName.value;
	form.sAddress.value=form.bAddress.value;
	form.sPostCode.value=form.bPostCode.value;
	form.sCountry.value=form.bCountry.value;
	form.sTel.value=form.bTel.value;
	form.sFax.value=form.bFax.value;
	form.sEmail.value=form.bEmail.value;
	return true;
}

var winp;
function winpopup(url) {
        LeftPosition = (screen.width) ? (screen.width-580)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
        winp = window.open(url,"","width=457,height=400,top="+TopPosition+",left="+LeftPosition+",location=no,directories=no,hotkeys=no,cophistory=no,resizable=yes,menubar=no,status=no,toolbar=no,scrollbars=yes,z-lock=yes");
        winp.focus();
}

