	function getCouponsEmail(partnerSiteId){	
	//document.couponForm.action="SmartSourceFrontController?command=UserSubscriptionFormCouponCommand&partnerSiteId="+partnerSiteId;
	// SIT # 1195 --- Starts
	document.emailSubscriptionForm.command.value="UserSubscriptionFormCouponCommand";
	document.emailSubscriptionForm._a.value=partnerSiteId;
	document.emailSubscriptionForm.toPage.value="getCouponsEmail";
	document.emailSubscriptionForm.submit();	
	// SIT # 1195 --- Ends
	}
	function getRegistration(partnerSiteId,fromPage){
	//document.couponForm.action="SmartSourceFrontController?command=UserRegistrationFormCouponCommand&partnerSiteId="+partnerSiteId;
	document.couponForm.command.value="UserRegistrationFormCouponCommand";
	document.couponForm._a.value=partnerSiteId;
	document.couponForm.toPage.value="registration";
	document.couponForm.fromPage.value=fromPage;
	document.couponForm.submit();
	}
	function getLogin(partnerSiteId,fromPage){
	//document.couponForm.action="SmartSourceFrontController?command=UserRegistrationCouponCommand&partnerSiteId="+partnerSiteId;
	document.couponForm.command.value="UserRegistrationCouponCommand";
	document.couponForm._a.value=partnerSiteId;
	document.couponForm.toPage.value="loginPage";
	document.couponForm.fromPage.value=fromPage;
	document.couponForm.submit();			
	}
	function getforgotPass(partnerSiteId){
	//document.loginForm.action="SmartSourceFrontController?command=UserRegistrationCouponCommand&partnerSiteId="+partnerSiteId;
	document.loginForm.command.value="UserRegistrationCouponCommand";
	document.loginForm._a.value=partnerSiteId;
	document.loginForm.toPage.value="forgotPassword";
	document.loginForm.submit();	
	}
	function getLoginRegistration(partnerSiteId,fromPage){
	//document.loginForm.action="SmartSourceFrontController?command=UserRegistrationFormCouponCommand&partnerSiteId="+partnerSiteId;
	document.loginForm.command.value="UserRegistrationFormCouponCommand";
	document.loginForm._a.value=partnerSiteId;
	document.loginForm.toPage.value="registration";
	document.loginForm.fromPage.value=fromPage;
	document.loginForm.submit();	
	}
	function checkKey(evt) {
	var keycode = (window.event)?event.keyCode:evt.which;
	if (keycode == 13)
	{	//alert("Enter");
	 if(validateZip()){
	    search();
	  }
   }
 }	
	function search(){
		document.couponForm.command.value='CouponDisplayCommand';
		document.couponForm.pageNo.value="1";
		document.couponForm.promptClicked.value='Y';
		document.couponForm.submit();
	}
	function selectOffer(offerId,offerValue,categoryId)
	{      
			var checkBox = eval("document.couponForm.chkoffer" + offerId);
			if(checkBox){
		  		if(checkBox.checked != true)
				{	
					checkBox.checked = true;
					updateNoSelectedOffers(offerValue,offerId,categoryId);
				}	  	
			}
  	}
  	function chkboxClick(offerId,offerValue,categoryId,col)
  	{
  		
  		var checkBox = eval("document.couponForm.chkoffer" + offerId);
		
  		
		if(checkBox.checked == true)
		{
			updateNoSelectedOffers(offerValue,offerId,categoryId);
		}
		else
		{
			removeNoSelectedOffers(offerValue,offerId,categoryId,col,0);				
		}
	}
	function updateNoSelectedOffers(value,id,categoryId)
  	{
  		var c = Number(document.getElementById("savSelectedOffers").innerHTML);
  		var val = Number(document.getElementById("savSelectedOfferValue").innerHTML);
  		
  		//val.toPrecision(3);
  		if(val==-1){
  			val=0;
  		}
  		if(value==-1){
  			value=0;
  		}
  		var offerId = document.couponForm.selectedOffers.value;
  		
  		var value1 = Number(value);
  		
  		//value1.toPrecision(3);
  		
  		var offersSelected = $('input[name=offersSelected]').val();
  		//alert("offersSelected >>>"+offersSelected);
  		if(offersSelected.length <= 0){
  			document.couponForm.offersSelected.value = id;
  	  		
  		}else if(offersSelected.length > 0){
  			
  			document.couponForm.offersSelected.value = document.couponForm.offersSelected.value +'|'+id;
  		}
  		//alert("End >>>"+document.couponForm.offersSelected.value);
  		document.couponForm.selectedOffers.value = offerId+'|'+id+':'+categoryId;
  		
  		document.couponForm.selectedOffIdValue.value = document.couponForm.selectedOffIdValue.value+'|'+id+':'+categoryId+'^^'+value;
  		document.couponForm.noSelectedOffers.value = c+1;
  		
  		var oriValue = roundNumber(val+value1,2);
  		
  		//var presicionValue = (oriValue.toString()).substring((oriValue.toString()).indexOf('.'));
  		//alert(presicionValue.length);
  		//if(presicionValue.length >3){
  				//oriValue = Number(oriValue).toPrecision(2);
  		//}if(presicionValue.length == 2){
  			//oriValue = Number(oriValue).toPrecision(4);
  		//}
  		if(oriValue==-1.00){
  			oriValue=0.00;
  		}
  		document.couponForm.selectedOfferValue.value = oriValue;
  		document.getElementById("savSelectedOffers").innerHTML = c+1;
  		document.getElementById("savSelectedOfferValue").innerHTML = oriValue;
  	}
  	 function roundNumber(num, dec)
  	  { var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); 
		result = result.toFixed(2);
		return result; }
	
		 	
