var noCouponPop=false;
function clickBackCoupon() {
	///////////////////////////////////////
	var ww=$(window).width();
	var wh=$(document).height();
	if(wh<1000) {
		wh=5500;
	}
	var wm=Math.floor(ww/2);
	var iw=380;//the width of our image
	var ih=210; //height of the image
	var ipos=(Math.floor(ww/2))-Math.floor(iw/2); //the x postion of our window
	$('body').prepend('<div id="wfiller"></div>');
	$('body').prepend('<div style="padding:5px; background-color:#000066;" id="coupon"><div style="border:dashed 3px #000000;">'+couponDivHtml+'</div></div>');
	$("#wfiller").css({'width':ww+'px','height':wh+'px','background':'#000066','position':'absolute','left':'0px','top':'0px','opacity':'.5'});
	//$("#coupon").hide();
	$("#coupon").css({'position':'absolute','height':ih+'px','width':iw+'px','background':'#ffffff','top':'20px','left':ipos+'px','z-index':'5500','cursor':'pointer','margin':'auto','text-align':'center'});
	//$("#coupon").slideDown('normal');
	$("#wfiller,#coupon").click(function() {

											var couponUrl=document.location.href;
											couponUrl=couponUrl.replace(/#Top/,"");

											//we need to see if we are adding to a query string, or making a new one
											var qpad='';



											if(couponUrl.indexOf("?")>0) {

													qpad="&";

											} else {

													qpad="?";

											}

											document.location.href=couponUrl+qpad+'cp_code='+couponCode; }
										 );
}
window.onbeforeunload=function(ev) {
	if(noCouponPop==false) {
	clickBackCoupon();
	document.location.hash="Top";
	window.onbeforeunload=null;
	//alert("function");
	return couponAlertText;
	}
}
