function loadNewPage(temp) 
{
	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()
{
	var sendform = 1;
	var errortext = "";		
	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;
	if((document.getElementById('epost').value.length<4))
		{
		errortext += "- Your email adress <br>";			
		sendform = 0;	
		}		
	if((document.getElementById('message').value.length<2))
		{
		errortext += "- Message content <br>";			
		sendform = 0;	
		}
	if(sendform==1)
		{
		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,'displayResults'); 
		}
	else
		{
		errortext = "<b>Please fill folowing fields : </b><br>"+errortext;	
		show_form_error(errortext);			
		return 0;
		}
}

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('menutab');
	if(!datacont){return};
	datacont.innerHTML='';
	datacont.innerHTML=userData;
}

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

function displayResults2(userData)
{
	var datacont=document.getElementById('flashbottom');
	//if(!datacont){return};
	datacont.innerHTML='';
	//alert(datacont.innerHTML)
	datacont.innerHTML=userData;
}
function displayResults3()
{
	var datacont=document.getElementById('flashbottom');
	//if(!datacont){return};
	datacont.innerHTML='';
	//alert(datacont.innerHTML)
}

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 sendHttpRequest1(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('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');
}