var aktuell = "maindiv"; // global
var inside = 0;
var kommentar = 1;	//global: vilken kommentar som visas
var nkommentar = 3; //global: antal kommentarer
var openbox = "none";
var box = "";
var pressed = "no";
var currentbox = 0;
// *********************  classen högermeny ****************************
function rightmenu(maxh, namn, anamn)
{
    this.h = 0;
    this.speed = 1;
	this.t;
	this.maxh = maxh;
	this.namn = namn;
	this.anamn = anamn;

}



// ******************** funktionerna för höger menyn ****************
rightmenu.prototype.move = function()    // Define Method
{
		switch (this.namn)
			{
				case "about":
					document.getElementById("omoss").style.background = "url(images/top-pilned.png) no-repeat scroll 0px 50%";
				break
				case "about2":
					document.getElementById("omoss2").style.background = "url(images/top-pilned.png) no-repeat scroll 0px 50%";
				break
				case "contact":
					document.getElementById("kontakt").style.background = "url(images/top-pilned.png) no-repeat scroll 0px 50%";
  				break
				case "ref":
					document.getElementById("referens").style.background = "url(images/top-pilned.png) no-repeat scroll 0px 50%";
  				break
			}


   
		if (this.h < 20){
			this.speed = 20;
		}

		if (this.h > 30 && this.h < 20){
			this.speed = 17;
		}
	
		else if (this.maxh*0.8 < this.h ){
			this.speed = this.speed*0.6;
			
		}
 		this.h += this.speed;
	if (this.h > this.maxh - 4 || this.speed < 0.4){
		this.h = this.maxh;
	}
	document.getElementById(this.namn).style.height=this.h + "px";
	if(this.h < this.maxh){
		setTimeout(this.namn + ".move()", 20);
		
	}else{
		
		this.speed = 1;
	//document.getElementById(this.anamn).style.background = "url(images/plus.png) no-repeat scroll left 7px";	
	switch (this.namn)
			{
				case "about":
					//document.getElementById(this.namn).style.height="auto";
					document.getElementById("omoss").href = "javascript:about.moveup()";
					break
				case "about2":
					document.getElementById("omoss2").href = "javascript:about2.moveup()";
					break
				case "portfolio":
 					document.getElementById("portfolj").href = "javascript:portfolio.moveup()";
					//tb_show('none', 'contact_us.php?keepThis=true&TB_iframe=true&height=800&width=855', 'none');

 					break
				case "contact":
					document.getElementById("kontakt").href = "javascript:contact.moveup()";
  					break
				case "newsarchive":
  					document.getElementById("nyhetsarkiv").href = "javascript:newsarchive.moveup()";
  					break
				case "ref":
					document.getElementById("referens").href = "javascript:ref.moveup()";
  					break
				case "indu":
  					document.getElementById("indumore").href = "javascript:indu.moveup()";
					pressed = "no";
					document.getElementById('indumain').style.background = "url(images/dot.gif) repeat-x scroll left bottom";
  					break
			
			
			}
if (this.anamn == "infobox"){
	openbox = this.namn;
	pressed = "no";
	document.getElementById(this.namn + "b").style.fontWeight = "bold";


	if (this.namn == 'code1' || this.namn == "code2" || this.namn == "code3" || this.namn == "code4" || this.namn == "code5"){
		//document.getElementById('kodning').style.background = "url(images/dot.gif) repeat-x scroll left bottom";
	}
	if (this.namn == 'design1' || this.namn == "design2" || this.namn == "design3" || this.namn == "design4" || this.namn == "design5"){
		//document.getElementById('grafik').style.background = "url(images/dot.gif) repeat-x scroll left bottom";
	}
	if (this.namn == 'seo1' || this.namn == "seo2" || this.namn == "seo3" || this.namn == "seo4" || this.namn == "seo5"){
		//document.getElementById('sokmotor').style.background = "url(images/dot.gif) repeat-x scroll left bottom";
	}
}
	}
	
}

