
  //-- ============================================= INITIERAR ALLA GLOBALA VARIABLER ============================================================== -->
  
  
  var DEBUG = 0;		// 0 - normal, 1 - debug light, 2 - debug
  var SPRAK,SIDA,VARDE,EDIT,LINJEN;
  
   	var CENTRERA = (getWindowWidth()-1000)/2;	
  	if (CENTRERA <= '0') {CENTRERA = 0;}
	
   var CENTRERA_HOJD = (WINDOWHEIGHT-550)/5;
  	if (CENTRERA_HOJD <= '0') {CENTRERA_HOJD = 0;}
  //- ================================================= FUNKTIONER ============================================================== -->
  
  // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som initierar sidan
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  //'" . $SIDAPHP . "','" . $$VARDE . "','" . $EDIT . "'
function initiera(sprak, sida, varde, edit) {
	
	CENTRERA = (getWindowWidth()-1000)/2;	
  	if (CENTRERA <= '0') {CENTRERA = 0;}
	
    CENTRERA_HOJD = (WINDOWHEIGHT-550)/5;
  	if (CENTRERA_HOJD <= '0') {CENTRERA_HOJD = 0;}
	
	SPRAK	= sprak;
	SIDA 	= sida;
	VARDE	= varde;
	EDIT	= edit;
	
//  	alert("Funktion: Initera()");
 	
	fixPage();
	
	
	showSaveSucess();
//	alert("Funktion: Fixpage genomkörd()");
//	alert("Alla funktioner igenomkörda!");
}

  // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som fixar till den specifiktvalda sidan
  // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


  // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som kollar hur stort fnster man anvnder
  // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


function fixPage(){
	
	switch (SIDA){			
		case 'skramlan': 		fixaSkramlan();			centerPage();		break;
							
		case 'ljusstakar': 		fixaButik();			centerPage('submeny');		break;
		case 'takkronor': 		fixaButik();			centerPage('submeny'); 		break;
		case 'konst': 			fixaButik();			centerPage('submeny'); 		break;
		case 'tradgard': 		fixaButik();			centerPage('submeny'); 		break;
		case 'grindar': 		fixaButik();			centerPage('submeny'); 		break;
		case 'vaggmotiv': 		fixaButik();			centerPage('submeny'); 		break;
		case 'varmsmide': 		fixaButik();			centerPage('submeny'); 		break;
					
		case 'servering': 		fixaCafeoSmedja();		centerPage('submeny'); 		break;
		case 'festlokal': 		fixaCafeoSmedja();		centerPage('submeny'); 		break;
		
		case 'prova': 			fixaCafeoSmedja();		centerPage('submeny'); 		break;
		case 'grupper': 		fixaCafeoSmedja();		centerPage('submeny'); 		break;
		
		case 'aktuellt': 		fixaAktuellt();			centerPage(); 				break;
		
		case 'kontakt': 		fixaKontakt();			centerPage(); 				break;
		
		case 'lankar': 			fixaLankar();			centerPage(); 				break;
			
		default:										centerPage(); 				break;
	}	
	
	
	
}



// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som ställer in lagrer beroende på grupper!
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function fixaSkramlan() {
	if (document.getElementById("Layer_Main_Large_Image")){
		document.getElementById("Layer_Main_Large_Image").style.top = 18 + 'px';
		document.getElementById("Layer_Main_Large_Image").style.left = 18 + 'px';
		document.getElementById("Layer_Main_Large_Image").style.width = 500 + 'px';
		document.getElementById("Layer_Main_Large_Image").style.height = 375 + 'px';
	}
	if (document.getElementById("Layer_Main_Text_Field")){
		document.getElementById("Layer_Main_Text_Field").style.top = 18 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.left = 536 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.width = 405 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.height = 375 + 'px';
	}
}
function fixaButik(){
	if (document.getElementById("Layer_Moving_Images")){
		document.getElementById("Layer_Moving_Images").style.left = '0px';
	}
	fixaPilar();
}
 	
function fixaCafeoSmedja(){
	if (document.getElementById("Layer_Main_Text_Field")){
		document.getElementById("Layer_Main_Text_Field").style.left = 275 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.width = 401 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.height = 400 + 'px';
	}
}

function fixaAktuellt(){
	if (document.getElementById("Layer_Main_Text_Field")){
		document.getElementById("Layer_Main_Text_Field").style.left = 275 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.width = 666 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.height = 400 + 'px';
	}
}

function fixaKontakt(){
	
	if (document.getElementById("Layer_Main_Text_Field")){
		document.getElementById("Layer_Main_Text_Field").style.top = 18 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.left = 536 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.width = 405 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.height = 375 + 'px';
	}	
	if (EDIT != 'Edit')
		loadMap();

}

