/*KOLLAR OM HEMSIDAN &Auml;R FAST I ANDRAS RAMAR*/
function trappedInFrames()
{
	if (window!= top)
	{
		top.location.href = location.href;
	}
}

/*SKRIPT F&Ouml;R ATT SKYDDA E-POSTADRESSER*/
function mailus() 
{
var maildivider="[at]" //enter divider you use to divide your email address strings

	for (i=0; i<=(document.links.length-1); i++)
	{
		if (document.links[i].href.indexOf(maildivider)!=-1)
		{
			document.links[i].href=document.links[i].href.split(maildivider)[0]+"@"+document.links[i].href.split(maildivider)[1]
		}

	}
}

/*H&auml;nvisa till annan CSS om de har 800x600 eller l&auml;gre*/
function checkRes()
{
//uppl&ouml;sning, Internet explorer, Firefox och modern Netscape
var resWidth; 
var ie;	
var ns6;

	ie = document.all; 
    ns6 = document.getElementById && !document.all;
    
    if(ns6)
	{
		resWidth = innerWidth; //Netscape & Firefox
		resHeight = innerHeight;
	}
	else
	{
		resWidth = screen.width; //IE och Opera
		resHeight = screen.height;
	}
	if(resWidth <= 800)
	{
		document.write('<style type="text/css" media="screen, projection">@import "/css/layout800.css";</style>');
		/*document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/layout800.css\" media=\"screen, projection\" />");*/
	}
	else
	{
		document.write('<style type="text/css" media="screen, projection">@import "/css/layout1024.css";</style>');
	}
}

/*SKAPA POPUP MED BILDINFO*/

function popUp(mypage,myname,w,h,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=0'
	win = window.open(mypage,myname,settings);
}

/*ANNAT POPUP SOM MAN SLIPPER SKAPA HTML-FIL F&Ouml;R VARJE BILD*/
// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}


/*F&Ouml;RLADDA BILDER*/
function preload()
{
    if (document.images)
    {
      imageObject = new Image();
      
      // URL
      imageURL = new Array();
      imageURL[0] = "/images/headerbg1024.gif";
      imageURL[1] = "/images/headerbg800.gif";
      imageURL[2] = "/images/maritha_sonny.jpg";

       var i = 0;
       for(i=0; i<=2; i++) 
       {
         imageObject.src = imageURL[i];
       }
    }
}


/* OBS: EJ N&Aring;GON FUNKTION*/
/*KOLLA GAMLA WEBBL&Auml;SARE + NS6 F&Aring;R ANV&Auml;NDA SITEMAP F&Ouml;R MENYN FUNKAR EJ*/
//CS1.1

var netsc6 = 0;
var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
	if(agt.indexOf('win')!=-1)
	{
		win=1;lin=0;
	}
	if(agt.indexOf('mac')!=-1)
	{
		mac=1;lin=0;
	}

var lnx=0;
	if(lin)
	{
		lnx=1;
	}
var ice=0;
var ie=0;
var ie4=0;
var ie5=0;
var ie6=0;
var com=0;
var dcm;
var op5=0;
var op6=0;
var op7=0;
var ns4=0;
var ns6=0;
var ns7=0;
var mz7=0;
var kde=0;
var saf=0;
	if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE")
	{
		var thisKDE=agt;
		var splitKDE=thisKDE.split("konqueror/");
		var aKDE=splitKDE[1].split("; ");
		var KDEn=parseFloat(aKDE[0]);
		if(KDEn>=2.2)
		{
			kde=1;
			ns6=1;
			exclude=0;
		}
	}
	else if(agt.indexOf('webtv')!=-1)
	{
		exclude=1;
	}
	else if(typeof window.opera!="undefined")
	{
	exclude=0;
		if(/opera[\/ ][5]/.test(agt))
		{
			op5=1;
		}
		if(/opera[\/ ][6]/.test(agt))
		{
			op6=1;
		}
		if(/opera[\/ ][7-9]/.test(agt))
		{
			op7=1;
		}
	}
	else if(typeof document.all!="undefined"&&!kde)
	{
		exclude=0;
		ie=1;
		if(typeof document.getElementById!="undefined")
		{
			ie5=1;
			if(agt.indexOf("msie 6")!=-1)
			{
				ie6=1;
				dcm=document.compatMode;
				if(dcm!="BackCompat")
				{
					com=1;
				}
			}
		}
		else
		{
			ie4=1;
		}
	}
	else if(typeof document.getElementById!="undefined")
	{
		exclude=0;
		if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1)
		{
			ns6=1;
			netsc6=1;
			//document.write("<link rel=stylesheet href=\"/css/ns6.css\" type=\"text/css\" media=\"screen\" />");
			//return true; //Returnerar sant om Netscape 6 - visar sitemap ist&auml;llet f&ouml;r menyn
			
		}
		else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1)
		{
			ns6=1;ns7=1;
		}
		else if(agt.indexOf("gecko")!=-1)
		{
			ns6=1;mz7=1; //S&auml;tter firefox 1.0 till sant men ej NS6
			
		}
		if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined"))
		{
			mz7=0;ns6=1;saf=1;
		}
	}
	else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4))
	{
		exclude=0;
		ns4=1;	
		if(typeof navigator.mimeTypes['*']=="undefined")
		{
			exclude=1;
			ns4=0;
		}
	}
	if(agt.indexOf('escape')!=-1)
	{
		exclude=1;ns4=0;
	}
	if(typeof navigator.__ice_version!="undefined")
	{
		exclude=1;ie4=0;
	}
	/*KOLLA OM GAMMAL IE O OMDIRIGERAR (NS4 fixas av stylesheeten)
	if(ie4)
	{
		document.write("omdirigerar");
		window.location.replace("/oldbrowser.html");
	}*/

