clearFlag = false;
function showInfo(ref) {
	if (document.getElementById(ref).style.display == "") {
		show = "none";
	}
	else {
		show = "";
	}
	document.getElementById(ref).style.display = show;
	return false;
}
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_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 MM_findObj(n, d) { //v4.01
	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 && d.getElementById)
		x=d.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];
		}
	}
actionPrepare = function(aObj, aFrmName, aConfirmText, aElementToCheck, aChecked) {
	if (aConfirmText != null && !confirm(aConfirmText))
		return false;
	if (typeof (event) == "object" && event.type == "click")
		event.returnValue = false;
	with (document.forms[aFrmName]) {
		var s = action;
		action = aObj.getAttribute("action");
		if (elements[aElementToCheck] && !elements[aElementToCheck].disabled)
			elements[aElementToCheck].checked = aChecked;
		submit();
		action = s;
		return false;
	}
}

function actionPrepareBase(aObj, aFrmName, useClickBank) {
	var tagInputs = document.forms[aFrmName].getElementsByTagName('input');
	for (var i = 0; i < tagInputs.length; i++) {
		if (tagInputs[i].type == 'radio' && tagInputs[i].name == 'chosenPrimaryProduct' && tagInputs[i].checked) {
			if (useClickBank) {
				tagInputs[i].onchange();
				document.forms[aFrmName].submit();
				return false;
			}
			else return actionPrepare(aObj, aFrmName, null, tagInputs[i].id, true);
		}
	}
	alert('Please select an option!');
	return false;
}

checkElement = function(aFrmName, aElementToCheck, aChecked) {
    with (document.forms[aFrmName]) {
        if (elements[aElementToCheck] && !elements[aElementToCheck].disabled)
            elements[aElementToCheck].checked = aChecked;
    }
}
submitPage = function(aObj, aFrmName) {
    if (typeof (event) == "object" && event.type == "click")
        event.returnValue = false;
    with (document.forms[aFrmName]) {
        var s = action;
        action = aObj.getAttribute("action");
        submit();
        action = s;
        return false;
    }
}

function parseResponseError(responseText){
	var errors = responseText.split(';');
		for(var i=0;i<errors.length;i++){
			var errorVars = errors[i].split('=');
			if (errorVars[1] == "invalid")
				writeErrorText(errorVars[0], errorVars[0] + ' is invalid or empty');
			else
				cleanErrorText(errorVars[0]); 
		}
}

function writeErrorText(controlId, text) {
	document.getElementById(controlId+ '_err').innerHTML = text;
}

function cleanErrorText(controlId) {
	document.getElementById(controlId + '_err').innerHTML = '';
}

function isValidValue(control, regexp, fieldName) {
	var reEmpty = new RegExp(/^$/);
	var reSpace = new RegExp(/^\s/);
	if (control.value.match(reEmpty) || control.value.match(reSpace)) {
		writeErrorText(control.id, fieldName + ': is required');
		return false;
	}
	if (!control.value.match(regexp)) {
		writeErrorText(control.id, 'Please enter a valid ' + fieldName);
		return false;
	}
	writeErrorText(control.id,'');
	return true;
}

function checkEnter(event) {
	var characterCode;
	if (event && event.which) {
		characterCode = event.which;
	}
	else {
		characterCode = event.keyCode;
	}

	if (characterCode == 13) {
		return false
	}
	else {
		return true
	}
}