rightmenu.prototype.moveup = function()    // Define Method
{
   switch (this.namn)
			{
				case "about":
					document.getElementById("omoss").style.background = "url(images/top-pilleft.png) no-repeat scroll 0px 45%";
				break
				case "contact":
					document.getElementById("kontakt").style.background = "url(images/top-pilleft.png) no-repeat scroll 0px 45%";
  				break
				case "ref":
					document.getElementById("referens").style.background = "url(images/top-pilleft.png) no-repeat scroll 0px 45%";
  				break
			}

		if (this.h < 20){
			this.speed = this.speed*0.6;
		}	
		else if (this.maxh - 20 < this.h ){
			this.speed = 20;
			
		}else{
			this.speed = 17;

		}
 		this.h -= this.speed;
		if (this.h < 5)
	{
		this.h = 0;
	}
	document.getElementById(this.namn).style.height=this.h + "px";
	
	if(this.h > 0){
		setTimeout(this.namn + ".moveup()", 20);
		
	}
	else{
		this.speed = 1;
		//document.getElementById(this.anamn).style.background = "url(images/dot.png) no-repeat scroll left 7px";
		switch (this.namn)
			{
				case "about":
					document.getElementById(this.anamn).href = "javascript:about.move()";
					break
				case "about2":
					document.getElementById(this.anamn).href = "javascript:about2.move()";
					break
				case "portfolio":
 					document.getElementById("portfolj").href = "javascript:portfolio.move()";
 					break
				case "contact":
  					document.getElementById("kontakt").href = "javascript:contact.move()";
  					break
				case "newsarchive":
  					document.getElementById("nyhetsarkiv").href = "javascript:newsarchive.move()";
  					break
				case "ref":
  					document.getElementById("referens").href = "javascript:ref.move()";
  					break
				case "indu":
  					document.getElementById("indumore").href = "javascript:indu.move()";
					pressed = "no";
					document.getElementById('indumain').style.background = "none";
  					break
			
			
			}


//document.write(oppna);
if (this.anamn == "infobox"){
	
	if (box == 'none'){
	pressed ="no";
	
	}else{
		
		setTimeout(box + ".move()", 30);	
	}



}
	}
}


//  ***********************  visa infobox funktionen  *****************************
rightmenu.prototype.show = function()    // Define Method
{

	if (pressed == "no"){
		pressed ="yes";
		
		document.getElementById(this.namn +"b").style.background = "url(images/top-pilned.png) no-repeat scroll 0px 50%";
		if (openbox == "none"){
			
			setTimeout(this.namn + ".move()", 30);
			

		}else{
			
			box = this.namn;
			if (openbox == this.namn){	
				box = 'none';
			
			}
			document.getElementById(openbox + "b").style.background = "url(images/top-pilleft.png) no-repeat scroll 0px 50%";
			setTimeout(openbox + ".moveup()", 30);
			document.getElementById(openbox + "b").style.fontWeight = "";
			//document.write(this.namn);
			
		}
	}
}


// ************************  skapar objekten med höjd i parantes  *****************
about = new rightmenu(400, 'about', 'omoss');
about2 = new rightmenu(320, 'about2', 'omoss2');
portfolio = new rightmenu(50, 'portfolio', 'portfolj');
contact = new rightmenu(162, 'contact', 'kontakt');
newsarchive = new rightmenu(50, 'newsarchive', 'nyhetsarkiv');
ref = new rightmenu(208, 'ref', 'referens');


design1 = new rightmenu(109, 'design1', 'infobox');
design2 = new rightmenu(60, 'design2', 'infobox');
design3 = new rightmenu(87, 'design3', 'infobox');
design4 = new rightmenu(87, 'design4', 'infobox');
design5 = new rightmenu(100, 'design5', 'infobox');
design6 = new rightmenu(100, 'design6', 'infobox');

seo1 = new rightmenu(73, 'seo1', 'infobox');
seo2 = new rightmenu(96, 'seo2', 'infobox');
seo3 = new rightmenu(123, 'seo3', 'infobox');
seo4 = new rightmenu(110, 'seo4', 'infobox');
seo5 = new rightmenu(189, 'seo5', 'infobox');



indu = new rightmenu(140, 'indu', 'indumore');

// ***********************  byta bild funktionerna  ************************

function remove()
{

		document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";
		document.getElementById("industri").src = "http://www.langustusindustrier.comimages/industri.png";
		document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
		document.getElementById("design").src = "http://www.langustusindustrier.com/design.png";


}

function out()
{
	if (aktuell == "")
	{
		aktuell = "maindiv";
	}

if (inside == 'true'){

}else{
	document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";
	document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri.png";
	document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
	document.getElementById("design").src = "http://www.langustusindustrier.com/images/design.png";

switch (aktuell)
			{
				case "maindiv":
					document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri over.png";

				break
					
				case "codediv":
					document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering over.png";
				break
					
				case "designdiv":
					document.getElementById("design").src = "http://www.langustusindustrier.com/images/design over.png";
				break

				case "seodiv":
					document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo over.png";
				break
							
			}
}
inside = "true";
}