/*##SLUT FUNKTION KOLLA WEBBL&Auml;SARE##*/

/*VALIDERA FORMUL&Auml;RET */
function validateFadder(form) 
{
	var firstName = form.firstname.value;
	var lastName = form.lastname.value;
	var street = form.street.value;
	var zip = form.zip.value;
	var city = form.city.value;
	var phone1 = form.phone_1.value;
	var mail = form.email.value;
	var errorMess = "";
	
  	if (firstName == "" || firstName == null || firstName.charAt(0) == ' ')
	{
		alert("Du m&aring;ste fylla i ditt F&ouml;rnamn!");
	    form.firstname.focus();
	    return (false);
	}
	if (lastName == "" || lastName == null || lastName.charAt(0) == ' ')
  	{
	    alert("Du m&aring;ste fylla i  ditt Efternamn!");
	    form.lastname.focus();
	    return (false);
  	}
  	if (street == "" || street == null || street.charAt(0) == ' ')
  	{
	    alert("Du m&aring;ste fylla i din Gatuadress!");
	    form.street.focus();
	    return (false);
  	}
  	if (zip == "" || zip == null || zip.charAt(0) == ' ')
  	{
	    alert("Du m&aring;ste fylla i ditt Postnr!");
	    form.zip.focus();
	    return (false);
  	}
  	if (city == "" || city == null || city.charAt(0) == ' ')
  	{
	    alert("Du m&aring;ste fylla i din Bostadsort!.");
	    form.city.focus();
	    return (false);
  	}
  	if (phone1 == "" || phone1 == null || phone1.charAt(0) == ' ')
  	{
	    alert("Du m&aring;ste fylla i minst ett Telefonnr. \nGl&ouml;m inte riktnumret!.");
	    form.phone_1.focus();
	    return (false);
  	}
  	if (mail != "")
  	{
	  	if (!validateEmail(mail))
	  	{
		  	form.email.focus();
		  	return (false);
	  	}
	}
}
/*VALIDERA E-POSTF&Auml;LTET */
function validateEmail(emailAdress)
{
	invalidCharacters = " /:,;"
	
	/*if(emailAdress == "" || emailAdress == null || emailAdress.charAt(0) == ' ')
	{
		alert("Du m&aring;ste fylla i en e-postadress d&auml;r vi kan n&aring;; dig.");
		return false;
	}*/
	for (i = 0; i < invalidCharacters.length; i++)
	{
		badCharacter = invalidCharacters.charAt(i);
		if(emailAdress.indexOf(badCharacter,0) > -1)
		{
			alert("Du m&aring;ste fylla i en giltig e-postadress!");
			return false;
		}
	}
		
	position = emailAdress.indexOf("@",1)
	if(position == -1)
	{
		alert("Du m&aring;ste fylla i en giltig e-postadress!");
		return false;
	}
	if(emailAdress.indexOf("@",position+1) != -1)
	{
		alert("Du m&aring;ste fylla i en giltig e-postadress!");
		return false;
	}
		
	periodPosition = emailAdress.indexOf(".",position)
	if(periodPosition == -1)
	{
		alert("Du m&aring;ste fylla i en giltig e-postadress!");
		return false;
	}
	if((periodPosition + 3) > emailAdress.length)
	{
		alert("Du m&aring;ste fylla i en giltig e-postadress!");
		return false;
	}
	return true; 
}
/*HIGHLIGHTA AKTUELLT FORMUL&Auml;RF&Auml;LT*/
//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor="#cccc00"

var netscape6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which)
{
	if (which.style&&intended.test(which.tagName))
	{
		if (netscape6&&eventobj.nodeType==3)
		eventobj=eventobj.parentNode.parentNode
		return true
	}
	else
		return false;
}

//Function to highlight form element
function highlight(e)
{
	eventobj=netscape6? e.target : event.srcElement
	if (previous!='')
	{
		if (checkel(previous))
		{
		previous.style.borderColor=''
		}
		previous=eventobj
		if (checkel(eventobj))
		{
		eventobj.style.borderColor=highlightcolor
		}
	}
	else
	{
		if (checkel(eventobj))
		{
			eventobj.style.borderColor=highlightcolor
		}
		previous=eventobj
	}
}
/*SLUT AKTUELLT FORMUL&Auml;RF&Auml;LT*/