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;
 }
 
 function MM_findObj(n, d) { //v4.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);
   if(!x && document.getElementById) x=document.getElementById(n); return x;
 }
 
 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_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];}}
 }
 function dopreload() {
 	MM_preloadImages('/images/header_cart_n.jpg','/images/submit_ro.gif');
 }
 function ldImg(param) {
 	MM_preloadImages('/images/header_cart_n.jpg','/images/submit_ro.gif');
 }

function popwin(param) {
	var remote = open ("", "TDwin", "left=0,top=0,toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=1,resizable=1,width=500,height=500");
	remote.focus();
	remote.location.href = (param);
}

	var autoSwitch = true;  // automatically switch images
	var fadeInt;
	var autoSwitchInt;
	var currentOp;
	var currentImage = 0;
	var loadStatus = 1;
	if (!autoSpeed) {	
		var autoSpeed = 4000;
	}
	if (!fadeSpeed) {
		var fadeSpeed = 2;
	}
	function setMainImage() {
		if (autoSwitch) {
			autoSwitchInt = setInterval("step(1)",autoSpeed);
		}
		var topImage = document.getElementById("topLayerImage");
		topImage.src = imageArray[0];
	}
	function step(direction) {
		clearInterval(autoSwitchInt);
		if (loadStatus == 1) {
			loadStatus = 0;
			currentImage = currentImage + direction;
			if (currentImage >= imageArray.length) {
				currentImage = 0;
			}
			else if (currentImage < 0) {
				currentImage = imageArray.length - 1;
			}
			loadImage();
		}
	}
	function loadImage() {
		clearInterval(fadeInt);
		var bottom = document.getElementById("bottomLayer");
		bottom.style.visibility="hidden"
		var newImage = document.getElementById("bottomLayerImage");
		newImage.onload = function() {
			var top = document.getElementById("topLayer");
			setOpacity(top, 100);
			currentOp = 100;
			fadeInt = setInterval("fadeTop()",10);
		}
		newImage.src = imageArray[currentImage];
	}
	function fadeTop() {
		var bottom = document.getElementById("bottomLayer");
		bottom.style.visibility="visible";
		currentOp = currentOp - fadeSpeed;
		if (currentOp >= 0) {
			var top = document.getElementById("topLayer");
			setOpacity(top, currentOp);
		}
		else {
			var newImage = document.getElementById("topLayerImage");
			newImage.onload = function() {
				document.getElementById("topLayer").style.opacity = 1;
				loadStatus = 1;
			}
			newImage.src = imageArray[currentImage];
			clearInterval(fadeInt);
			if (autoSwitch) {
				autoSwitchInt = setInterval("step(1)",autoSpeed);
			}
		}
	}
	function setOpacity(obj, opacity) {
  		opacity = (opacity == 100)?99.999:opacity;
	  	// IE/Win
  		obj.style.filter = "alpha(opacity:"+opacity+")";
  		// Safari<1.2, Konqueror
  		obj.style.KHTMLOpacity = opacity/100;
  		// Older Mozilla and Firefox
  		obj.style.MozOpacity = opacity/100;
  		// Safari 1.2, newer Firefox and Mozilla, CSS3
  		obj.style.opacity = opacity/100;
	}
function emailCheck (emailStr) {
	if (emailStr==null||emailStr=="") {
		alert("Please enter an e-mail address.");
		return false;
	}
	emailStr = emailStr.toLowerCase();
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	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) {
		alert("Your e-mail address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("Ths e-mail username contains invalid characters.");
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("Ths domain name contains invalid characters.");
			return false;
		}
	}
	if (user.match(userPat)==null) {
		alert("The e-mail username doesn't seem to be valid.");
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("Destination IP address is invalid!");
				return false;
			}
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("The domain name does not seem to be valid.");
			return false;
		}
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("Please check the last part of your e-mail address.\n\nThe address must end in a well known domain or two letter country.");
		return false;
	}
	if (len<2) {
		alert("This address is missing a hostname!");
		return false;
	}
	return true;
}

function ckEmail() {
	if (emailCheck(document.emailForm.email.value)) {
		return true;
	}
	else return false;
}

