	
function doSearch()
{
	var sForm = document.getElementById("frmSearch")
	if( sForm )
	{
		sForm.method = "get";
		
		if( sForm.txtSearch.value != "" )
		{
			sForm.submit();
		}
		else
		{
			alert("Din sökning måste innehålla minst ett tecken.");
		}
	}
}

function positionize()
{	
	var sBottomBar = document.getElementById("bottomBar");
	var sInfoBox   = document.getElementById("infoBox");
	
	if( sBottomBar && sInfoBox )
	{ 
		//Visas bara om den innehåller text
		if( sInfoBox.innerText )
		{
			if( sInfoBox.innerText.length > 1 ) 
			{
				sInfoBox.style.top = sBottomBar.offsetTop - 161;
				sInfoBox.style.visibility = "visible";
			}
		}
	}
		
}

function openLoginWin()
{
	var w = window.open('login.aspx', 'Login', 'width=540,height=460,dependent');
		w.focus();
}

function openWebshopInfoWin()
{
	var w = window.open('info.htm', 'Information', 'width=440,height=260,dependent');
		w.focus();
}

function checkOut(CheckoutLink)
{
	//location.href = location.pathname + "?checkout=true";
	location.href = CheckoutLink + "?checkout=true";
}

function checkOrderForm()
{

	if( document.OrderForm.antal.value > 0)
		document.OrderForm.submit();
	else
		alert('Du måste ange hur många Du vill beställa.');
}

function updateOrderForm()
{
	var sAction = location.href;
	var sNyttAntal = "";
	var i;
	
	if( sAction.indexOf( "?" ) > 0 )
	{
		if( document.OrderForm.NyttAntal.length > 0)
		{
			for (i = 0; i < document.OrderForm.NyttAntal.length; i++)
			{
				sNyttAntal = sNyttAntal + "," + document.OrderForm.NyttAntal[i].value;
			}
					
			if( sNyttAntal.indexOf( ",", 1 ) > 0 )
				sNyttAntal = sNyttAntal.substr( 1 );
		}
		
		else
		{
			sNyttAntal = document.OrderForm.NyttAntal.value;
		}
		
		//location.href = sAction + "&DoUpdate=true&NyttAntal=" + sNyttAntal;
		location.href = location.pathname + "?checkout=true&DoUpdate=true&NyttAntal=" + sNyttAntal;
	}
}

function sendOrderForm()
{
	var sAction		= location.pathname;
	var sNamn		= document.OrderForm.namn;
	var sEmail		= document.OrderForm.email;
	var sMeddelande = document.OrderForm.meddelande;
	
	if( sNamn.value == "" )
	{
		alert( "Du måste ange ett namn som referens." );
		sNamn.focus()
	}
	else if( sEmail.value == "" )
	{
		alert( "Du måste ange en emailadress." )
		sEmail.focus();
	}
	else
	{
		if( sEmail.value.indexOf( "@" ) > 0 )
		{
			if( sAction.indexOf( "?" ) > 0 )
				sAction += "&";
			else
				sAction += "?";
			
			sAction += "DoCheckout=true&namn=" + sNamn.value + "&email=" + sEmail.value + "&meddelande=" + sMeddelande.value;
				
			location.href = sAction;
		}
		else
		{
			alert( "Den angivna emailadressen: " + sEmail.value + " är inte en giltig adress." );
			sEmail.focus();
		}
	}
}

function moveUser()
{
	setTimeout( 'doMoveUser()', 5000 );
}

function doMoveUser()
{
	var sStartPage = document.URL;
		sStartPage = sStartPage.substr( 0, sStartPage.lastIndexOf( "/" ) + 1 ); 
		sStartPage = sStartPage + "323.htm";
	//alert( sStartPage );
	//location.href = "../";
	//top.main.location.href = sStartPage;
	location.href = sStartPage;
}

function showNewsArchive()
{
	var sArchive = document.getElementById("pArchive");
		sArchive.style.visibility = "visible";
		sArchive.style.display = "";
	
	positionize();
}

function ToggleCategory( DivID )
{
	//Visa div och byt bild...
	var sDiv = document.getElementById("dCategory"+DivID);
	var sImage = document.getElementById("imgSeparator"+DivID);
	
	if( sDiv.style.visibility == "visible" )
	{
		sDiv.style.visibility = "hidden";
		sDiv.style.display = "none";
		
		sImage.src = "images/common/plus.gif";
	}
	else
	{
		sDiv.style.visibility = "visible";
		sDiv.style.display = "";
		
		sImage.src = "images/common/minus.gif";
	}
}

function logOut()
{
	var w = window.open('logout.aspx', 'Logout', 'width=1,height=1,dependent');
		w.focus();
}

