chk=1;
function formSubmit(theForm)
{
	chk=0;
	var problem=false;
	var errMsg = "";
	
	if(theForm.zip.value.length <= 0)
	{
		errMsg += "Zip code is required.\n";
		var problem = true;
	}
	else
	{
		var myzip = theForm.zip.value;
		var myzip_re = /\s+/gi;
		var myzip1_re = /\D/gi;
		var myzip_result = myzip.match(myzip_re);
		var myzip1_result = myzip.match(myzip1_re);

		if (theForm.zip.value.length != 5) 
		{
			errMsg += "Zipcode is invalid.\n";
			var problem = true;
		}
		else
		{
				
			if (myzip_result != null)
			{
				errMsg += "Zipcode cannot have spaces.\n";
				var problem = true;
			}
			
			if (myzip1_result != null)
			{
				errMsg += "Zipcode contains invalid characters.\n";
				var problem = true;
			}			
		}
	}
	if(problem)
	{
		alert(errMsg);
		errMsg= "";
		return false;
	}
	else
	{
		//theForm.submit();
		return true;
	}
	
	
}
	
function exit_pop(promo)  
{
		if(chk == 1)
		{
			var url = "http://freeslide.com/exitpop.html?p=" + promo;
			//var url = "http://ileadztracker.com/track/rd/67263455/4/exitpop";
			win2 = window.open(url, "win2"); //, "width=750,height=550,menubar=0,toolbar=0,status=0"); 
		}
}

function exit_pop_rrc(promo)  
{
		if(chk == 1)
		{
		  var url = "http://freeslide.com/exitpop.html?p=" + promo;
		//	var url = "http://ileadztracker.com/track/rd/67263455/4/exitpop";
		//	win2 = window.open(url, "win2", "width=650,height=500,menubar=0,toolbar=0,status=0"); 	
		  win2 = window.open(url, "win2");
		}
}

function breakout_of_frame()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}


function loadpopunder(str_popunder){
	var once_per_session = 1;
	var winfeatures="scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=1"
	
	if ( once_per_session == 0 || get_cookie('popunder')=='' )
	{
		win2=window.open(str_popunder,"",winfeatures);
		win2.blur();
		setTimeout('window.focus()',3000);
		document.cookie="popunder=yes";
	}
}

/*
function loadpopunder(){
	var popunder="http://handbagtestpanel.com"
	var winfeatures="scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=1"
	
	if ( once_per_session == 0 || get_cookie('popunder')=='' )
	{
		alert ("here");
		win2=window.open(popunder,"",winfeatures);
		win2.blur();
		window.focus();
		document.cookie="popunder=yes;expires="+expire.toGMTString();
	}
}
*/

function echeckRRC(str){

        var at="@"
        var dot="."
        var lat=str.indexOf(at)
        var lstr=str.length
        var ldot=str.indexOf(dot)
        if (str.indexOf(at)==-1){
           return false
        }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
           return false
        }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
                return false
        }

         if (str.indexOf(at,(lat+1))!=-1){
                return false
         }

         if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
                return false
         }

         if (str.indexOf(dot,(lat+2))==-1){
                return false
         }

         if (str.indexOf(" ")!=-1){
                return false
         }

         return true
}
function ValidateRRCEmailSubmit(theForm){
	chk=0;
	var problem=false;
	var errMsg = "";
	
	if(!echeckRRC(theForm.email.value)){
		errMsg += "Please enter a valid email address.\n";
		problem = true;
	}

	if(!theForm.termsagree.checked)
	{               
		errMsg += "You must agree to the privacy policy and terms and conditions.";
		problem = true;
	}
	
	if(problem)
	{
		alert(errMsg);
		errMsg="";
		return false;
	}
	else
	{
		chk=0;
		return true;
	}      
}