function getSelectedOffer()
	{	
	if(document.couponForm){
		
		document.getElementById("savSelectedOffers").innerHTML = document.couponForm.noSelectedOffers.value;
		var checkAllContent=document.couponForm.totIdValue.value.split('^^');
		var checkAllCount=checkAllContent.length-1;
		document.getElementById("savSelectedOfferValue").innerHTML = document.couponForm.selectedOfferValue.value;  		
		var offerId = document.couponForm.selectedOffIdValue.value;
		var offTotId = document.couponForm.offerTotId.value;
		var qualifiedId = document.couponForm.qualifiedOfferIds.value;
		var col = document.couponForm.col.value;
		var selAll = document.couponForm.selectAllFlag.value;
		var childOffer = document.couponForm.childOffer.value;
		if(selAll == 1){
	  		document.getElementById("savSelectedOffers").innerHTML = checkAllCount;
	  		document.getElementById("savSelectedOfferValue").innerHTML = document.couponForm.offerTotValue.value;
		}
		if(offerId != 'null'){
		var split = offerId.split("|");
		
		for(var seloffervalue = 0;seloffervalue<split.length;seloffervalue++){	
		   if(''!=(split[seloffervalue].toString())&& 'null' != (split[seloffervalue].toString())){
		  	var split5 = split[seloffervalue].toString().split(":");	
		  	var arrOfferValue = split5[1].split("^^");	
				 if(offTotId.indexOf(split5[0])== -1 && qualifiedId.indexOf(split5[0])== -1 && childOffer.indexOf(split5[0])== -1){
					removeNoSelectedOffers(arrOfferValue[1],split5[0],arrOfferValue[0],col,selAll);
				 }
			  }
			}
			if(selAll == 1){
	  		document.getElementById("savSelectedOffers").innerHTML = checkAllCount;
	  		document.getElementById("savSelectedOfferValue").innerHTML = document.couponForm.offerTotValue.value;
		    }
		}
	 }
	 if(document.frmLoadActivex){
	 callactivex();
	 }
	}
		
  	function removeNoSelectedOffers(value,id,categoryId,col,selAll)
  	{
  		var c = Number(document.getElementById("savSelectedOffers").innerHTML);
  		
  		var val = Number(document.getElementById("savSelectedOfferValue").innerHTML);
  		//val = val.toPrecision(3);
  		if(value=='null'){
		value=0;
		}
		if(val==-1){
			val=0;
		}
   		if(value==-1){
			value=0;
		}
		
  		var value1 = Number(value);
  		//value1 = value1.toPrecision(3);
  		var offerId = document.couponForm.selectedOffers.value;
		
		var split = offerId.split("|");
		var remOfferId = "";
		for(var intId = 0;intId < split.length;intId++){
			if(split[intId]!=id+':'+categoryId && split[intId] != ''){
				remOfferId = remOfferId+'|'+split[intId];
				
			}
		}
		//added for deselect a coupon  fix
		var offerIdOnly = document.couponForm.offersSelected.value;
		
		var splitOnly = offerIdOnly.split("|");
		var remOfferIdOnly = "";
		for(var intId = 0;intId < splitOnly.length;intId++){
		var stringval=splitOnly[intId].substring(0,splitOnly[intId].indexOf(':'));
			if(stringval!=id && stringval!= ''){
				remOfferIdOnly = remOfferIdOnly+'|'+stringval;
				
			}
		}
		//added for deselect a coupon fix
		
		var offerId = document.couponForm.selectedOffIdValue.value;
		
		var split1 = offerId.split("|");
		var remOfferIdValue = "";
		for(var intId = 0;intId < split1.length;intId++){
			var splitid = split1[intId].split(":");
			
			if(split1[intId] != ''&& splitid[0]!=id){
				remOfferIdValue = remOfferIdValue+'|'+split1[intId];
				
			}
		}		

		var removedOfferId = document.couponForm.removedOffers.value;
		document.couponForm.selectedOffers.value = remOfferId;		
		document.couponForm.offersSelected.value=remOfferIdOnly;
		document.couponForm.selectedOffIdValue.value = remOfferIdValue;		
		document.couponForm.removedOffers.value = removedOfferId+'|'+id;
		document.couponForm.noSelectedOffers.value = c-1;
		var oriValue = roundNumber(val-value1,2);
		//(val-value1).toPrecision(3);
		///var presicionValue = (oriValue.toString()).substring((oriValue.toString()).indexOf('.'));
  		
  		//if(presicionValue.length >3){
  			//oriValue = Number(oriValue).toPrecision(2);
  		//}if(presicionValue.length == 2){
  			//oriValue = Number(oriValue).toPrecision(4);
  		//}
  		document.couponForm.selectedOfferValue.value = oriValue;
  		document.getElementById("savSelectedOffers").innerHTML = c-1;
  		document.getElementById("savSelectedOfferValue").innerHTML =oriValue;
  		document.couponForm.selectAllFlag.value=selAll;	
  		if(col == 1)
  		document.couponForm.chkSelectAll1.checked = false;
  		else
  		document.couponForm.chkSelectAll2.checked = false;
  	}
  	
  	function nextPage(pageNum)
  	{
   		//document.couponForm.action = "SmartSourceFrontController?command=CouponDisplayCommand";
   		document.couponForm.command.value="CouponDisplayCommand";
  		document.couponForm.pageNo.value = pageNum;
  		document.couponForm.promptClicked.value='Y';
  		document.couponForm.submit();
  	}
  	function goToPage(c,localeId){  	
	  if(!isNumeric(c))
		{
		  if(localeId ==2) {
			  alert("Veuillez entrer un numéro de page valide");
			  
		  } else {
			  alert('Please Enter Valid Page Number');
		  }
		  
	    	return false;
		}
			
  	else if(Number(c) >Number(document.couponForm.totPage.value) || Number(c) <= 0){
  		 if(localeId ==2) {
			  alert("Veuillez entrer un numéro de page valide");
		  } else {
			  alert('Please Enter Valid Page Number');
		  }
	    	return false;
		//a=document.couponForm.pageNo.value;
		//var b=document.getElementById('goPageTop');
		//var d=document.getElementById('goPageBottom');
		//b.value=a;
		//d.value=a;
	}
  	else {
   	nextPage(c);
  	return true;
  	}	
  	}
  
  function deSelectAll(col){
  	var ch1 = true;
  	//Commented as different logic added for select all check box
  	/*for(var c=0 ; c<document.couponForm.length ; c++){
				if(document.couponForm[c].type == 'checkbox' 
				&& document.couponForm[c].name.lastIndexOf("chkoffer") == 0){
					if(!document.couponForm[c].checked){
					ch1=false;
					break;
					}
					}
					}*/
  	//Added to select all check box if total offer ids selected
  	var c = Number(document.getElementById("savSelectedOffers").innerHTML);
  	var count = document.couponForm.count.value;  	
  	if(c != count){  		
  		ch1=false;
  	}					
	if(ch1){
	if(col==1){
  			document.couponForm.chkSelectAll1.checked =true;
  		}else{
  			document.couponForm.chkSelectAll2.checked =true;
  		}
  		document.couponForm.selectAllFlag.value=1;	
	}
	else{
	if(col==1){
  			 document.couponForm.chkSelectAll1.checked=false ;
  		}else{
  			document.couponForm.chkSelectAll2.checked =false;
  		}
  		document.couponForm.selectAllFlag.value=0;	
  	}
  	}
  	
  	
  	function selectAll(col)	{
  	
  		var check ;
  		if(col==1){
  			check = document.couponForm.chkSelectAll1.checked ;
  		}else{
  			check = document.couponForm.chkSelectAll2.checked ;
  		}
  		
    	if(check == true)
  		{
  			
			for(var c=0 ; c<document.couponForm.length ; c++)
				if(document.couponForm[c].type == 'checkbox' 
				&& document.couponForm[c].name.lastIndexOf("chkoffer") == 0)
					document.couponForm[c].checked = true;
			document.couponForm.selectAllFlag.value=1;	
			
			//Added for uat defect fix- 206480   Select all count and savings summary functionality - starts 
			var checkAllContent=document.couponForm.totIdValue.value.split('^^');
  			var checkAllCount=checkAllContent.length-1;
			document.couponForm.noSelectedOffers.value = checkAllCount;
  			document.couponForm.selectedOfferValue.value = document.couponForm.offerTotValue.value;
  			
  			
  			//var offerId = document.couponForm.offerTotId.value;
  			//alert('offerId>>'+offerId);
  			//var split1 = offerId.split("|");
  			//var offersSelected = "";
  			//for(var intId = 1;intId < split1.length;intId++){
  			//	var splitid = split1[intId].split(":");	  				
  			//	offersSelected = offersSelected+'|'+splitid[0];
  			//}	
  			//alert('offersSelected>>'+offersSelected);
  			//document.couponForm.offersSelected.value = offersSelected;
  			document.getElementById("savSelectedOffers").innerHTML =checkAllCount;
			//Added for uat defect fix- 206480   Select all count and savings summary functionality  - Ends
			document.couponForm.selectedOffers.value =document.couponForm.offerTotId.value;
			document.getElementById("savSelectedOfferValue").innerHTML =document.couponForm.offerTotValue.value;		
			document.couponForm.selectedOffIdValue.value = document.couponForm.totIdValue.value;
		}
		else if(check == false)
		{
			for(var c=0 ; c<document.couponForm.length ; c++)
				if(document.couponForm[c].type == 'checkbox' 
				&& document.couponForm[c].name.lastIndexOf("chkoffer") == 0)
					document.couponForm[c].checked = false;
			document.couponForm.selectAllFlag.value=0;	
			
			document.couponForm.noSelectedOffers.value = 0;
  			document.couponForm.selectedOfferValue.value = 0;
			document.getElementById("savSelectedOffers").innerHTML =0;			
			document.couponForm.selectedOffers.value ='';
			document.couponForm.offersSelected.value ='';//added for deselect all fix
			document.couponForm.selectedOffIdValue.value ='';
			document.getElementById("savSelectedOfferValue").innerHTML =0;
		}
	}
	
	function printOffer(partnerSiteId,localeId){
		var osNam=navigator.platform;
		var browserName = navigator.appName; 
		clearPageNumber();
    	if(document.couponForm.noSelectedOffers.value == 0){
		//if(noCouponmsg=='null' || noCouponmsg==null){
		//	alert("Please select the coupons you would like to clip and click the Print Now button.");
		//}else{	  
		//	alert(noCouponmsg);
		//}
    		if(localeId == 2){
    			alert("Veuillez sélectionner le(s) coupon(s) à imprimer");
    		} else {
    			alert("Please select the coupon(s) to Print.");
    		}
		}else{
		//document.couponForm.action="SmartSourceFrontController?command=AddOnCommand&partnerSiteId="+partnerSiteId;
		document.couponForm._a.value=partnerSiteId;
		document.couponForm.osDetails.value=osNam;		
		document.couponForm.command.value="AddOnCommand";
		document.couponForm.browserName.value=browserName;	
    	document.couponForm.submit();
		}
	}
	function AddOffers(partnerSiteId,regReqd){	
		//alert('regReqd'+regReqd);	
		var browserName = navigator.appName;
		var osNam=navigator.platform;
		clearPageNumber();
		if(document.couponForm.noSelectedOffers.value == 0){
			alert("Please select the coupon you would like to clip and click the Add To Card button");
		}else{
		if(regReqd=='Y' || regReqd=='y')
			{
				//alert('card condn');
				//document.couponForm.action = "SmartSourceFrontController?command=AddOnCommand&partnerSiteId="+partnerSiteId+"&browserName="+browserName+"&showCardPage=Y";
				document.couponForm.command.value="AddOnCommand";
				document.couponForm.showCardPage.value="Y";
				
			}
			else
			{
				//alert('no card condn');
				//document.couponForm.action = "SmartSourceFrontController?command=CouponDisplayCommand&partnerSiteId="+partnerSiteId+"&toPage=AddToCard"+"&browserName="+browserName;
				document.couponForm.command.value="CouponDisplayCommand";
				document.couponForm.toPage.value="AddToCard";
			}

		//document.couponForm.action = "SmartSourceFrontController?command=CouponDisplayCommand&partnerSiteId="+partnerSiteId+"&page=AddToCard";
		document.couponForm._a.value=partnerSiteId;
		document.couponForm.osDetails.value=osNam;		
		document.couponForm.browserName.value=browserName;		
		document.couponForm.submit();
    	}
	}
	//added for SweepStake & Qualified offers
