setInterval( "refreshSession();", 1000 * 60 * 15 );

function refreshSession()
{
	var xmlHttp = null;
	if( window.XMLHttpRequest )
	{ // code for IE7+, Firefox, Chrome, Opera, Safari
		xmlHttp = new XMLHttpRequest();
	}
	else
	{ // code for IE6, IE5
		xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
	}
		
	if( xmlHttp != null )
	{
		xmlHttp.open( 'GET', "/refreshSession/", true );
		xmlHttp.send( null );
	}
}
function doIdAction( form, action, id )
{
	var f = document.getElementById( form );
	f.action.value = action;
	f.id.value = id;
	f.submit();
}
function doAction( form, action )
{
	var f = document.getElementById( form );
	f.action.value = action;
	f.submit();
}
function confirmAction( q, form, action )
{
	if( confirm( q ) )
	{
		doAction( form, action );
	}
	return false;
}
function confirmIdAction( q, form, action, id )
{
	if( confirm( q ) )
	{
		doIdAction( form, action, id );
	}
	return false;
}
function doUpdateAction( form, id, from, to )
{
	var f = document.getElementById( form );
	f.action.value = 'updateField';
	f.id.value = id;
	f.from.value = from;
	f.to.value = to;
	f.submit();
}	
function stopEvent( event )
{
	if( window.event != null )
	{
		window.event.cancelBubble = true;
	}
	if( event != null )
	{
		if( event.stopPropagation )	event.stopPropagation();
		event.cancelBubble = true;
	}
}

function openNew( event, link )
{
	if( window.event != null )
	{
		window.event.cancelBubble = true;
		window.open( link, '_blank' );
	}
	if( event != null )
	{
		event.cancelBubble = true;
		if( event.stopPropagation )	event.stopPropagation();
		if( window.event == null )	window.open( link, '_blank' );
	}
}
function doAdSearch() {
	var searchValue = $('adNameSearch').value;
	if( searchValue != "" )
	{
		window.location='?s=annonser&sub=aktivaannonser&adNameSearch=' + encodeURIComponent( searchValue );
	}
}
function switch_vis(which) {
	if (Element.visible(document.getElementById(which))==false){
		new Effect.BlindDown(which);
	}else{
		new Effect.BlindUp(which);
	}

}

function changeName(which,div) {
	if (Element.visible(document.getElementById(which))==false){
		document.getElementById(div).innerHTML = 'Dölj'
	}else{
		document.getElementById(div).innerHTML = 'Visa fler'
	}
	
}
function preview(elemid)
  { cp = document.getElementById('CP');
    for(var i=0; i<cp.childNodes.length; i++) cp.childNodes[i].className = 'search_div_none'; 
    document.getElementById(elemid).className = 'search_div_show';
   

  }

function switch_style(which,span){
	
	if (Element.visible(document.getElementById(which))==false){
		new Effect.BlindDown(which);
		document.getElementById(span).className='text_small_bold';
	}else{
		new Effect.BlindUp(which);
		document.getElementById(span).className='text_small';
	}
}
function show_hide_details(which_arrow,which) {
	
	if (Element.visible(document.getElementById(which))==false){
		new Effect.BlindDown(which);
		document.getElementById(which_arrow).src='images/content/arrow_down.gif';
		
	}else{
		new Effect.BlindUp(which);
		document.getElementById(which_arrow).src='images/content/arrow.gif';
	}
}


function Search(kw,what,city) {
	var length = kw.length;
	if(length >=2)
	{
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
	
		var url = "search="+kw+"&city="+city;
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open( "POST", what, true );
		xmlHttp.setRequestHeader( 'Content-Type', "application/x-www-form-urlencoded; charset=UTF+8" );
		xmlHttp.send( url );

		document.getElementById("categories").className = "search_div_none";
		return false;		
	}
}

	function stateChanged() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("search_div").className = "search_div_show";
			document.getElementById("search_div").innerHTML=xmlHttp.responseText 
			document.getElementById("categories").className = "search_div_none";
			document.getElementById("indicator").className = "search_div_none";
		} 
		else
		{	
			document.getElementById("search_div").className = "search_div_none";
			document.getElementById("indicator").className = "search_div_show";
		}
	} 

	function GetXmlHttpObject()
	{ 
		var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
			objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		return objXMLHttp
	} 


/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}