function loadNewPage(temp) 
{
	if(temp=='page8.php')
		sendHttpRequest('mail2.php','displayResults2');
	else
		sendHttpRequest('mailpic.php','displayResults2');
	sendHttpRequest(temp,'displayResults1');	
}

function loadGallery(temp)
{
	sendHttpRequest(temp,'displayResults1');
	document.getElementById("text").style.width = "735px";
	document.getElementById("photo").style.display = "none";
	document.getElementById('submenu').style.display="none";
}

function removeElement(divNum) 
{
	var d = document.getElementById('contain');
	var olddiv = document.getElementById(divNum);
	d.removeChild(olddiv);
}

function addElement() 
{
	document.getElementById("photo").style.display = "block";
	document.getElementById("text").style.width="590px";  
}

function check_fields()
{
		if((document.getElementById('epost').value.length<4)||(document.getElementById('epost').value==" E-post...")){
		
		alert('Please enter valid email adsress');
		return false;
		//errortext += "- Your email adress <br>";			
		//sendform = 0;	
			
		}		
		
		if((document.getElementById('message').value.length<2)||(document.getElementById('message').value=="Arende...")){

		alert('Please enter message text');			
		return false;	
			
		}
		var message = document.getElementById('message').value;
		var visitoremail = document.getElementById('epost').value;
		var name = document.getElementById('namn').value;
		var subject = document.getElementById('foretag').value;
		var mobile = document.getElementById('mobil').value;
		//var phone = document.getElementById('telefon').value;
		var url1="sendemail.php?message="+message;
		url1=url1+"&visemail="+visitoremail;
		url1=url1+"&name="+name;
		url1=url1+"&subject="+subject;
		//url1=url1+"&phone="+phone;
		url1=url1+"&mobile="+mobile;
		sendHttpRequest(url1,'displayResults2'); 
		
	
}

function show_form_error(error)
{
	table=document.getElementById("photo");
	table.innerHTML = "<font style='color: #444444;  font: bold 12px Palatino Linotype; '>"+ error +" </font>";
}
		
function displayResults(userData)
{
	var datacont=document.getElementById('rcontmail');
	if(!datacont){return};
	datacont.innerHTML='';
	alert('assadsadasd')
	datacont.innerHTML="<font style='font : italic 13px Century Gothic; color: #A0A0A0;'>"+userData+" </font>";
}

function displayResults1(userData)
{
	var datacont=document.getElementById('leftcontainer');
	if(!datacont){return};
	datacont.innerHTML='';
	datacont.innerHTML=userData;
}

function displayResults2(userData)
{
	var datacont=document.getElementById('mailcon');
	if(!datacont){return};
	datacont.innerHTML='';
	datacont.innerHTML=userData;
}

function sendHttpRequest(url,callbackFunc,respXml)
{
	var xmlobj=null;
	try
		{
		xmlobj=new XMLHttpRequest();
		}
	catch(e)
		{
		try
			{
			xmlobj=new ActiveXObject("Microsoft.XMLHTTP");
			}
		catch(e)
			{
			alert('AJAX is not supported by your browser!');
			return false;
			}
		} 
	xmlobj.onreadystatechange=function(){
	if(xmlobj.readyState==4)
		{
		if(xmlobj.status==200)
			{
				
			respXml?eval(callbackFunc+'(xmlobj.responseXML)'):eval(callbackFunc+'(xmlobj.responseText)');
			
			
			}
		}

	}
	// open socket connection
	xmlobj.open('GET',url,true);
	// send http header
	xmlobj.setRequestHeader('Content-Type','plain/text; charset=UTF-8');
	// send http request
 	xmlobj.send(null);
}

function roll_over(img_name, img_src)
{
  
   document[img_name].src = img_src;
}// JavaScript Document
function browser_det()
{
	var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
	var data = browser + ' ';
	verdata = b_version.split(";");
	if(verdata[1]==' MSIE 6.0')
		{
		document.getElementById('page').style.backgroundImage = "none";
		document.getElementById('page').style.backgroundRepeat = "no-repeat";
		document.getElementById('page').style.backgroundColor = "#FFFFFF";
		document.getElementById('bottomborder').style.display = "none";
		document.getElementById('text').style.marginLeft = "22px";
		document.getElementById('photo').style.marginRight= "23px";
		document.getElementById('bottom').style.marginTop= "10px";
		document.getElementById('bottom').style.marginLeft= "100px";
		}
	if(browser=='Netscape')
		{
		document.getElementById('image').style.marginTop = "125px";
		document.getElementById('bottombrd').style.marginTop = "800px";
		//document.getElementById('page').style.marginTop = "-650px";
		
		//document.getElementById('bottomborder').style.width = "904px";
		}
}
function toggleLayer( whichLayer )
{  
	var elem, vis;  
	if( document.getElementById ) 
	// this is the way the standards work    
	elem = document.getElementById( whichLayer );  
	else if( document.all ) 
	// this is the way old msie versions work      e
	lem = document.all[whichLayer];  
	else if( document.layers ) 
	// this is the way nn4 works   
	elem = document.layers[whichLayer];  
	vis = elem.style;  
	//if the style.display value is blank we try to figure it out here 
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)   
	vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
	loadNewPage('page3.php');
}