function fixaLankar(){							
	if (document.getElementById("Layer_Main_Links")){
		document.getElementById("Layer_Main_Links").style.left = -1 + 'px';
		document.getElementById("Layer_Main_Links").style.top = -1 + 'px'
		document.getElementById("Layer_Main_Links").style.width = 376 + 'px';
		document.getElementById("Layer_Main_Links").style.height = 412 + 'px';
	}
	
	if (document.getElementById("Layer_Main_Text_Field")){
		document.getElementById("Layer_Main_Text_Field").style.left = 383 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.width = 569 + 'px';
		document.getElementById("Layer_Main_Text_Field").style.height = 400 + 'px';
	}
}
	
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som ställer in lagrer beroende storleken på webbläsaren
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


	function centerPage(sidlayout) {
	
  	CENTRERA = (getWindowWidth()-947)/2;	
   	if (CENTRERA <= '0') 
		CENTRERA = 0;
		
	
	if (document.getElementById("Layer_Main")){
		document.getElementById("Layer_Main").style.top = 160 + CENTRERA_HOJD + 'px';
		if (sidlayout == 'submeny'){
			document.getElementById("Layer_Main").style.left = 265 + CENTRERA + 'px';
		}else{
			document.getElementById("Layer_Main").style.left = CENTRERA + 'px';
			document.getElementById("Layer_Main").style.width = 947 + 'px';
		}
		MM_showHideLayers('Layer_Main','','show'); 	
	}
		
	if (document.getElementById("layer_meny")){
		document.getElementById("layer_meny").style.top = 10 + CENTRERA_HOJD + 'px';
		document.getElementById("layer_meny").style.left = CENTRERA + 'px';
		MM_showHideLayers('layer_meny','','show'); 
	}
	if (document.getElementById("layer_sub_meny")){
		document.getElementById("layer_sub_meny").style.top = 160 + CENTRERA_HOJD + 'px';
		document.getElementById("layer_sub_meny").style.left = CENTRERA + 'px';
		if (sidlayout == 'submeny'){
			MM_showHideLayers('layer_sub_meny','','show'); 
		}
		
	}
	if (document.getElementById("Layer_Info")){
		document.getElementById("Layer_Info").style.top = 11 + CENTRERA_HOJD + 'px';
		document.getElementById("Layer_Info").style.left = 2 + CENTRERA + 'px';
		MM_showHideLayers('Layer_Info','','show'); 
	}
	if (document.getElementById("Layer_Login")){
		document.getElementById("Layer_Login").style.top = 0 + CENTRERA_HOJD + 'px';
		document.getElementById("Layer_Login").style.left = 50 + CENTRERA + 'px';
		MM_showHideLayers('Layer_Login','','show'); 
	}
	
	
	
	if (document.getElementById("Layer_Error")){
		document.getElementById("Layer_Error").style.top = 90 + CENTRERA_HOJD + 'px';
		document.getElementById("Layer_Error").style.left = 265 + CENTRERA + 'px';
		MM_showHideLayers('Layer_Error','','show'); 
	}

}
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som gr s att menyn visas korrekt
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function fixaMenyn(SIDA,SPRAK){
	
//	alert ("bilden: " + "images/meny_" + SPRAK + "/" + SIDA + "_over" + ".png");	
//	changeImages(SIDA,'_over', "images/meny_" + SPRAK + "/"); 

}

function fixaPilar(){
	if (AntalProdukter > AntalBilderPerRad){
		
		
		if (document.getElementById("Layer_Main_Small_Image_List")){
			document.getElementById("Layer_Main_Small_Image_List").style.left = 34 + 'px';
		}
		
		
		
		if(current_Bild != 0){
			MM_showHideLayers('Layer_Main_Pil_Vanster','','show'); 
		}else{
			MM_showHideLayers('Layer_Main_Pil_Vanster','','hide'); 
		}
	
		if(current_Bild != -(AntalProdukter-AntalBilderPerRad)){
			MM_showHideLayers('Layer_Main_Pil_Hoger','','show'); 
		}else{
			MM_showHideLayers('Layer_Main_Pil_Hoger','','hide'); 
		}
	}else{
		if (document.getElementById("Layer_Main_Small_Image_List")){
			document.getElementById("Layer_Main_Small_Image_List").style.left = 6 + 'px';
		}
	}
}
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som ändrar till rätt meny_layer vid mouse over
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


