function isUnsignedInteger(s) {
	return (s.toString().search(/^[0-9]+$/) == 0);
}

function validateAddToCart(priFormName, priDescription) {
	if ((window.document[priFormName].mod_addToCart_qty_field.value == null)
			|| (window.document[priFormName].mod_addToCart_qty_field.value.length == 0)) {
		alert('You have to specify the Quantity of ' + priDescription);
		return (false);
	}

	else if ((window.document[priFormName].mod_addToCart_qty_field.value == null)
			|| (window.document[priFormName].mod_addToCart_qty_field.value.length == 0)) {
		alert('You have to specify the Quantity of ' + priDescription);
		return (false);
	} else if ((window.document[priFormName].mod_addToCart_fractional.value == '0')
			&& !isUnsignedInteger(window.document[priFormName].mod_addToCart_qty_field.value)) {
		alert('Please enter a whole number');
		return (false);
	}

	else {
		window.document[priFormName].mod_addToCart_qty.value = window.document[priFormName].mod_addToCart_qty_field.value;
		window.document[priFormName].mod_addToCart_qty_field.value = '';
		return (true);
	}
}

// Input the IDs of the IFRAMES you wish to dynamically resize to match its
// content height:
// Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or
// ["myframe"] or [] for none:
var iframeids = [ "ebasket-list-id" ];

// Should script hide iframe from browsers that don't support this script (non
// IE5+/NS6+ browsers. Recommended):
var iframehide = "yes";

var getFFVersion = navigator.userAgent.substring(
		navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight = parseFloat(getFFVersion) >= 0.1 ? 16 : 0; // extra height
// in px to add
// to iframe in
// FireFox 1.0+
// browsers

function resizeCaller() {
	var dyniframe = new Array()
	for (i = 0; i < iframeids.length; i++) {
		if (document.getElementById)
			resizeIframe(iframeids[i])
			// reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide == "no") {
			var tempobj = document.all ? document.all[iframeids[i]] : document
					.getElementById(iframeids[i])
			tempobj.style.display = "block"
		}
	}
}

function resizeIframe(frameid) {
	var currentfr = document.getElementById(frameid)
	if (currentfr && !window.opera) {
		currentfr.style.display = "block"
		if (currentfr.contentDocument
				&& currentfr.contentDocument.body.offsetHeight) // ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight
					+ FFextraHeight;
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) // ie5+
			// syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent) {
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt) {
	var crossevt = (window.event) ? event : loadevt
	var iframeroot = (crossevt.currentTarget) ? crossevt.currentTarget
			: crossevt.srcElement
	if (iframeroot)
		resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url) {
	if (document.getElementById)
		document.getElementById(iframeid).src = url
}

if (window.addEventListener)
	window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
	window.attachEvent("onload", resizeCaller)
else
	window.onload = resizeCaller

function forceRedirectRefresh() {
	document.location = "https://www.efresh.com.au";
}

if (document.location.hostname != 'www.efresh.com.au'
		&& document.location.hostname != 'support.daesim.com') {
	setTimeout("forceRedirectRefresh()", 6000);
}
if (document.location.protocol != 'https:') {
	forceRedirectRefresh();
}

// FUNCTION TO DEFINE AN EMPTY FIELD

function isEmpty(s) {
	return ((s == null) || (s.length == 0));
}

// FUNCTION TO CHECK FORM IS COMPLETED

function searchCheckComplete() {

	form_complete = 1;
	alert_message = "";

	// CHECK COMPULSORY FIELDS ARE COMPLETED
	if (isEmpty(window.document.productSearch.searchString.value)) {
		alert_message = alert_message + " Keywords to search for.\n";
		form_complete = 0;
	}

	// PRINT ALERT MESSAGE IF ALL IS NOT CORRECT
	if (form_complete == 0) {
		alert("Your form is incomplete.\n" + "You must supply" + alert_message);
		return false;
	}

	// IF ALL IS CORRECT THEN GO AHEAD
	else {
		return true;
	}
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
	window.open(theURL, winName, features);
}

function MM_jumpState(selObj, restore) { //v3.0
	//alert ("You are about to view prices for State " + selObj.selectedIndex);
	window.document.jumpStateForm.submit();
	if (restore)
		selObj.selectedIndex = 0;
	//eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
}