function playnsave(){
	var o=document.getElementsByTagName("input");
	//alert(o.length);
	var qName=null;
	var qAnswered=false;
	var count = 0;
	var err=document.getElementById("errorCell");
	var localeId = document.getElementById("localeId");
	if(err)
		err.innerHTML = "";
	for(x=0; x<o.length; x++)
	{
		var t = o[x];		
		
		if (o[x].type.toLowerCase()=='radio')
		{
			/*alert('Name = '+o[x].name + '\n'+'Type = '+o[x].type + '\n'+'tagName = '+o[x].tagName + '\n'
			+'Checked = '+o[x].checked + '\n');*/
		
			if(qName!=o[x].name)
			{
				if(qName!=null && qAnswered==false)
				{
					break;
				}
				qName = o[x].name;
				if(qAnswered)
				{
					qAnswered = false;
				}
			}
			if(o[x].checked)
			{
				qAnswered = true;
				count++;
			}
			

		}		
	}
	if(qAnswered==false)
	{			
		//alert(count);
		if(err)
			if(localeId != null && localeId.value ==2){
				err.innerHTML = "Veuillez répondre à toutes les questions ci-dessous pour recevoir des économies supplémentaires.";
			} else {
				err.innerHTML = "Please answer all of the questions below to receive your bonus savings";
			}	
		//alert('Please answer all of the questions below to receive your bonus savings');
		return false;
	}

		
		var c = Number(opener.document.getElementById("savSelectedOffers").innerHTML);
  		//var val = Number(opener.document.getElementById("savSelectedOfferValue").innerHTML);
  	
  		
  		document.playandsave.offerTotValue.value = opener.document.couponForm.offerTotValue.value;
  		document.playandsave.selectedOfferValue.value = opener.document.couponForm.selectedOfferValue.value;
  		document.playandsave.selectedOffIdValue.value = opener.document.couponForm.selectedOffIdValue.value;
  		
  		opener.document.couponForm.noSelectedOffers.value = c+1;
  		//opener.document.couponForm.selectedOfferValue.value = val+document.playandsave.offerValue.value;
  		opener.document.getElementById("savSelectedOffers").innerHTML = c+1;
  		//opener.document.getElementById("savSelectedOfferValue").innerHTML = val+document.playandsave.offerValue.value;
	
	
		//opener.document.couponForm.submit();
		return true;
}


  	function isEmpty(o)
  {	
	if(typeof o.value != 'undefined')
		{
			if(o.value==null||o.value=="")
			{
				return true;
			}
	 }	
	 return false;
}

	 function sweepStakesCall(offerId,offerTypeId,localeId){              
                                premiumTracking(offerId,offerTypeId);
                                var siteId=document.couponForm._a.value;
                                var defaultLocaleId =document.couponForm.defaultLocaleId.value;
                                var secondaryLocaleId=document.couponForm.secondaryLocaleId.value;
                                var localeLanguage=document.couponForm.localeLanguage.value;
                                var defaultLocaleLanguage=document.couponForm.defaultLocaleLanguage.value;
                                var secondaryLocaleLanguage=document.couponForm.secondaryLocaleLanguage.value;
                                var defaultLocaleCode=document.couponForm.defaultLocaleCode.value;
                                var secondaryLocaleCode=document.couponForm.secondaryLocaleCode.value;
        window.open("SmartSourceFrontController?command=CouponSweepStakeCommand&offerId="+offerId+"&offerTypeID="+offerTypeId
          +"&_a="+siteId+"&localeId="+localeId+"&defaultLocaleId="+defaultLocaleId+"&secondaryLocaleId="+secondaryLocaleId+"&localeLanguage="+localeLanguage+"&defaultLocaleLanguage="+defaultLocaleLanguage+"&secondaryLocaleLanguage="+secondaryLocaleLanguage+"&defaultLocaleCode="+defaultLocaleCode+"&secondaryLocaleCode="+secondaryLocaleCode,"mywindow","scrollbars=1,width=600,height=460"); 
     }

	function playnSaveCall(offerId,offerValue,categoryId,fontStyle,localeId){	
	var siteId=document.couponForm._a.value;
	var defaultLocaleId =document.couponForm.defaultLocaleId.value;
	var secondaryLocaleId=document.couponForm.secondaryLocaleId.value;
	var localeLanguage=document.couponForm.localeLanguage.value;
	var defaultLocaleLanguage=document.couponForm.defaultLocaleLanguage.value;
	var secondaryLocaleLanguage=document.couponForm.secondaryLocaleLanguage.value;
	var defaultLocaleCode=document.couponForm.defaultLocaleCode.value;
	var secondaryLocaleCode=document.couponForm.secondaryLocaleCode.value;
	 window.open("SmartSourceFrontController?command=CouponSweepStakeCommand&offerId="+offerId+
        "&offerTypeID="+8+"&offerValue="+offerValue+"&categoryId="+categoryId+"&fontStyle="+fontStyle
        +"&_a="+siteId+"&localeId="+localeId+"&defaultLocaleId="+defaultLocaleId+"&secondaryLocaleId="+secondaryLocaleId+"&localeLanguage="+localeLanguage+"&defaultLocaleLanguage="+defaultLocaleLanguage+"&secondaryLocaleLanguage="+secondaryLocaleLanguage+"&defaultLocaleCode="+defaultLocaleCode+"&secondaryLocaleCode="+secondaryLocaleCode,"mywindow","scrollbars=1,width=600,height=460"); 
premiumTracking(offerId,8);
	}
		
		
	function linkCall(offerId,offerTypeId,url){
	        if(offerTypeId!=null && offerTypeId=='4'){
	          new WebTrends().dcsMultiTrack('WT.ac',offerId);
	         }
             premiumTracking(offerId,offerTypeId);
             window.open (url,"mywindow"); 
            
      }
	function linkCallPopUp(offerId,offerTypeId,url){
	         new WebTrends().dcsMultiTrack('WT.ac',offerId);
             window.open (url,"mywindow","scrollbars=1,width=500,height=500"); 
             premiumTracking(offerId,offerTypeId);
      }