function changeLayer(LayerID, Status) {
	
	var ChangeLayerNormal = "layer_" + LayerID+"_norm";
	var ChangeLayerOver = "layer_" + LayerID+"_over";
	var ChangeLayerDown = "layer_" + LayerID+"_down";
//	alert("Normal: " + ChangeLayerNormal + " ---  Over: " + ChangeLayerOver + " ---   Down: " + ChangeLayerDown);
//	MM_showHideLayers(ChangeLayerNormal,'','hide',ChangeLayerOver,'','hide',ChangeLayerDown,'','hide'); 
	
	switch (Status){			
		case 'over': 		MM_showHideLayers(ChangeLayerNormal,'','hide',ChangeLayerOver,'','show',ChangeLayerDown,'','hide'); 		break;
		case 'down': 		MM_showHideLayers(ChangeLayerNormal,'','hide',ChangeLayerOver,'','hide',ChangeLayerDown,'','show'); 		break;
		default:			MM_showHideLayers(ChangeLayerNormal,'','show',ChangeLayerOver,'','hide',ChangeLayerDown,'','hide'); 		break;
	}
}	
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som ndrar text p sidan
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function changeText(ID,text, style){
//	alert("Ändrar texten till: " + text + ", med ID: " + ID);
	document.getElementById(ID).innerHTML 	= "<span class=\"" + style + "\">" + text + "</span>";	
}

// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktioner som flyttar ett lager - test 1
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function showContent(){
	MM_showHideLayers('Layer_Content_Left','','show','Layer_Content_Right','','show'); 
}
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktioner som flyttar ett lager - test 2
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// The effect is executed by an event call to function 'zxcBAnimator('left','tst1',20,260,2000);'
// where:
// parameter 0 = the mode(see Note 1).                                                                     (string)
// parameter 1 = the unique ID name or element object.                                                     (string or element object)
// parameter 2 = the start position of the effect.                                                         (digits, for opacity minimum 0, maximum 100)
// parameter 3 = the finish position of the effect.                                                        (digits, for opacity minimum 0, maximum 100)
// parameter 4 = (optional) period of time between the start and finish of the effect in milliseconds.     (digits or defaults to 2000 milliSeconds)
//
//  Note 1:  The default units(excepting opacity) are 'px'.
//  Note 2:  Examples modes: 'left', 'top', 'width', 'height', 'opacity.
//           For hyphenated modes, the first character after the hyphen must be upper case, all others lower case.
//  Note 3:  To 'toggle' the effect include '#' in parameter 0.
//           The first call will set the toggle parameters.
//           Subsequent calls with '#' in parameter 0 and the same start and finish parameters will 'toggle' the effect.
//  Note 4:  The function may be re-executed with a different set of parameters (start/finish time or period)
//           whenever required, say from an onclick/mouseover/out event.
//           The period parameter will be retained unless re-specified.

// It may be required to access the current value of the effect.
// The element effect is accessible from the element property
// element effect = elementobject[mode.replace(/[-#]/g,'')+'oop'];
// where mode is parameter 0 of the initial call.
// An array storing the current, start and finish values of the element effect may be accessed
// from the element effect.data as fields 0, 1 and 2 respectively
//

// **** General
//
// All variable, function etc. names are prefixed with 'zxc' to minimise conflicts with other JavaScripts.
// These characters may be changed to characters of choice using global find and replace.
//
// The Functional Code(about 2K) is best as an External JavaScript.
//
// Tested with IE7 and Mozilla FireFox on a PC.

var current_Pos = 0;
var current_Bild = 0;
var Bildbredd = 123 + 2;
var AntalBilderPerRad = 5;


function scrollImages(adderaBilder){
	
	
	document.getElementById("Layer_Moving_Images").style.width = (AntalProdukter * Bildbredd) + 'px';
	
	
	current_Bild = current_Bild + adderaBilder;
	if (current_Bild > 0){ current_Bild = 0; }
	var MaxantalBilder = (-1 * AntalProdukter) + AntalBilderPerRad;
	
	if (current_Bild < MaxantalBilder){ 
		current_Bild = MaxantalBilder; 
	}   //när current_Bild = -3;  antalbilder = -9;
	
	var NyXPos = Bildbredd * current_Bild;
		
		
//		document.getElementById("current_Pos").innerHTML 	= "<span class=\"style4\">" + current_Pos + "</span>";	
//		document.getElementById("current_Bild").innerHTML 	= "<span class=\"style4\">" + current_Bild + "</span>";	
//		document.getElementById("Antal_Bild").innerHTML 	= "<span class=\"style4\">" + MaxantalBilder + "</span>";	

	zxcBAnimator('left','Layer_Moving_Images',current_Pos,NyXPos,2000);
	fixaPilar();
}



