//############# MY FORM FUNCTION #################################################
	function myform(frmName) {
		
		if(!document.getElementById(frmName)) return ;
		var id=document.getElementById(frmName);
		id.onsubmit=function(){
			return callMyform(this);
		}
	}
	function confirmRedemption(){
		
		showPopUp('notice');
		
		var obj = document.getElementById('idname');
		
		var nameprovided = obj.value;
		
		var tmp = nameprovided.split(" ");
		
		var namecount = tmp.length
		
		if (namecount > 1){
		
		document.getElementById('notice').innerHTML = '<div style="margin-top:10px;font-size:1.2em" align="center"><h2>PLEASE CONFIRM YOUR SELECTIONS</h2>Please verify you entered your full name correctly<br />and verify the bar you selected. <p />Once you press GIVE ME MY BEER your selection will be final.<p />Must use full amount at bar No cash back, no balance<p /><img src="./images/cancel.gif" style="cursor:pointer" onclick="showPopUp(\'notice\')"/>&nbsp;<img src="./images/givememybeer.gif" style="cursor:pointer" onclick="document.getElementById(\'redemptionForm\').submit()" /></div>';
		}else{
		document.getElementById('notice').innerHTML = '<div style="margin-top:10px;font-size:1.2em" align="center"><h2>PLEASE CHECK YOUR NAME ENTRY</h2>Please provide your first and last name as shown on your personal ID.<p /><img src="./images/cancel.gif" style="cursor:pointer" onclick="showPopUp(\'notice\')"/></div>';
		}
	}
	function showLocDetails(text){
		
		showPopUp('notice');
		
		document.getElementById('notice').innerHTML = '<div style="margin-top:10px;font-size:1.2em" align="center">'+text+'<p /><a href="javascript:showPopUp(\'notice\')">CLOSE</a></div>';
		
	}
	function showPopUp(div,text,size){
		var obj = document.getElementById(div);
		if (obj.style.display=="block"){
			obj.style.display="none"	
		}else{
			obj.style.display="block"	
			obj.innerHTML='<img src="templates/images/loading.gif" style="border:2px solid black;position:relative;left:50%;top:50%;margin-left:-17px;margin-top:-17px;"/>';
			
			if (text != undefined){
				obj.innerHTML = "<div style=\"padding:30px;\" align=\"center\">"+text+"<p /><a href='#' onclick='showPopUp(\"notice\")'>CLOSE</a></div>";	
			}
		}
	}

	function callMyform(formfields) {
		var returnval=true;
		for(var i=0; i<formfields.elements.length; i++) {
			
			//var re = new RegExp("[^a-zA-Z0-9\~\(\)/_. ]","i");
			var element=formfields.elements[i];
			if(element.className=="emailrequired") {
				if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(element.value))) {
					showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Enter the Valid "+element.title);
					element.focus();
					returnval=false;
					break;
				}
			} else if(element.className=="mandatory" ) {
			if(element.value.length > 1 && element.type =="text") {
					if(Trim(element.value)){
						showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please remove the White spaces from " + element.title);
						element.focus();
						returnval=false;
					    break;
					}
					/*if(re.test(element.value)){
						showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Enter the Valid " + element.title);
						element.focus();
						returnval=false;
					    break;
					}*/
				}
				if(element.value.length < 1) {
					showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Enter the " + element.title);
					element.focus();
					returnval=false;
				    break;
			  }
		} else if(element.className=="selectcombo") {
				if(element.value=="-1") {
					showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Select the " + element.title);
					element.focus();
					returnval=false;
					break;
				}
			} else if(element.className=="notanumber") {
				if(element.value.length < 1 || isNaN(element.value)) {
					showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Enter the " + element.title + " in Digits ");
					element.focus();
					returnval=false;
					break;
				}
			} else if(element.className=="uploadimagescript") {
				// START IMAGE CHECK
					extArray = new Array(".jpg", ".gif");
					allowSubmit = false;
					file=element.value;
					if (!file) { return; }
					while (file.indexOf("\\") != -1)
						file = file.slice(file.indexOf("\\") + 1);
						ext = file.slice(file.indexOf(".")).toLowerCase();
						for (var i = 0; i < extArray.length; i++) {
							if (extArray[i] == ext) { allowSubmit = true; break; }
						}
						if (allowSubmit) {
							return true;
						} else {
							showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Upload the Files with these Extensions Only:\n  "
							+ (extArray.join("  ")) + "\nPlease Select a New File to Upload and Submit Again.");
							element.focus();
							return false;
						}
				// END IMAGE CHECK
			} else if(element.className=="uploadfilescript") {
				// START IMAGE CHECK
					extArray = new Array(".jpg", ".gif", ".doc", ".pdf");
					allowSubmit = false;
					file=element.value;
					if (!file) { return; }
					while (file.indexOf("\\") != -1)
						file = file.slice(file.indexOf("\\") + 1);
						ext = file.slice(file.indexOf(".")).toLowerCase();
						for (var i = 0; i < extArray.length; i++) {
							if (extArray[i] == ext) { allowSubmit = true; break; }
						}
						if (allowSubmit) {
							return true;
						} else {
							showPopUp("notice","<b>PLEASE REVIEW</b><p /> Please Upload the Files with these Extensions Only:\n  "
							+ (extArray.join("  ")) + "\nPlease Select a New File to Upload and Submit Again.");
							element.focus();
							return false;
						}
				// END IMAGE CHECK
			}
		}
		return returnval;
	}
//############# MY FORM FUNCTION ENDS #################################################

//############# FUNCTIONS #############################################################
//############# FUNCTIONS END ########################################################

//############# BOOKMARK #############################################################
	function bookmarksite(title, url) {
		if (document.all)
			window.external.AddFavorite(url, title);
		else if (window.sidebar)
			window.sidebar.addPanel(title, url, "")
	}
//############# BOOKMARK END #########################################################
//############# Remove White Spaces #########################################################

function Trim(str) {
if(str.charAt(0) == (" ") || str.charAt(str.length-1) == " ") {
return true;
}
return false;
}
//############# End Remove White Spaces #########################################################
function printFlyer(save){

	var val=document.getElementById("flyercopy").value;
	
	window.open('merchant_flyer.php?print=1&pcopy='+val,'printFlyer');

}