function validate(){
  	var o = document.form1.elements;
  	  var error=document.getElementById('errorMessage');
  	  var localeId = document.getElementById('localeId').value;
  	  var expchar = "a-zà-ÿ"
  		 expchar = expchar + expchar.toUpperCase();
  	    error.innerHTML='';
	//alert('Total Elements '+o.length);
  	for(x=0;x<o.length; x++)
	{		
		switch (o[x].tagName.toLowerCase())
		{
			case 'input':
				//alert('Input Name = '+o[x].name + '\n'+'Type = '+o[x].type + '\n'+'tagName = '+o[x].tagName + '\n');		
				switch (o[x].type.toLowerCase())
				{
					case 'text':
						if(o[x].value=='')
						{
							if(localeId == 2) {
								error.innerHTML="S'il vous plaît répondre à toutes les questions obligatoires";
							} else {
								error.innerHTML='Please answer all mandatory questions';
							}	
							 
							return false;
						}else {
							  var matchString = "^[0-9"+expchar+"\\s|':.@_\\-~#^&,;$!/\\\\{}()]+$"; 
							  var objRegExp = new RegExp(matchString);
							  if(!objRegExp.test((o[x].value))){
								  if(localeId == 2) {
									  error.innerHTML="S'il vous plaît entrez réponse valable";
								  } else {
									  error.innerHTML='Please enter valid answer';
								  }
								  return false;
								  }
						}
					break;
					case 'radio':						
						var eName = o[x].name;
						//alert('eName>>>>>>>>>>>'+eName);
						var eArray = document.getElementsByName(o[x].name);
						var checked = false;
						for(y=0;y<eArray.length;y++)
						{
							//alert('eArray[y].checked>>>>>>>>>>'+eArray[y].checked);
							if(eArray[y].checked)
							{
								//alert('Inside if condition');
								checked = true;
								break;
							}
						}			
						//alert('checked>>>>>>>>>>'+checked);
						if(!checked)
						{
							//alert('Inside if checked condition');
							if(localeId == 2) {
								error.innerHTML="S'il vous plaît cochez le bouton radio";
							} else {
								error.innerHTML='Please check the radio button';
							}
							return false;
						}	
					break;
					case 'checkbox':						
						var eName = o[x].name;
						var eArray = document.getElementsByName(o[x].name);
						var checked = false;
						for(y=0;y<eArray.length;y++)
						{
							//alert('eArray[y].checked>>>>>>>>>>'+eArray[y].checked);
							if(eArray[y].checked)
							{
								//alert('Inside if condition');
								checked = true;
								break;
							}
							//added for removing mandatory validation for sample offer check box
							if(eArray[y].id == 'sam'){
								checked = true;
								break;

							}
						}			
						//alert('checked>>>>>>>>>>'+checked);
						if(!checked)
						{
							//alert('Inside if checked condition');
							if(localeId == 2) {
								error.innerHTML="S'il vous plaît cocher la case";
							} else {
								error.innerHTML='Please check the check box';
							}
							return false;
						}	
					break;
				}			
				break;
			case 'select':
				if(o[x].selectedIndex==0||o[x].options[o[x].selectedIndex].value==-1||o[x].options[o[x].selectedIndex].value=='select')
				{
					if(localeId == 2) {
						error.innerHTML="S'il vous plaît répondre à toutes les questions obligatoires";
					} else {
						error.innerHTML='Please answer all mandatory questions';
					}
					return false;
				}
				//alert('Select Name = '+o[x].name + '\n'+'Type = '+o[x].type + '\n'+'tagName = '+o[x].tagName + '\n');
				break;
			case 'textarea':
				//alert('TextArea Name = '+o[x].name + '\n'+'Type = '+o[x].type + '\n'+'tagName = '+o[x].tagName + '\n');
				if(o[x].value=='')
				{
					if(localeId == 2) {
						error.innerHTML="S'il vous plaît répondre à toutes les questions obligatoires";
					} else {
						error.innerHTML='Please answer all mandatory questions';
					}
					return false;
				}else {
					  var matchString = "^[0-9"+expchar+"\\s|':.@_\\-~#^&,;$!/\\\\{}()]+$"; 
					  var objRegExp = new RegExp(matchString);
					  if(!objRegExp.test((o[x].value))){
						  if(localeId == 2) {
							  error.innerHTML="S'il vous plaît entrez réponse valable";
						  } else {
							  error.innerHTML='Please enter valid answer';
						  }
						  return false;
						  }
				}
				break;
		}
	}
	var accept=document.getElementById('acceptance');
	if(accept!=null){
	if(!accept.checked){
		if(localeId == 2) {
			error.innerHTML="S'il vous plaît Vérifier l'acceptation par les utilisateurs pour que votre entrée soit soumis.";
		} else {
			error.innerHTML='Please Check the User Acceptance in order for your entry to be submitted.';
		}
	return false;
	}
	}
	document.form1.submit();
  	return true;
  }	
