function fFocus(tthis) {
	tthis.className = "cssFocus";
}

function fBlur(tthis) {
	tthis.className = "";
}

function fMouseOut(tthis) {
	if(tthis.className != "cssFocus") {
		tthis.className = "";
	}
}

function fMouseOver(tthis) {
	if(tthis.className != "cssFocus") {
		tthis.className = "cssOver";
	}
}

function fVerifyEmail(strEmail) {
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if (re.test(strEmail)) {
		return true;
	} else {
		return false;
	}
}

function fVerifyInput(strID, strText) {
	var oInput = document.getElementById(strID);
	if(oInput.value == "") {
		oInput.style.background = "#ffcccc";
		return strText;
	} else {
		oInput.style.background = "";
		return "";
	}
}

function fVerifyInputLength(strID, intLength, strText) {
	var oInput = document.getElementById(strID);
	if(oInput.value.length < intLength) {
		oInput.style.background = "#ffcccc";
		return strText;
	} else {
		oInput.style.background = "";
		return "";
	}
}

function fVerifyRadio(strID, strText) {
	var oRadio = document.getElementsByName(strID);
	for(i=0; i<oRadio.length; i++) {
		if(oRadio[i].checked) {
			return "";
		}
	}
	return strText;
}

function fVerifyCheck(strID, strText) {
	var oCheck = document.getElementById(strID);
	if(oCheck.checked) {
		return "";
	}
	
	return strText;
}

function fVerifySelect(strID, strText) {
	var oElement = document.getElementById(strID);
	if(oElement.selectedIndex == 0) {
		oElement.style.background = "#ffcccc";
		oElement.focus();
		return strText;
	} else {
		oElement.style.background = "#ffffff";
	}
	return "";
}

function fInputValue(strID) {
	return document.getElementById(strID).value;
}

function fShow(strDiv) {
	document.getElementById(strDiv).style.visibility = "visible";
	document.getElementById(strDiv).style.display = "block";
}

function fHide(strDiv) {
	document.getElementById(strDiv).style.visibility = "hidden";
	document.getElementById(strDiv).style.display = "none";
}


function fToggle(strID) {
	if(document.getElementById(strID).style.visibility == "hidden") {
		fShow(strID);
	} else {
		fHide(strID);
	}
}

function fAJAXRequest(strTarget, strURL) {
	if(window.XMLHttpRequest) {
		oRequest = new XMLHttpRequest();
		oTarget = strTarget;
		oRequest.onreadystatechange = fAJAXChangeWhenReady;
		oRequest.open("GET", strURL, true);
		oRequest.send(null);
	} else if(window.ActiveXObject) {
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
		if(oRequest) {
			oTarget = strTarget;
			oRequest.onreadystatechange = fAJAXChangeWhenReady;
			oRequest.open("GET", strURL, true);
			oRequest.send();
		}
	}
}

function fAJAXChangeWhenReady() {
    if(oRequest.readyState == 4) {
    	if(document.getElementById(oTarget)) {
    		document.getElementById(oTarget).innerHTML = oRequest.responseText;
    	}
    }
}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}

function fVerifyOrderingInformation() {
	var strError = "";
	
	strError += fVerifyInput("realname","Please enter your name.\n");
	strError += fVerifyInput("Phone","Please enter your phone number.\n");
	strError += fVerifyInput("email","Please enter your email address.\n");
	
	if(strError != "") {
		alert(strError);
		return false;
	}
	return true;
}