function checkCustomer( iPageID, sChildID )
{
	var vAllTags = document.getElementsByTagName("input");
	var bSubmit = true;
	
	for( var i = 0; i < vAllTags.length; i++ )
	{
		if( vAllTags[i].name.substr(0,3) == "txt" )
		{
			if( vAllTags[i].value.length == 0 )
			{
				alert( "Du måste fylla i " + vAllTags[i].name.substr(3) );
				vAllTags[i].focus();
				bSubmit = false;
				break;
			}
		}
	}
	
	if( bSubmit )
	{
		/*if( sChildID.length == 0 )
			document.forms[0].action = iPageID + ".htm?showSummary=true";
		else
			document.forms[0].action = iPageID + "_" + sChildID + ".htm?showSummary=true";
		
		alert(document.forms[0].action);*/
		document.forms[0].submit();
	}
	
/*	var bSubmit = true;
	
	if( document.getElementById("txtCompany").value.length == 0 )
		bSubmit = false;*/
}

function startImagePlay( Delay )
{
	//alert("inne i startImagePlay");
	var oImage1 = document.getElementById("imgPlayObject1");
	var oImage2 = document.getElementById("imgPlayObject2");;
	var oImage3 = document.getElementById("imgPlayObject3");;

	//Starta animering om alla bilder finns...
	if( oImage1 && oImage2 && oImage3 )
	{
		if( oImage1.style.visibility == "visible" )
		{
			//Dölj ettan...
			oImage1.style.visibility = "hidden";
			oImage1.style.display = "none";
			
			//Visa tvåan...
			oImage2.style.visibility = "visible";
			oImage2.style.display = "";
		}
		else if( oImage2.style.visibility == "visible" )
		{
			//Dölj tvåan...
			oImage2.style.visibility = "hidden";
			oImage2.style.display = "none";
			
			//Visa trean...
			oImage3.style.visibility = "visible";
			oImage3.style.display = "";
		}
		else if( oImage3.style.visibility == "visible" )
		{
			//Dölj trean...
			oImage3.style.visibility = "hidden";
			oImage3.style.display = "none";
			
			//Visa ettan...
			oImage1.style.visibility = "visible";
			oImage1.style.display = "";
		}
				
		setTimeout( "startImagePlay('" + Delay + "')", parseInt( Delay ) );
	}
}

function checkMailForm()
{
	var sForm = document.getElementById("mailform");
	var bSubmit = true;
	
	if( typeof( sForm ) == "object" )
	{
		sForm.method = "post";
			
		for( var i = 0; i < sForm.length; i++ )
		{
			if( sForm[ i ].value.indexOf( "<" ) > -1 )
			{
				alert( "Fältet innehåller otillåtna tecken!" );
				bSubmit = false;
				sForm[ i ].focus();
			}
		}
		
		if( bSubmit )
			sForm.submit();
	}
}

function checkAddNewsLetterUser( LanguageID )
{
	var sForm;
		sForm = document.getElementById("addNewsLetterUser");
		
	var sAlertText;
	
	switch( LanguageID )
	{
		case 1:
			sAlertText = "E-postadressen är inte korrekt."
			break;
			
		default:
			sAlertText = "E-postadressen är inte korrekt."
			break;
	}
	
	if( sForm.email.value.length == 0 )
	{
		sForm.email.focus();
		alert( sAlertText );
	}
	else
	{	
		if( IsEmailValid( sForm.email.value ) )
			window.open("addNewsLetterUser.asp?email="+ sForm.email.value +"&todo=add&name="+ sForm.name.value + "&LanguageID=" + LanguageID,'NewsLetterUser', 'menubar=no,resizable=no,width=300,height=400,titlebar=no,alwaysRaised=yes,status=no,scrollbars=yes,left='+(screen.width/2-300/2)+',top='+(screen.height/2-200/2-200/10)+',screenX=0,screenY=0');
		else
		{
			sForm.email.focus();
			alert( sAlertText );
		}
	}
}

function IsEmailValid( sEmail )
{
	var objRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return objRegExp.test( sEmail );
}

function AddNewsLetterUser()
{
	var sForm;
		sForm = document.getElementById("addNewsLetterUser");
		
	if( sForm )
	{
		if( sForm.email.value.length == 0 )
		{
			alert( "Du måste ange en e-postadress." );
			sForm.email.focus();
		}
		
		if( sForm.name.value.length == 0 )
		{
			//alert( "Du måste ange ett namn." );
			sForm.name.focus();
		}
		
		else
		{
			if( IsEmailValid( sForm.email.value ) )
			{
				//sForm.action = "addNewsLetterUser.asp?email="+ sForm.email.value +"&todo=doAdd&name="+ sForm.name.value;
				sForm.action = "addNewsLetterUser.asp"
				sForm.submit();
			}
			else
				alert( "E-postadressen är inte korrekt." );
		}
	}	
}

var gSelectedTRMenuItem; 

function clickTRMenuItem(objTR)
{
	if(typeof(gSelectedTRMenuItem) != 'undefined'){
		gSelectedTRMenuItem.style.backgroundColor = '';
	}
	gSelectedTRMenuItem = objTR;
}
function overTRMenuItem(objTR,menuItemName)
{
	objTR.style.backgroundColor = '#566478';
	window.defaultStatus = menuItemName; 
	objTR.style.cursor='pointer'; 
}

function outTRMenuItem(objTR)
{
	if(objTR != gSelectedTRMenuItem){
		objTR.style.backgroundColor = '';
		window.defaultStatus='';
	}
}

