

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
			
function TilmeldingValidering()
	{
	var strErrorMsg='';
	document.Konkurrence.Email.style.color='';
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; 
	if(trim(document.Konkurrence.Email.value) == "" || trim(document.Konkurrence.Email.value) == "Din email" || reg.test(document.Konkurrence.Email.value) == false) {
		if(strErrorMsg == "")
		{
			document.Konkurrence.Email.focus();
		}
		document.Konkurrence.Email.style.color='red'; 
		strErrorMsg+= '      * E-mail \n';
 		}
	
	if (strErrorMsg != '') {
			alert('Følgende felter er ikke udfyldt korrekt: \n\n'+strErrorMsg);
			return false;
		} 
		
		{
			setCookie('TilmeldingPopup','on',100)
		}
	}



function TilmeldingPopup()
	{
		if(getCookie('TilmeldingPopup') != 'on')
		{
			var myWidth = 0, myHeight = 0;
			if(typeof(window.innerWidth) == 'number') 
			{
				//Non-IE
				myWidth = window.innerWidth;
				myHeight = window.innerHeight;
			}
			else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
			{
				//IE 6+ in 'standards compliant mode'
			    myWidth = document.documentElement.clientWidth;
			    myHeight = document.documentElement.clientHeight;
			} 
			else if(document.body &&(document.body.clientWidth || document.body.clientHeight)) 
			{
				//IE 4 compatible
			    myWidth = document.body.clientWidth;
			    myHeight = document.body.clientHeight;	
			} 
			
				if(myHeight > 500)
				{
					document.getElementById("Konkurrence").style.left 				= (myWidth/2-255+10)+"px";
					document.getElementById("Konkurrence").style.top 				= (myHeight/2-235)+document.body.scrollTop+"px";
					document.getElementById("Konkurrence").style.width 				= "469px";
					document.getElementById("Konkurrence").style.height 			= "309px";
					document.getElementById("Konkurrence").style.backgroundImage	= "url(/grafik/popup/popup-nyhedsmail-bg.png)";
					document.getElementById("Konkurrence").style.position			= "absolute";
					document.getElementById('Konkurrence').style.display 			= "inline";
			
					var innerDIV = "<form method=\"post\" action=\"/nyhedsmail.asp?From=ForsidePopup&NextURL=/shop/external/formular/tilmelding.asp&Add=ok\" name=\"Konkurrence\" style=\"margin:0; padding:0\" onSubmit=\"return TilmeldingValidering(this)\">"
								+"<div style=\"height:70px;\"><div style=\"cursor:pointer; float:right;margin:25px 27px 0 0; width:33px; height:33px\" onclick=\"HideKonkurrence()\"></div></div>"
								
								+"<div style=\"padding:40px 10px 0 200px; text-align:left; color:#fff; font-size:11px\">"
								+"Tilmeld dig til vores nyhedsbrev nu<br />- så får du også alle de <b>ekstra gode</b><br />tilbud direkte i din indbakke!<br /><br /><a style=\"font-size:11px; font-weight:bold; text-decoration:underline; color:#fff\" href=\"/shop/external/formular/tilmelding.asp\">Læs mere her</a>"
								+"</div>"

								+"<div style=\"float:left; width:68px; margin-top:40px\"></div>"
								+"<div style=\"text-align:left; margin-top:39px; float:left\"><input type=\"text\" name=\"Email\" style=\"background:transparent; border:0px; width:200px; margin-top:1px\" value=\"Indtast din e-mail\" onfocus=\"if(this.value==this.defaultValue)this.value='';else this.select();\" onblur=\"if(this.value=='')this.value=this.defaultValue;\"\"></div>"
								+"<div style=\"float:left; margin-top:30px\"><p style=\"padding:0px\"><input type=\"image\" style=\"cursor:pointer\" src=\"/grafik/popup/tilmeld-gratis.png\" onMouseOver=\"this.src='/grafik/popup/tilmeld-gratis-hover.png'\" onMouseOut=\"this.src='/grafik/popup/tilmeld-gratis.png'\"></p></div>"
					

								+"</form>"
								
					document.getElementById("Konkurrence").innerHTML = innerDIV;
				}


		}
	}

function CookieSkjulTilmelding()
{
	setCookie('TilmeldingPopup','on',100)
	setTimeout(HideKonkurrence, 1000);
}

function HideKonkurrence() 
{
   document.getElementById('Konkurrence').style.display = 'none';
   setCookie('TilmeldingPopup','on',100)
}