/**************************************/
/*
Unite and Rule JavaScript
CopyrightŠUnite and Rule Ltd.
*/
/**************************************/

/**************************************/
/* Swap the active CSS */
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

/**************************************/
/* Counter */
var countContainer=0;
var currentSeconds=0;
var countPause=20;

function ActivateCount(strContainerID, initialValue) {
    countContainer = document.getElementById(strContainerID);
    SetCountText(initialValue);
    window.setTimeout("CountTick()", countPause);
}
 
function CountTick() {
    if (currentSeconds >= 123) {
        return; //skip count
    }
    SetCountText(currentSeconds+1);
    window.setTimeout("CountTick()", countPause);
}
 
function SetCountText(seconds) {
    currentSeconds = seconds;
    var strText = AddZero(seconds);
    countContainer.innerHTML = strText;
}
 
function AddZero(num) {
    num = ((num >= 0)&&(num < 10))?"0"+num:num+"";
    num = ((num >= 0)&&(num < 100))?"0"+num:num+"";
	return num;
} 

/*window.onload=WindowLoad;
function WindowLoad(event) {
    ActivateCount("CountPanel", 0);
}*/

/**************************************/
/* Contact Validation */
function validateContact(oForm) {
	var bValid = true;
/*
	//check for security code
	if (oForm.code.value.length < 4) {
		alert('Please enter the security code');
		return false;
	}
*/

	//check email
	if (validateEmail(oForm.email) == false) {
		alert('Please enter a valid email address');
		return false;
	}

	return true;
}

/**************************************/
/* validate the email field */
function validateEmail(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) { return false; }
		else { return true; }
	}
}