function isNumeric(n)
{
	var match = "^[0-9]+$"; 
	var objRegExp = new RegExp(match);
	return objRegExp.test(n);
}
function isAlphaNumeric(n)
{
	var match = "^[A-Z0-9][a-zA-Z0-9]*$"; 
	var objRegExp = new RegExp(match);
	return objRegExp.test(n);
}	

function validateZipCode(n,localeId)
{		
		if(checkZipCode(n))
		{
			if(localeId == 2){
				alert('Entrez province valide');
				return false;
			} else if(localeId == 3){
				alert('Enter Valid Province');
				return false;
			} else {
				alert('Enter Valid Zip Code');
				return false;
			}
		}	
	  return true;	

}
if(!Array.indexOf){
	  Array.prototype.indexOf = function(obj){
	   for(var i=0; i<this.length; i++){
	    if(this[i]==obj){
	     return i;
	    }
	   }
	   return -1;
	  }
	}

function checkZipCode(o)
{
//var province = ["111", "112",  "MB", "NB", "NS", "ON", "QB", "SK"]; 

	if(!isEmpty(o))
	{
		var v = o.value;
		
		if(isNumeric(v)  )
		{
		
			var ZIP_REGEX = "[0-9]";
			var objRegExp = new RegExp(ZIP_REGEX);
			if (objRegExp.test(v) )
			{	
				return false;
			}
			return true;
		}
		else return true;
	}
	else return false;
}

