/*
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/

function chkF(field,alerttxt,reject){
	with (field) {
		if (value==null||value==""||value==reject){
			alert(alerttxt);
			return false
		} else { return true }
	}
}

function chkE(field,alerttxt){
	with (field){
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
			  {alert(alerttxt);return false}
		else {return true}
	}
}

function contactForm(thisForm) {
	with (thisForm){
		if (chkF(lhlName, "Please enter your name.", "asd")==false){
			lhlName.focus();
			return false
		}
		
		if (chkE(lhlEmail,"Sorry that isn't a valid Email Address")==false){
			lhlEmail.focus();
			return false
		}
		
		if (chkF(lhlContact,"Please enter your Contact Number", "asd")==false){
			lhlContact.focus();
			return false
		}
		
		if (chkF(lhlMessage, "Please enter a Message", "asd")==false){
			lhlMessage.focus();
			return false
		}
	}
}

function changeimg(img) {
	if(img.src.match("-norm")) {
		img.src = img.src.split("-norm").join("-fade");
	} else {
		img.src = img.src.split("-fade").join("-norm");
	}
}

function changeprodimg(img) {
	if(img.src.match("-norm")) {
		img.src = img.src.split("-norm").join("-fade");
	} else {
		img.src = img.src.split("-fade").join("-norm");
	}
}

function flash(movie, width, height, alt, id) {
	document.write('<object style="border:0;padding:0;margin:0;" id="'+id+'" type="application/x-shockwave-flash" data="'+movie+'" width="'+width+'" height="'+height+'" title="'+alt+'">\n');
	document.write('<param name="movie" value="'+movie+'" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('</object>\n');
}

function newwin(lnk) {
	window.open(lnk.href, 'newwindow','toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');
	return false;
}

function areyousure(txt) {
	var q = confirm(txt);
	if (!q){ return false; }
}


/* -------- PROTOTYPE CREATIVE SLIDING BOX -------- */
// Declare the variables including milliseconds & timer
var x = 0; var end = 0; var diff = 525; var millisec = 0; var timer;

// Function to increase variable millisec by 10 every 10 milliseconds & track for movement
function time(){ millisec+=10; timer = setTimeout("time()",1); }

// Function to reset the time
function reset() { clearTimeout(timer); millisec = 0; }

// Function to decide which way to move the element (right or left)
function moveme(a, tot) { if(a=='right') { if((end + diff) <= 0) { end = end + diff; time(); moveright(); } } else if(a=='left') { rev = diff*tot; if((end - diff) > rev - (rev*2)) { end = end - diff; time(); moveleft(); } } }

// Move the box to the right
function moveright() { if (x < end) { x += millisec / 3.3; document.getElementById('slider').style.left = x + 'px'; setTimeout('moveright()',1); } else { document.getElementById('slider').style.left = end + 'px'; x = end; reset(); } }

// Move the box to the left
function moveleft() { if (x > end) { x -= millisec / 3.3; document.getElementById('slider').style.left = x + 'px'; setTimeout('moveleft()',1); } else { document.getElementById('slider').style.left = end + 'px'; x = end; reset(); } }

// Move the box to a specific page
function moveto(page, tot) { here = (page -1) * diff; here = here - (here*2); if(here > x) { end = here-diff; moveme('right', tot); } else if(here < x) { end = here+diff; moveme('left', tot); } }

// Set the remove function to remove 
function remove(){ document.getElementById('text').style.overflow = "hidden"; }
