// JavaScript Document

var sURL = unescape(window.location.pathname);
window.onresize = function (){
// window.location.href = sURL;
}

window.onload = function(){

	
	document.getElementById("sandwichLogo").onmouseover = function(){
		document.getElementById("sandwichLogo").src="/img/sandwich_logo_over.jpg";
	}
	document.getElementById("sandwichLogo").onmouseout = function(){
		document.getElementById("sandwichLogo").src="/img/sandwich_logo.jpg";
	}
	document.getElementById("sandwichLogo").onclick = function(){
		window.open("http://www.sandwich.eu");
	}



var smallStylesheetLink = "/css/style800.css";
var normalStylesheetLink = "/css/style1024.css";
var bigStylesheetLink = "/css/style1280.css";

setStyle();



function setStyle() {
   var width, height;
   if(window.innerWidth) {
      width = window.innerWidth;
      height = window.innerHeight;
   }
   else if(document.documentElement.clientWidth) {
      width = document.documentElement.clientWidth;
      height = document.documentElement.clientHeight;
   }
   else if(document.body.clientWidth) {
      width = document.body.clientWidth;
      height = document.body.clientHeight;
   }
  
   var stylesheetLink = document.getElementById("stylesheetLink");
   var useSmall = (width <= 800 );
   var useBig = (width >= 1200 );
   if(useSmall){
	    stylesheetLink.setAttribute("href", smallStylesheetLink);
   }else{
		if(useBig){
			stylesheetLink.setAttribute("href", bigStylesheetLink);
		}else{
			stylesheetLink.setAttribute("href", normalStylesheetLink);
		}
   }
}


// make page visible
document.getElementById("content").style.display='block';
}

function goGoogleMaps(){
window.open("http://maps.google.nl/maps?f=q&hl=nl&geocode=&q=rach%C3%A8le&sll=51.808456,4.502077&sspn=0.025632,0.076904&ie=UTF8&ll=51.927966,4.499588&spn=0.053669,0.153809&z=13&iwloc=A&iwstate1=dir");
	
}

function checkFrmNews(){

	if(emailCheck(document.forms[0].emailadres.value)==false){
		alert("Dit is geen geldig emailadres");
		return false;
	}

}

function emailCheck(email){
	var email = email;
		ok = isValidEmail(email);
			if(ok == false){
//			show('ErrEmailadres');
			return false;
			}else{
			return true;	
			}
}



function isValidEmail(str){
var str=str;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)){
		return true;
	}else{
		return false;
	}

}