function validateLoginForm(localeId){
   err=document.getElementById('userError');
   document.getElementById('error').style.display='none';
    err.innerHTML='';
     for(var i=0;i<document.getElementById('listSize').value;i++){
       if(document.getElementById('ansFlag'+i).value=="Y"){
          var type=document.getElementById('ansType'+i).value;
          var ans=document.getElementById('ans'+i);
          if(type=='154'||type=='152'){
          if(isEmpty(ans)){
        	  if(localeId == 2) {
        		  err.innerHTML="Veuillez fournir les renseignements demandés";
        	  } else {
        		  err.innerHTML='Please provide required information';
        	  }
                 ans.focus();
                return false;
           }
      if(document.getElementById('questionId'+i).value=="9"){
    	  if(localeId == 2 || localeId ==3) {
    		  if(ans.value.length !=6){
    		      err.innerHTML="S'il vous plaît entrez zipcode valide";
    		      ans.focus();
                  return false;
    		  }
    		  if(!isAlphaNumeric(ans.value))
    			 { 
    			      err.innerHTML="S'il vous plaît entrez zipcode valide";
    			     ans.focus();
    	             return false;
    			  }
    	  } else {
	      	if(!isNumeric(ans.value))
			 { 
			      err.innerHTML='Please enter valid zipCode';
			     ans.focus();
	             return false;
			  }
			  if(ans.value.length !=5){
			      err.innerHTML='Please enter valid zipCode';
			      ans.focus();
	              return false;
			  }
			}
      }
	   }else if(type=='155' || type=='151'){
           var eArray = document.getElementsByName('ans'+i);
	       var checked = false;
	 	 for(y=0;y<eArray.length;y++)
	    {
		    if(eArray[y].checked)
		    {
		      checked = true;
		       break;
		     }
	    }				
        if(!checked)
	    {
        	if(localeId == 2) {
        		err.innerHTML="Veuillez fournir les renseignements demandés";
        	} else {
        		err.innerHTML='Please provide required information';
        	}
	      ans.select();
	      return false;
	    }	
       } else if(type=='153') {
          if(ans.value==""){
        	  if(localeId == 2) {
          		err.innerHTML="Veuillez fournir les renseignements demandés";
          	} else {
          		err.innerHTML='Please provide required information';
          	}
          ans.select();
          return false;
        }
      }
     if(document.getElementById('questionId'+i).value=="10"){
       var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
          if(!(filter.test(ans.value))){ 
        	  if(localeId == 2) {
            		err.innerHTML="Courriel invalide";
            	} else {
            		err.innerHTML='Invalid Email';
            	}
           ans.focus();
           return false;     
          }     
       }
       if(document.getElementById('questionId'+i).value=="11"){
       var password=ans.value;
        var matchString = "^[a-z A-Z0-9]+$"; 
	  var objRegExp = new RegExp(matchString);
	    if(!(objRegExp.test(password)) || password.length<6){
	    	 if(localeId == 2) {
	          		err.innerHTML="Les mots de passe doivent être de longueur 6 à 30 ans, des chiffres et / ou de lettres, et peuvent ne pas contenir de caractères spéciaux";
	          	} else {
	          		err.innerHTML='Passwords must be of length 6 to 30, numbers and/or letters, and may not contain special characters';
	          	}
	        ans.focus();
	       return false;
	       }
	       var j=i+1;
           var confirm=document.getElementById('ans'+j);
           //alert(confirm);
            if(isEmpty(confirm)){
            	 if(localeId == 2) {
               		err.innerHTML="Veuillez fournir les renseignements demandés";
               	} else {
               		err.innerHTML='Please provide required information';
               	}
                 confirm.focus();
                return false;
           }
           if(password!=confirm.value){
        	   if(localeId == 2) {
             		err.innerHTML="Les mots de passe entrés ne correspondent pas. S'il vous plaît ré-entrer le mot de confirmer";
             	} else {
             		err.innerHTML='Passwords entered do not match. Please re-enter the confirm password';
             	}
	        ans.focus();
	       return false;
           }
     
      
     
      }
   }else{
    var ans=document.getElementById('ans'+i);
   if(document.getElementById('questionId'+i).value=="9"){
    if(ans.value!=""){
    	if(localeId == 2 || localeId ==3) {
  		  if(ans.value.length !=6){
  		      err.innerHTML="S'il vous plaît entrez zipcode valide";
  		      ans.focus();
                return false;
  		  }
  		  if(!isAlphaNumeric(ans.value))
  			 { 
  			      err.innerHTML="S'il vous plaît entrez zipcode valide";
  			     ans.focus();
  	             return false;
  			  }
  	  } else {
      	if(!isNumeric(ans.value))
		 { 
		      err.innerHTML='Please enter valid zipCode';
		     ans.focus();
             return false;
		  }
		  if(ans.value.length !=5){
		      err.innerHTML='Please enter valid zipCode';
		      ans.focus();
              return false;
		  }
		}
    }
	}
   
 }
 }
 err.innerHTML="";
 document.RegistrationForm.command.value="UserRegistrationCouponCommand";
 document.RegistrationForm.submit();
 return true;
}	

function clearPageNumber(){
	var top=document.getElementById('goPageTop');
	if(top!=null){
	 	 top.value="";
	 }
    var bottom=document.getElementById('goPageBottom');
	 if(bottom!=null){
		  bottom.value="";
		}
}

function checkPageTopKey(evt) {
			
	var keycode = (window.event)?event.keyCode:evt.which;
	if (keycode == 13)
	{	
	 goToPageTop(document.getElementById('localeId').value);
	}
 }	
 
function checkPageBottomKey(evt) {
			
	var keycode = (window.event)?event.keyCode:evt.which;
	if (keycode == 13)
	{	
	 goToPageBottom(document.getElementById('localeId').value);
	}
 }