function change(typ)
{
	inside = 1;
	switch (aktuell)
			{
				case "maindiv":
						document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";

	document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
	document.getElementById("design").src = "http://www.langustusindustrier.com/images/design.png";
					
				break

				case "codediv":
					document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";
	document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri.png";

	document.getElementById("design").src = "http://www.langustusindustrier.com/images/design.png";
				break

				case "designdiv":
					document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";
	document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri.png";
	document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
	
				break

				case "seodiv":
					
	document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri.png";
	document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
	document.getElementById("design").src = "http://www.langustusindustrier.com/images/design.png";
				break
							
				default:
					
	document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";
	document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri.png";
	document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
	document.getElementById("design").src = "http://www.langustusindustrier.com/images/design.png";
				break
							
			}


	var bild = typ + " over";
	document.getElementById(typ).src = "http://www.langustusindustrier.com/images/" + bild + ".png";

inside = "false";

}
function changeout(typ)
{
	


}


// ***********************  Ändrar huvud innehlållet  *****************************
function show(typ)
{

aktuell = typ;	
	document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo.png";
	document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri.png";
	document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering.png";
	document.getElementById("design").src = "http://www.langustusindustrier.com/images/design.png";

	if (divObj = document.getElementById("searchdiv"))
	{
		document.getElementById("searchdiv").style.height = "0px";
	}
	
		switch (aktuell)
			{
				case "maindiv":
					document.getElementById("maindiv").style.height = "auto";
					document.getElementById("codediv").style.height = 0 + "px";
					document.getElementById("designdiv").style.height = 0 + "px";
					document.getElementById("seodiv").style.height = 0 + "px";
					document.getElementById("industri").src = "http://www.langustusindustrier.com/images/industri over.png";
					document.getElementById("hake").src = "http://www.langustusindustrier.com/images/Logo-redhake.png";
					
				break

				case "codediv":
					document.getElementById("maindiv").style.height = 0 + "px";
					document.getElementById("codediv").style.height = "auto";
					document.getElementById("designdiv").style.height = 0 + "px";
					document.getElementById("seodiv").style.height = 0 + "px";
					document.getElementById("programmering").src = "http://www.langustusindustrier.com/images/programmering over.png";
					document.getElementById("hake").src = "http://www.langustusindustrier.com/images/Logo-greenhake.png";
				break

				case "designdiv":
					document.getElementById("maindiv").style.height = 0 + "px";
					document.getElementById("codediv").style.height = 0 + "px";
					document.getElementById("designdiv").style.height = "auto";
					document.getElementById("seodiv").style.height = 0 + "px";
					document.getElementById("design").src = "http://www.langustusindustrier.com/images/design over.png";
					document.getElementById("hake").src = "http://www.langustusindustrier.com/images/Logo-bluehake.png";
				break

				case "seodiv":
					document.getElementById("maindiv").style.height = 0 + "px";
					document.getElementById("codediv").style.height = 0 + "px";
					document.getElementById("designdiv").style.height = 0 + "px";
					document.getElementById("seodiv").style.height = "auto";
					document.getElementById("seo").src = "http://www.langustusindustrier.com/images/seo over.png";
					document.getElementById("hake").src = "http://www.langustusindustrier.com/images/Logo-gulhake.png";
				break
				
				default:
					document.getElementById("searchdiv").style.height = "auto";
					document.getElementById("maindiv").style.height = 0 + "px";
					document.getElementById("codediv").style.height = 0 + "px";
					document.getElementById("designdiv").style.height = 0 + "px";
					document.getElementById("seodiv").style.height = 0 + "px";
							
			}


}
//  ******************* hoover scriptet *****************************

function hoverout(id){

//document.getElementById(id).style.background = "url(images/dot.png) no-repeat scroll left 7px";
}

function hover(id){

//document.getElementById(id).style.background = "url(images/plus.png) no-repeat scroll left 7px";



}
// ***********************  Ändrar kommentarena till höger  *****************************
function comment(typ)
{

if (typ == 'next'){
kommentar +=1;
}
if (typ == 'prev'){
kommentar -=1;
}

if (kommentar < 1){
kommentar = nkommentar;
}
if (kommentar > nkommentar){
kommentar = 1;
}
var i = 1;
while (i < nkommentar + 1){
	document.getElementById("comment" + i).style.height = 0 + "px";
	i++;
}
document.getElementById("comment" + kommentar).style.height = "auto";

}



//  ****************** ändra bakgrundscriptet *********************
function bgchange(bg)
{

function removejscssfile(filename, filetype){
	var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from
	var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for
	var allsuspects=document.getElementsByTagName(targetelement)
	for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
		if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
   		allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
 	}
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}






	if (bg == "black"){
	document.getElementById('bg').style.background = "black url(images/background-" + bg + ") fixed no-repeat";
	removejscssfile("style.css", "css") //remove all occurences "somestyle.css" on page	
	loadjscssfile("style-black.css", "css") ////dynamically load and add this .css file
		
	}else{
	removejscssfile("style-black.css", "css") //remove all occurences "somestyle.css" on page	
	loadjscssfile("style.css", "css") ////dynamically load and add this .css file
	document.getElementById('bg').style.background = "url(images/background-" + bg + ") fixed repeat-x";
	//document.getElementById('bg').style.color= "black";
	}


}

