<!-- Original:  CodeLifter.com (support@codelifter.com) -->
<!-- Web Site:  http://www.codelifter.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
// Set slideShowSpeed (milliseconds)
/*var slideShowSpeed = 3000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below

/*Pic[0] = 'bilder/5.jpg'
Pic[1] = 'bilder/2.jpg'
Pic[2] = 'bilder/3.jpg'
Pic[3] = 'bilder/4.jpg'
Pic[4] = 'bilder/1.gif'
Pic[5] = 'bilder/6.jpg'
Pic[6] = 'bilder/7.jpg'
Pic[7] = 'bilder/8.jpg'
Pic[8] = 'bilder/9.jpg'
Pic[9] = 'bilder/10.jpg'*/

/*Pic[0] = 'css/start3.jpg'
Pic[1] = 'css/Vaxel2.jpg'
Pic[2] = 'css/hundkatt2.jpg'*/

/*Pic[0] = '../img/welcome.jpg'
Pic[1] = '../img/welcome_with_dog.jpg'*/
/*Pic[2] = 'img/bgStart5.jpg'
Pic[3] = 'img/butik_storbild.jpg'
Pic[4] = 'img/bgStart3.jpg'
Pic[5] = 'img/reception_storbild.jpg'*/

// do not edit anything below this line
/*var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}*/
function runSlideShow() 
{
	alert("HEJ");
	var slideShowSpeed = 3000;
	var crossFadeDuration = 3;
	var Pic = new Array();
	var t;
	var j = 0;
	var p = Pic.length;
	var preLoad = new Array();
	alert("BLA");
	for (i = 0; i < p; i++) {
	preLoad[i] = new Image();
	preLoad[i].src = Pic[i];
	
	}
	Pic[0] = '../img/welcome.jpg'
	Pic[1] = '../img/welcome_with_dog.jpg'
	
	
	if (document.all && 1==2) 
	{
		alert("if");
		document.images.SlideShow.style.filter="blendTrans(duration=2)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	else
	{
		alert("else");
		document.getElementById("welcome").filter="blendTrans(duration=2)";
		document.getElementById("welcome").filter="blendTrans(duration=crossFadeDuration)";
		
		//document.getElementById("welcome").filters.blendTrans.Apply();
		alert("BLA2");
	}
	
	//document.images.SlideShow.src = preLoad[j].src;
	document.getElementById("welcome").style.backgroundImage="url('welcome_with_dog.jpg');";
	//document.getElementById('col3').style.backgroundImage = "url(images/col3-bg" + rand + ".jpg);";
	/*document.getElementById("welcome").style.backgroundImage=preLoad[j].src;
	if (document.all && 1==2) 
	{
		alert("if");
		document.images.SlideShow.filters.blendTrans.Play();
	}
	else
	{
		alert("else");
		document.getElementById("welcome").filters.blendTrans.Play();
	}
	
	j = j + 1;
	if (j > (p - 1)) j = 0;
		t = setTimeout('runSlideShow()', slideShowSpeed);*/
}
//  End -->

function popitup(url)
{
	newwindow=window.open(url,'name','height=400,width=300, resizable=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popitup2(url)
{
	 var arr = showModalDialog(url,"","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em" );
     if (arr != null) cmdExec("ForeColor",arr);     
}

//VISAR BILDVAL
function changeImage(id, id2)
{
	if (id=='imglink')
	{
		var box=eval(document.all.imglink);
		document.bild2.src ='Bilder/'+box.options[box.selectedIndex].value;
	}
	else if (id=='img')
	{
		var box=eval(document.all.img);
		document.bild3.src ='Bilder/'+box.options[box.selectedIndex].value;
		document.bild4.src ='Bilder/'+box.options[box.selectedIndex].value;
	}
	else if (id=='new_imglink')
	{
		var box=eval(document.all.new_imglink);
		document.new_bild2.src ='Bilder/'+box.options[box.selectedIndex].value;
	}

}
//INFORGAR DIV

function createDIV2()
{
	var newDiv = document.createElement('DIV'); // Skapa div 

    //newDiv.addBehavior("HTC/file.htc") // Lägg till behaviour 
            
    with(newDiv.style) // CSS 
    { 
        //position = "absolute"; 
        //left = 300;//event.offsetX; 
        //top = 300;//event.offsetY; 
        width = 200; 
        height = 100; 
        background:"#e8e8e8";
        borderStyle = "dashed"; 
        borderColor =  "#999999"; 
        borderWidth = 1 + "px"; 
    } 
    newDiv.setAttribute("contentEditable","true");
    //var editor=document.getElementById("memoTool3);
    //editor.appendChild(newDiv);
    document.body.appendChild(newDiv); // Klistra in 

}
function doRule() 

{ 

document.execCommand('inserthorizontalrule', false, null); 

}
function createDIV()
{
//document.getElementById("memoTool3").insertAdjacentHTML("beforeEnd",'<span style="border:1px dotted #000000;width:150">red bg</span>')
alert("HEJ");
var sel = document.selection;

if (sel!=null) 
{
    var rng = sel.createRange();
    if (rng!=null)
    {
        rng.pasteHTML("<span class='box'>Skriv text här...</span>");
        //rng.setAttribute("contentEditable","true");
    }
}
}
function createDIV4()
{
var sText = document.selection.createRange();
sText.pasteHTML("<span>Skriv din text här...</span>");
var txt=document.getElementById("1");
txt.style.width=100;
txt.style.height=100;
txt.setAttribute("contentEditable","true");
}
function createDIV3()
{
	
//var txt=document.getElementById("divtext");
//var t=getText();
var oNewNode= document.createTextNode("Detta är texten");
var txt=document.body.createControlRange();

txt.add(oNewNode);
    txt.select();
/*
if (txt!=null)
{
	txt.pasteHTML("<span class=textbox>Skriv din text här...</span>");
}*/
//var newPara = document.createElement("span");
//var newText = document.createTextNode("Detta är texten");
//newPara.appendChild(newText);
//var spanRef = document.getElementsByTagName("body").item(0);
//var spanRef=document.getElementById("memoTool3")
//newPara.setAttribute("class","textbox");
//spanRef.appendChild(newPara);
//newPara.style.backgroundColor="#e8e8e8";

//newPara.setAttribute("contentEditable","true");

//bodyRef.appendChild(newPara);


}
//VISA INMATNINGSFÄLT EFTER COMBOVAL
function check(id)
{


	//var box=eval(document.all.new_visapos);
	var box=eval(id);
	
	
	if (box.name=="new_visapos")
	{
		s0="new_sublink0";
		s1="new_sublink1";
		s2="new_sublink2";
		s3="new_sublink3";
		s4="Select4";
		s5="Select5";
	}
	else if (box.name=="visapos")
	{
		s0="sublink0";
		s1="sublink1";
		s2="sublink2";
		s3="sublink3";
		s4="Select8";
		s5="Select9";
	}
	if (box.options[box.selectedIndex].value==2)
	{
		document.getElementById(s2).style.display='block';
		document.getElementById(s3).style.display='block';
		document.getElementById(s0).style.display='none';
		document.getElementById(s1).style.display='none';
	}
	else if (box.options[box.selectedIndex].value==5)
	{
		document.getElementById(s0).style.display='block';
		document.getElementById(s1).style.display='block';
		document.getElementById(s2).style.display='block';
		document.getElementById(s3).style.display='block';
	}
	else
	{
		document.getElementById(s0).style.display='none';
		document.getElementById(s1).style.display='none';
		document.getElementById(s2).style.display='none';
		document.getElementById(s3).style.display='none';
		document.getElementById(s4).value="";
		document.getElementById(s5).value="";
		document.bild2.src="";
	}
}

//HÄMTA TEXT FRÅN DIV TILL TEXTAREA FÖR UPPDATERING
function getText()
{
	//HÄMTA FRÅN TEXTOMRÅDE
	updateform.cont.value=memoTool3.innerHTML;
	//HÄMTA FRÅN BILDOMRÅDE
	updateform.pic.value=pictures.innerHTML;
	//SKICKA FORMULÄRDATA FÖR UPPDATERING
	document.updateform.submit();
}

/*******************EDITOR_FUNKTIONER************************/

//LÄGG TILL BILD
function InsertImage()
{
	doRule();
	var box=eval(document.all.img);
	opener.document.execCommand("InsertImage", false, 'Bilder/'+box.options[box.selectedIndex].value);
	adjustimage(box.options[box.selectedIndex].value);
}
function createLink2()
{
 var arr = showModalDialog("popupex2.asp","","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em" );
 if (arr != null) cmdExec("ForeColor",arr); 
    
}

function openExternLink(URI)
{
p="'"+URI+"'"
win = window.open(URI,"secWin","width=500,height=300,left=100,scrollbars=yes,resiz able=yes,location=yes");
win.focus();
}

function createLink()
{
//var sText = opener.document.selection.createRange();
var sText = document.selection.createRange();
	alert(sText.value);
	for (i=0;i<document.all.radio.length;i++)
	{
		if (document.all.radio[i].checked)
		{
			user_input = document.all.radio[i].value;
		}
	}
		
	if (sText.text!="")
	{
		if (user_input=='intern')
		{
			
			var box=eval(document.all.linkparent);
			pid=box.options[box.selectedIndex].value;
			//opener.document.execCommand("CreateLink",false,"default.asp?pid="+pid);
			document.execCommand("CreateLink",false,"default.asp?pid="+pid);
			alert("Länken är infogad. För att spara tryck på knappen update");
			//document.getElementById('insertLink').style.visibility='hidden';
		}
		else
		{
			url="http://" + document.all.linkdest.value;
			url2 = "javascript:openExternLink('" + url + "');";
			//alert(url+' '+url2);
			//opener.document.execCommand("CreateLink",false,url2);
			opener.document.execCommand("CreateLink",true);
			
			//opener.document.memoTool3.focus();
			alert(sText.parentElement().tagName);
			sText.setAttribute("target","_blank");
			if (sText.parentElement().tagName == "A")
			{
				sText.parentElement().setAttribute("target", "_blank");

				//sText.parentElement().target="_blank";
				//sText.parentElement().innerText=sText.parentElement().href;
			}
			alert("Länken är infogad. För att spara tryck på knappen update");
				
			
			//document.getElementById('insertLink').style.visibility='hidden';
			//InsertLink();
		}
	}
	else
		alert("Inget element är markerat. Markera text eller bild och försök igen");
	
	

}
function getParentElement()
{

var sText = document.selection.createRange();
alert(sText.text);

}
function checkLink(typ)
{
	
	if (typ=='intern')
	{
		document.getElementById("internlink").style.display='block';
		document.getElementById("linkparent").style.display='block';
		document.getElementById("externlink").style.display='none';
	}
	else
	{
		document.getElementById("internlink").style.display='none';
		document.getElementById("linkparent").style.display='none';
		document.getElementById("externlink").style.display='block';
		
	}

}
function openLink(h)
{
	win = window.open("createLink.asp","Länkar","width=500,height=350,left=100,scrollbars=yes,resizable=yes,location=yes");
	//document.getElementById('insertLink').style.visibility='visible';
	//document.getElementById('insertLink').style.height=150;
}
//LÄGG TILL LÄNK
function InsertLink() 
{
	
	var sText = document.selection.createRange();

	if (!sText=="")
	{
		url="http://"+document.all.linkdest.value;
		
		//Create link
		document.execCommand("CreateLink");
		alert(sText.parentElement().tagName);
		//Replace text with URL
		if (sText.parentElement().tagName == "A")
		{
			sText.parentElement().target="_blank";
			//sText.parentElement().innerText=sText.parentElement().href;
		}    
	}
	else
	{
		alert("Markera texten som ska vara länktext");
	}   
	

}

//LÄGG TILL RAM PÅ BILD
function adjustimage(n){
var range = document.selection.createRange();



/* Check if one object is selected */
	if (range.length == 1 && (range(0).tagName == 'IMG' || range(0).tagName == 'img'))
	{
	//alert(range(0).name);
	//range(0).align = 'right';
	//range(0).align='right';
	//range(0).hspace='0';
	//range(0).vspace='0';
	//range(0).name=n;
	//range(0).width=range(0).width+10;
	range(0).name=n;
	return true;
	}
}

//ÄNDRA TECKENSTORLEK
function changeFontSize()
{
	var box=eval(document.all.fontsize);
	alert(box.options[box.selectedIndex].value);
	document.execCommand('FontSize', false, box.options[box.selectedIndex].value);

} 

/***********************************************************************/

var palettTimeout;
function startTimerPalett(id)
{
		palettTimeout = setTimeout("closePalette('" + id + "')",1);
}
function stopPalettTimer()
{
		clearTimeout(palettTimeout);
}
function openPalette(id)
{
if (id=="palett")
{
document.getElementById(id).style.top='212px';
document.getElementById(id).style.left='740px';
}
else
{
document.getElementById(id).style.top='212px';
document.getElementById(id).style.left='770px';
}
document.getElementById(id).style.visibility='visible';
}
function closePalette(id)
{

document.getElementById(id).style.visibility='';
}
function ChangeForeColor(id, color)
{
//var range = document.selection.createRange();
var txt = document.selection.createRange().text;
document.execCommand('ForeColor','false',color);


//document.getElementById(id).style.background=color;
}

function ChangeBackColor(id, color)
{
//var range = document.selection.createRange();
var txt = document.selection.createRange();

alert(txt.parentElement().id);
if (!txt=="")
	if (txt.parentElement().tagName == "div")
		alert("HEJ");
//document.execCommand('BackColor','false',color);
document.execCommand('BackColor','true');

//document.getElementById(id).style.background=color;
}

function openMenu(id)
{
var obj=document.getElementById(id);
	for (var i=1;i<=3;i++)
	{
		
		if (document.getElementById('editarea'+i))
		{
			
			document.getElementById('editarea'+i).style.display='none';
		}
	}

	if (obj)
	{
		
		obj.style.display='block';
	}

	
}

function openPicture()
{
document.getElementById('large').style.visibility='visible';


}
function closePicture()
{
document.getElementById('large').style.visibility='hidden';
}
function editSite()
{
document.getElementById('editSite').style.visibility='visible';

}
function newSite()
{
document.getElementById('newSite').style.visibility='visible';

}
function insertImage()
{
document.getElementById('insertImage').style.visibility='visible';
document.getElementById('insertImage').style.height=150;

}
function openSettings()
{
document.getElementById('Setting').style.visibility='visible';


}
function closeBox(id)
{
document.getElementById(id).style.visibility='hidden';

}
function getHTML()
{
alert(memoTool3.innerHTML);
alert(pictures.innerHTML);

//document.getElementById('html').style.visibility='visible';


}
function deletesite(pid)
{
var user=confirm("Vill du ta bort sidan?");

	if (user==true)
	{
		document.deleteform.submit();
		return true;
		
	}
	else
		return false;
}