var couponwidthdefault='358';
var couponheightdefault='480';
var couponiddefault='1451';
var couponid='1451';
var couponid2='1454';

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
 // alert(regex);
 
  if( results == null )
    return "";
  else
    return results[1];
}
function validateForm(theForm)
	{
		// Customize these calls for your form
		// Start ------->
		if (!validFirstName(theForm.FirstName))
			return false;
		if (!validLastName(theForm.LastName))
			return false;
		if (!validRequired(theForm.Email,"email"))
			return false;
		if (!validEmail(theForm.Email,"Email",true))
			return false;
		// <--------- End
		validateCustomForm(theForm);
		return true;
}

var cgi = new Object();
      cgi.http_host = location.host;
      cgi.http_user_agent = navigator.userAgent;
      cgi.http_cookie = document.cookie;
      cgi.https = (location.protocol == 'https:\/\/') ? 'on' : 'off';
      cgi.path_info = (location.pathname.indexOf('?') != -1) ?
location.pathname.substring(0, location.pathname.indexOf('?')) :
location.pathname;
      cgi.query_string = (location.search) ?
((location.search.indexOf('#') != -1) ? location.search.substring(1,
location.search.indexOf('#')) : location.search.substring(1)) : '';
      cgi.script_name = cgi.path_info;
      cgi.http_referer = document.referrer;
	
	  if (cgi.query_string.search(/refcode/i) > -1){
		 var JSREF =  gup("REFCODE");
		 document.cookie="JSREF=" + JSREF;
	  }
        var LinkLocation =
"http://www.etnasystems.com/coupon/?COUPONID=" + couponid + "&OriginalReferer=" +
getCookie("JSREF") + "&OriginalPage=" + cgi['script_name'] + "&OriginalSite=" + cgi['http_host'];
		var LinkLocation2 =
"http://www.etnasystems.com/coupon/?COUPONID=" + couponid2 + "&OriginalReferer=" +
getCookie("JSREF") + "&OriginalPage=" + cgi['script_name'] + "&OriginalSite=" + cgi['http_host'];
   
//alert("link=" + LinkLocation);
// alert('test2=' + LinkLocation);




// FANCY STUFF 


$(document).ready(function() {
	$("a.fancypopup").fancybox({
        'autoScale'     	: false,
		'overlayOpacity'	: 0.65,
		'overlayColor'		: '#999275',
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'type'					: 'iframe',
		'titleShow'			: false,
		'width'				: 530,
		'height'				: 610,
		'opacity'				: true
	});
});


$('a.fancyclose').click(function(){ 
    parent.top.$('#fancy_close').trigger('click'); 
});