// ********************* klockan  *****************************************
function sivamtime() {
  now=new Date();
  hour=now.getHours();
  min=now.getMinutes();
  sec=now.getSeconds();

if (min<=9) { min="0"+min; }
if (sec<=9) { sec="0"+sec; }
time = ((hour<=9) ? "0"+hour : hour) + ":" + min + ":" + sec + " ";

if (document.getElementById) { document.getElementById('theTime').innerHTML = time; }
else if (document.layers) {
 document.layers.theTime.document.write(time);
 document.layers.theTime.document.close(); }

setTimeout("sivamtime()", 1000);
}
window.onload = sivamtime;

// ***********************  fixar skuggorna  *****************************
function shadow(id)
{
var nyhet = id;
var shadow = "shadow" + id;
var height = document.getElementById(nyhet).offsetHeight;
document.getElementById(shadow).style.top = - height - 6 + "px";


      var ua = window.navigator.userAgent
      var msie = ua.indexOf ( "MSIE " )

      if ( msie > 0 )      // If Internet Explorer, return version number
        var version = (ua.substring (msie+5, ua.indexOf (".", msie )));
		
		if (version == 8){
		
		document.getElementById(shadow).style.visibility = 'hidden';	
		}
	 

}


//  *************************************  checkbox scriptet  ***************************************



function menuarrow(typ)
{

	if (currentbox > 0)
	{
	document.getElementById("amenuarrow"+currentbox).style.background = "url(images/menuarrow.gif) no-repeat scroll right";
currentbox++;
	document.getElementById("amenuarrow"+currentbox).style.background = "url(images/menuarrow.gif) no-repeat scroll right";
currentbox = currentbox -1;
	}
if (currentbox == 0)
	{
currentbox++;
	document.getElementById("amenuarrow"+currentbox).style.background = "url(images/menuarrow.gif) no-repeat scroll right";
currentbox = currentbox -1;
	}
	if (typ > 1)
	{
	
 typ -= 1;
// alert("amenuarrow"+typ);
 //document.getElementById("amenuarrow" + typ).style.background = 'background: url("images/menuarrow-grey-invert.gif") scroll right no-repeat';
	document.getElementById("amenuarrow"+typ).style.background = "url(images/menuarrow-grey-invert.gif) no-repeat scroll right";
	}
}

function menuarrowout(typ)
{
if (currentbox == 0)
	{
currentbox++;
		document.getElementById("amenuarrow"+currentbox).style.background = "#e3e3e3 url(images/menuarrow-grey.gif) no-repeat scroll right";
		currentbox = currentbox -1;
	}

	if (typ > 1)
	{
	
 typ -= 1;
 //alert(typ);
 //document.getElementById("amenuarrow" + typ).style.background = 'background: url("images/menuarrow.gif") scroll right no-repeat';
 	document.getElementById("amenuarrow"+typ).style.background = "url(images/menuarrow.gif) no-repeat scroll right";
	if (currentbox > 0)
	{
		document.getElementById("amenuarrow"+currentbox).style.background = "url(images/menuarrow-grey-invert.gif) no-repeat scroll right";
		currentbox++;
		document.getElementById("amenuarrow"+currentbox).style.background = "#e3e3e3 url(images/menuarrow-grey.gif) no-repeat scroll right";
		
		currentbox = currentbox -1;
	}
	
	}
}

function showseobox(typ)
{
	if (currentbox > 0)
	{
	document.getElementById("amenuarrow"+currentbox).style.background = "url(images/menuarrow.gif) no-repeat scroll right";
	}
	currentbox = typ - 1;
for (i=1;i<=5;i++)
{
	document.getElementById("seobox"+i).style.visibility = "hidden";
	document.getElementById("seobox"+i).style.height = "0";

	
}
	
	document.getElementById("seobox"+typ).style.visibility = "visible";
	document.getElementById("seobox"+typ).style.height = "auto";
	

}

function loginclient()
{
document.getElementById("client").style.visibility = "visible";
document.getElementById("client1").href = "javascript: loginclient1()";
document.getElementById("member").style.visibility = "hidden";
document.getElementById("member1").href = "javascript: loginmember()";
}
function loginclient1()
{
document.getElementById("client").style.visibility = "hidden";
document.getElementById("client1").href = "javascript: loginclient()";
}

function loginmember()
{
document.getElementById("member").style.visibility = "visible";
document.getElementById("member1").href = "javascript: loginmember1()";
document.getElementById("client").style.visibility = "hidden";
document.getElementById("client1").href = "javascript: loginclient()";
}
function loginmember1()
{
document.getElementById("member").style.visibility = "hidden";
document.getElementById("member1").href = "javascript: loginmember()";
}