function zxcBAnimator(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime){
	
	
current_Pos = zxcfin;



 if (typeof(zxcobj)=='string'){ zxcobj=document.getElementById(zxcobj); }
 if (!zxcobj||(!zxcsrt&&!zxcfin)||zxcsrt==zxcfin) return;
 var zxcoop=zxcobj[zxcmde.replace(/[-#]/g,'')+'oop'];
 if (zxcoop){
  clearTimeout(zxcoop.to);
  if (zxcoop.srtfin[0]==zxcsrt&&zxcoop.srtfin[1]==zxcfin&&zxcmde.match('#')) zxcoop.update([zxcoop.data[0],(zxcoop.srtfin[0]==zxcoop.data[2])?zxcfin:zxcsrt],zxctime);
  else zxcoop.update([zxcsrt,zxcfin],zxctime);
 }
 else zxcobj[zxcmde.replace(/[-#]/g,'')+'oop']=new zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime);
}

function zxcBAnimatorOOP(zxcmde,zxcobj,zxcsrt,zxcfin,zxctime){
 this.srtfin=[zxcsrt,zxcfin];
 this.to=null;
 this.obj=zxcobj;
 this.mde=zxcmde.replace(/[-#]/g,'');
 this.update([zxcsrt,zxcfin],zxctime);
}

zxcBAnimatorOOP.prototype.update=function(zxcsrtfin,zxctime){
 this.time=zxctime||this.time||2000;
 this.data=[zxcsrtfin[0],zxcsrtfin[0],zxcsrtfin[1]];
 this.srttime=new Date().getTime();
 this.cng();
}

zxcBAnimatorOOP.prototype.cng=function(){
 var zxcms=new Date().getTime()-this.srttime;
 this.data[0]=(this.data[2]-this.data[1])/this.time*zxcms+this.data[1];
 if (this.mde!='left'&&this.mde!='top'&&this.data[0]<0) this.data[0]=0;
 if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
 else  zxcOpacity(this.obj,this.data[0]);
 if (zxcms<this.time) this.to=setTimeout(function(zxcoop){return function(){zxcoop.cng();}}(this),10);
 else {
  this.data[0]=this.data[2];
  if (this.mde!='opacity') this.obj.style[this.mde]=this.data[0]+'px';
  else zxcOpacity(this.obj,this.data[0]);
 }
}

function zxcOpacity(zxcobj,zxcopc){
 if (zxcopc<0||zxcopc>100) return;
 zxcobj.style.filter='alpha(opacity='+zxcopc+')';
 zxcobj.style.opacity=zxcobj.style.MozOpacity=zxcobj.style.KhtmlOpacity=zxcopc/100-.001;
}



// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som Fadar in-ut enskilda bilder
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	
	var speed = Math.round(millisec / 100);
	 
	var timer = 0;
	 
	//set the current image as background
	
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;
//	alert ("Bildfilen: " + imagefile);
	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
 




  
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som vxlar bilder vid mouseover
  // ---------------------------------------------------------------------------------------------------------------------------------------------------

   
function changeImages(BildNamn, Status, location) {
	document.images["img_" + BildNamn].src= location + BildNamn + Status + ".png";
}							
  
function showLargeImage(BildNamn, location){
	document.images["img_" + BildNamn].src= location;
}

  // -----------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som skriver ut ett ord i input rutor
  // ---------------------------------------------------------------------------------------------------------------------------------------------------
function clearPrompt(id, text) {  
 var inputfield = document.getElementById(id);  
 if (inputfield.value == text) {  
   inputfield.value = "";  
 }  
}  

// Set the prompt for the username field, if required.  
function setPrompt(id, text) {  
 var inputfield = document.getElementById(id);  
 if (inputfield.value == "") {  
   inputfield.value = text;  
 }  
}  
///////////////////////////////////////////////////////////////77

function clearLinkPrompt(id, text) {  
 var inputfield = document.getElementById(id);  
 if (inputfield.value == text) {  
   inputfield.value = "http://";  
 }  
}  
function setLinkPrompt(id, text) {  
 var inputfield = document.getElementById(id);  
 if (inputfield.value == "http://" || inputfield.value == "") {  
   inputfield.value = text;  
 }  
}  

//////////////////////////////////////////////////////////////////
  // Clear prompt from username field, if required.  
function clearUsernamePrompt() {  
 var username = document.getElementById("user");  
 if (username.value == "Användarnamn") {  
   username.value = "";  
 }  
}  

// Set the prompt for the username field, if required.  
function setUsernamePrompt() {  
 var username = document.getElementById("user");  
 if (username.value == "") {  
   username.value = "Användarnamn";  
 }  
}  
// Clear prompt from password field, if required.  
function clearPasswordPrompt() {  
 var password = document.getElementById("pass");  
 password.style.display = "inline";  
 password.focus();  
 var passwordPrompt = document.getElementById("passwordPrompt");  
 passwordPrompt.style.display = "none";  
}  

// Set the prompt for the password field, if required.  
function setPasswordPrompt() {  
 var password = document.getElementById("pass");  
 if (password.value == "") {  
   password.style.display = "none";  
   var passwordPrompt = document.getElementById("passwordPrompt");  
   passwordPrompt.style.display = "inline";  
 }  
}  
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktioner som visar "Uppgifterna Sparade" i två sekunder efter lycked sparning
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function showSaveSucess(){
	if (document.getElementById("Layer_Save_Sucess")){
		document.getElementById("Layer_Save_Sucess").style.left = 320 + CENTRERA + 'px';
		document.getElementById("Layer_Save_Sucess").style.top = 200 + CENTRERA_HOJD + 'px';
		MM_showHideLayers('Layer_Save_Sucess','','show'); 
		setTimeout("MM_showHideLayers('Layer_Save_Sucess','','hide')",2000);	
	}
}
// -----------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktion som håller koll på om man sparat eller inte...
// ---------------------------------------------------------------------------------------------------------------------------------------------------

 var SAVED = 1;
 var OVERRIDESAVE=0;
 
function SetSAVEtoFalse(){
	SAVED = 0;
}

function SetSAVEtoTrue(){
	SAVED = 1;
}

function checkIfSaved(){	
//	if (OVERRIDESAVE == 0){alert("Man bara lämnade sidan!");}else{alert("man tryckte på spara!");}

	if (OVERRIDESAVE == 0){		// Gör så att submitform INTE körs när man klickat på spara knappen!
		OVERRIDESAVE = 1;

	//	submitForm();
//		if (SAVED == 0){alert("Uppgifterna har ändrats!");}else{alert("Inga Ändringar!");}

		if (SAVED == 0){
			if (confirm ("Vill Ni spara era ändringar?")){
				document.EditForm.submit();
		//		alert("Ändringarna är Sparade");
			}
		}
	}
}
function saveButtonPressed(){

	OVERRIDESAVE=1; 
//	alert('Ändringarna är Sparade');

}
// -----------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktion som ritar ut ett snyggt textfield fönster som man kan ändra stil och lite så på...
// ---------------------------------------------------------------------------------------------------------------------------------------------------


//First lets initiate some variables

var isEditable= false;
var isIE;
var isGecko;
var isSafari;
var isKonqueror;
var browser = navigator.userAgent.toLowerCase();

function initiateEditor() {
 //check what browser is in use

 isIE = ((browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1) && (browser.indexOf("webtv") == -1)); 
 isGecko = (browser.indexOf("gecko") != -1);
 isSafari = (browser.indexOf("safari") != -1);
 isKonqueror = (browser.indexOf("konqueror") != -1);
 
 //enable designMode if the browser is not safari or konqueror.
 if (document.getElementById && document.designMode && !isSafari && !isKonqueror) {
   isEditable= true;
 }
}
//Javascript function dislpayEditor will create the textarea. 

function displayEditor(editor, html, width, height) {
   if(isEditable){
	   
       document.writeln('<iframe id="' + editor + '" name="' + editor + '" width="' + width + 'px" height="' + height + 'px" ></iframe>');
//create a hidden field that will hold everything that is typed in the textarea
       document.writeln('<input type="hidden" id="hidden' + editor + '" name="hidden' + editor + '" value="">');
//assign html (textarea value) to hiddeneditor 
      document.getElementById('hidden' + editor).value = html;
//call function designer
      designer(editor, html);
   }else{
     document.writeln('<textarea  name="' + editor + '" id="' + editor + '" cols="39" rows="10">' + html + '</textarea>');
   }
}

//this is designer function that enables designMode and writes defalut text to the text area
function designer(editor, html) {
     var mainContent= "<html id=" + editor + "><head><style type='text/css'><!--body,td,th {font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 18px;color: #8a7a70;}body {background-color: #FFFFFF;}--></style></head><body>" + html + "</body></html>" ;
//assign the frame(textarea) to the edit variable using that frames id
     var edit = document.getElementById(editor).contentWindow.document;
//write the content to the textarea
      edit.write(mainContent);
	  edit.close();
//enable the designMode	
      edit.designMode =  "On" ;
	  document.getElementById(editor).contentDocument.designMode = "on";
}

//To execute command we will use javascript function editorCommand. 
function editorCommand(editor, command, option) {
// first we assign the content of the textarea to the variable mainField
    var mainField;
	mainField = document.getElementById(editor).contentWindow;
 // then we will use execCommand to execute the option on the textarea making sure the textarea stays in focus
   try {
          mainField.focus();
          mainField.document.execCommand(command, false, option);
          mainField.focus();
    } catch (e) { }
}

function updateEditor(editor,original) {
	
	if (!isEditable) return;
//assign the value of the textarea to the hidden field. 
	var hiddenField = document.getElementById('sub' + editor);
	if (hiddenField.value == null) hiddenField.value = "";
		hiddenField.value = document.getElementById(editor).contentWindow.document.body.innerHTML;
		
	if (hiddenField.value !=  original)	{	// om texten är ändrad....
	//	alert("Sidan HAR ändrade uppgifter");
	
//	alert("ORIGINALTEXTEN: " + original + "   -----------------TEXTEN SOM STÅR PÅ SIDAN NU: " + hiddenField.value);
		SAVED = 0;
	}
}
// -----------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktion som visar ett pop-up fnster med frga
// ---------------------------------------------------------------------------------------------------------------------------------------------------
 
function bekraftaDELETE(oFrm,text){
//	alert(oFrm.DELETE.value);
	if (confirm (text))
		oFrm.DELETE.value='1';
	else
		oFrm.DELETE.value='-1';
}
function bekraftaSAVE(oFrm,text){
//	alert(oFrm.DELETE.value);
	if (confirm (text))
		oFrm.SAVE.value='1';
	else
		oFrm.SAVE.value='-1';
}

// =========================================================================================================================================================================================
// Crossfading pictures
// =========================================================================================================================================================================================

var CrossFadeDuration = 10;

var SlideShowSpeed1 = 4000;
var preLoad1 = new Array();
var Picture1 = new Array(); 
var tss1, iss1, jss1 = 0, pss1, preLoad1;

var SlideShowSpeed2 = 4000;
var preLoad2 = new Array();
var Picture2 = new Array(); 
var tss2, iss2, jss2 = 0, pss2, preLoad2;

function InitSlideShow(){

	pss1 = Picture1.length-1;
	
	
	for (iss1 = 0; iss1 < pss1+1; iss1++){
		preLoad1[iss1] = new Image();
		preLoad1[iss1].src = Picture1[iss1];
//		alert ("Picture1: " + Picture1[iss1] + " Preload1: " + preLoad1[iss1].src);
	}
	
	pss2 = Picture2.length-1;
	for (iss2 = 0; iss2 < pss2+1; iss2++){
		preLoad2[iss2] = new Image();
		preLoad2[iss2].src = Picture2[iss2];
//		alert ("Picture2: " + Picture2[iss2] + " Preload2: " + preLoad2[iss2].src);
	}
}

function RunSlideShow1(layer, image){
	blendimage(layer,image, preLoad1[jss1].src ,800); 
	jss1 = jss1 + 1;
	if (jss1 > (pss1)) jss1=0;
	
	tss1 = setTimeout("RunSlideShow1('"+layer+"','"+image+"')", SlideShowSpeed1);
}

function RunSlideShow2(){
	blendimage('Layer_Main_Medium_Image2','imgMediumImage2', preLoad2[jss2].src ,800); 
	jss2 = jss2 + 1;
	if (jss2 > (pss2)) jss2=0;
	
	tss2 = setTimeout('RunSlideShow2()', SlideShowSpeed2);
}



   // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som skruver ut en sida
  // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 function skrivut()
	{
		var a = window.open('','','scrollbars=yes,width=700,height=470');
		
		a.document.open("text/html");
		a.document.write('<html><head>');
		a.document.write('<style type="text/css">@import url("http://www.annalunda.nu/new/skhf.css");</style>');
		a.document.write('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA6kNufAnKoTx9dko__8h39RQR0JwiTgnwP9YHmmybsBfo2pf-sxQ_LnUCbGHJmJ66XHLPQlHM0vPZeA" type="text/javascript"></script>');
		a.document.write('<script src="googlemap.js" type="text/javascript"></script>');
		a.document.write('</head><body onLoad="loadprint();">');
		a.document.write(document.getElementById('Layer_Adress').innerHTML);
		a.document.write('</body></html>');
		a.print();
		a.document.close();
	//	a.print();
	}
	
 
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktion som tar reda p fnstrets bredd
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function getWindowWidth(){
    var ww = 0;
    d = document;
     if ( typeof window.innerWidth != 'undefined' ){
		WINDOWHEIGHT = window.innerHeight;  
       	ww = window.innerWidth;  
	 }else{
       if ( d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth != 0 ){
         ww = d.documentElement.clientWidth;
		 WINDOWHEIGHT = d.documentElement.clientHeight;
	   }else if ( d.body  && typeof d.body.clientWidth != 'undefined' ){
           ww = d.body.clientWidth;
		   WINDOWHEIGHT = d.body.clientHeight;
	   }else 
	   		alert ("Tyvärr fungerar inte sidan som den ska med eran webbläsare, prova med firefox");
     }
//	 alert("Höjden: " + WINDOWHEIGHT);
     return ww;
  }  
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Funktioner som ändrar bakgrunden och textens färg i en tabell
// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

var preEl ;
var orgBColor;
var orgTColor;
function HighLightTR(el, backColor,textColor){
  if(typeof(preEl)!='undefined') {
     preEl.bgColor=orgBColor;
     try{ChangeTextColor(preEl,orgTColor);}catch(e){;}
  }
  orgBColor = el.bgColor;
  orgTColor = el.style.color;
  el.bgColor=backColor;

  try{ChangeTextColor(el,textColor);}catch(e){;}
  preEl = el;
}


function ChangeTextColor(a_obj,a_color){  ;
   for (i=0;i<a_obj.cells.length;i++)
    a_obj.cells(i).style.color=a_color;
}
  
  
  
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  // Funktioner som dljer och tar fram lager, frn DreamWeaver
  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  function MM_showHideLayers() { //v6.0
    var i,p,v,obj,args=MM_showHideLayers.arguments;
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
      if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
      obj.visibility=v; }
  }
  
  function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
  }
// =========================================================================================================================================================================================
//Funktion fr att ta reda p musens position
// =========================================================================================================================================================================================

/*
<!--

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)


// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

  function getMouseXY(e) {
	
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY

//  filter the mouse position


  tempX = tempX - CENTRERA - vansterkant - (bredd/2); 
  tempY = tempY - ovankant;
  
	if (tempX > (bredd/2) || tempX < -(bredd/2) )	{ tempY = 0; tempX = 0; }
 	if (tempY < 0)	{ tempY = 0; tempX = 0; }
  	if (tempY > hojd)	{ tempY = 0; tempX = 0; }



tempX = -tempX / scrollfaktor;

if (tempX >0 )	{		//	tempX r positivt
	tempX = tempX-scrolldelay;		
	if (tempX < 0){
		tempX = 0;
	}
}
		
else if (tempX < 0) {		// om tempX r negativt 
	tempX = tempX+scrolldelay;
	if (tempX > 0){
		tempX = 0; 
	}  
}
  inchLeftRight(0,tempX,langd);

//  document.Show.MouseY.value = tempY;
//  document.Show.MouseX.value = tempX;
  return true;
}

*/


// =========================================================================================================================================================================================
  // Funktioner fr det scrollbara lagret
// =========================================================================================================================================================================================


function startScrollLayer(){
	PGLOADED=true;	
	WNDO[0] = new dw_scrollObj('Layer_Main_Small_Image_List');	
	loadScrLyr(0,'Layer_Moving_Images','t2');
}


var SCRTIMER = 20; 
var SCRTMID=0;	
var MOVR_INC = 1;
var MOVR_INC_FAST = 6;
var PGLOADED=false;
var WNDO = new Array();

dw_scrollObj.prototype.shiftBy=dw_shiftBy;
dw_scrollObj.prototype.shiftTo=dw_shiftTo;
dw_scrollObj.prototype.show=dw_show; 
dw_scrollObj.prototype.hide=dw_hide;
  
  
function inchRight(num,inc,right) {
	
  	if (!PGLOADED||!WNDO[num]) return;
  	if (SCRTMID) clearTimeout(SCRTMID);
  	var y = parseInt(WNDO[num].cnt.css.left);	
  	if (y>-(right)) {		// Layer_Main_Bas bredd 
  		WNDO[num].cnt.shiftBy(-inc,0);
  		SCRTMID = setTimeout("inchRight("+num+","+inc+","+right+")",SCRTIMER);	
  	}
}
  
function inchLeft(num,inc,left) {   // num - lagrets nr 0     inc = hur stort steg, left, 
	
  	if (!PGLOADED||!WNDO[num]) return;
  	if (SCRTMID) clearTimeout(SCRTMID);
  	var y = parseInt(WNDO[num].cnt.css.left);
  	if (y<left) { 
  		WNDO[num].cnt.shiftBy(inc,0);
  		SCRTMID = setTimeout("inchLeft("+num+","+inc+","+left+")",SCRTIMER);	
    }
}

var diff=0;
var smallimagewidth = 122;

function ScrollTo(num,inc,ImageNumber){
	if (!PGLOADED||!WNDO[num]) return;
  	if (SCRTMID) clearTimeout(SCRTMID);
  	var y = parseInt(WNDO[num].cnt.css.left); 

	diff = -(right+y);
	if (y<=0) {    //om Y r mindre n noll dvs man r inte utanfr till vnster
		if (inc > -y){	inc = -y;}
		if(y>=-right){		// och man r inte fr lngt till hger
			
			
			if (inc < diff){ inc = diff;}
			WNDO[num].cnt.shiftBy(inc,0);
			SCRTMID = setTimeout("inchLeftRight("+num+","+inc+","+right+")",20);	
		}else{	//	man har hamnat fr lngt till hger
			stopScroll();
		//	WNDO[num].cnt.shiftTo(-right,0);	
		}
   	}else{		// man har hamnat fr lngt till vnster
		stopScroll();
   		WNDO[num].cnt.shiftTo(0,0);	
   }
	
	
}


function inchLeftRight(num,inc,right) {
	getMouseXY;
  	if (!PGLOADED||!WNDO[num]) return;
  	if (SCRTMID) clearTimeout(SCRTMID);
  	var y = parseInt(WNDO[num].cnt.css.left); 
//	if (y>0){y=0;} 
//	right = 1935;
	
	diff = -(right+y);
	if (y<=0) {    //om Y r mindre n noll dvs man r inte utanfr till vnster
		if (inc > -y){	inc = -y;}
		if(y>=-right){		// och man r inte fr lngt till hger
			
			
			if (inc < diff){ inc = diff;}
			WNDO[num].cnt.shiftBy(inc,0);
			SCRTMID = setTimeout("inchLeftRight("+num+","+inc+","+right+")",20);	
		}else{	//	man har hamnat fr lngt till hger
			stopScroll();
		//	WNDO[num].cnt.shiftTo(-right,0);	
		}
   	}else{		// man har hamnat fr lngt till vnster
		stopScroll();
   		WNDO[num].cnt.shiftTo(0,0);	
   }
}
  
function stopScroll() {
  	clearTimeout(SCRTMID);
  	SCRTMID = 0;
}

  
  function dw_shiftTo(x,y) {
  	if (x!=null) this.x=x; if (y!=null) this.y=y;	
  	if (this.css.moveTo) { 
  		this.css.moveTo(Math.round(this.x),Math.round(this.y)); 
  	} else { 
  		this.css.left=Math.round(this.x)+"px"; 
  	//	this.css.top=Math.round(this.y)+"px"; 
  	}
  }
  
  function dw_shiftBy(x,y) {
  	this.shiftTo(this.x+x,this.y+y);
  }
  
  function loadScrLyr(num,lyr,id) {
  	if (!PGLOADED) return; // avoid not loaded errors
  	if (typeof WNDO[num].cnt != "undefined") WNDO[num].cnt.hide();
  	WNDO[num].cnt = new dw_scrollObj(lyr,id);
  	   WNDO[num].cnt.show();
  	WNDO[num].cnt.shiftTo(0,0);	// restore top/left to 0 
  	WNDO[num].maxX = WNDO[num].cnt.width - WNDO[num].width;
  	WNDO[num].maxY = WNDO[num].cnt.height - WNDO[num].height
  } 
  function getLyrRef(lyr,doc) {
  	if (document.layers) {
  		var theLyr;
  		for (var i=0; i<doc.layers.length; i++) {
  	  	theLyr = doc.layers[i];
  			if (theLyr.name == lyr) return theLyr;
  			else if (theLyr.document.layers.length > 0) 
  	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
  					return theLyr;
  	  }
  		return null;
    }
  }
  
  function dw_scrollObj(obj,id,x,y) {
  	this.el = (document.getElementById)? document.getElementById(obj): (document.all)? document.all[obj]: (document.layers)? getLyrRef(obj,document): null;
  	if (!this.el) return null;
  	this.css = (this.el.style)? this.el.style: this.el;
  	var px = (document.layers||window.opera)? "": "px";
  	this.x = x || 0;	if (x) this.css.left = this.x+px;
  	this.y = y || 0;	if (y) this.css.top = this.y+px;
  	this.width = (this.el.clientWidth)? this.el.clientWidth: (id && document.getElementById && document.getElementById(id).offsetWidth)? document.getElementById(id).offsetWidth: (this.el.offsetWidth)? this.el.offsetWidth: (this.css.clip.width)? this.css.clip.width: 0;
  	this.height = (this.el.offsetHeight)? this.el.offsetHeight: (this.css.clip.height)? this.css.clip.height: 0;
  	this.obj = obj + "Obj"; eval(this.obj+"=this");
  }
  

  function dw_show() {	this.css.visibility = "visible"; }
  function dw_hide() { this.css.visibility = "hidden"; }


  var origWidth, origHeight;
  if (document.layers) {
  	origWidth = window.innerWidth; origHeight = window.innerHeight;
  	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
  }
    
