var nodex;

function fixPageHeight( node )
{
	nodex = node;
	setTimeout("Fix()",500);
}

function Fix( node )
{
	var nodeID = nodex;

	var footer  	= document.getElementById( 'siufooter' );
	var xright  	= document.getElementById( 'countryselect');
	var xleft   	= document.getElementById( 'facebook');
	var xmiddle   	= document.getElementById( 'innercontent');

	xleft.style.height   =  ( footer.offsetTop - xleft.offsetTop) + 'px';
	xmiddle.style.height   =  ( footer.offsetTop - xmiddle.offsetTop) + 'px';

	if ( nodeID == 2 && navigator.appName == 'Microsoft Internet Explorer' )
		xright.style.height  = ( footer.offsetTop - xright.offsetTop + 4 ) + 'px';
	else
		xright.style.height  = ( footer.offsetTop - xright.offsetTop ) + 'px';

	
	
}


function showHide( div )
{
	
	var tmp = document.getElementById( div ).style.display;
	
	if ( div == 'flash' )
	{
		if ( tmp == 'inline' )
		{
			document.getElementById( div ).style.display = 'none';
			document.getElementById( 'pult' ).innerHTML = 'Tilbake til skrivepulten';
		}
		else
		{
			document.getElementById( div ).style.display = 'inline';
			document.getElementById( 'pult' ).innerHTML = 'Skjul skrivepulten';
		}
	}
	else
	{
		if ( tmp == 'inline' )
			document.getElementById( div ).style.display = 'none';
		else
			document.getElementById( div ).style.display = 'inline';
	}
}

function resett( div )
{
	document.getElementById( div ).value = '';
	
}

var http_request = false;
   
function postRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Kan ikke opprette XMLHTTP instansen. Bytt browser');
	 return false;
  }
  
  http_request.onreadystatechange = hentPHP;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}

function hentPHP() {
  if ( http_request.readyState == 4 ) {
	 if ( http_request.status == 200 ) 
	 {
		//alert(http_request.responseText);
		result = http_request.responseText;
		if ( result == 1 )
			document.getElementById( 'xstatus' ).innerHTML = '<span style=\"color:green;\">Tipset ble sendt!</span>';
		else if ( result == 2 )
			document.getElementById( 'xstatus' ).innerHTML = '<span style=\"color:red;\">Ugyldig e-post!</span>';
		else
			document.getElementById( 'xstatus' ).innerHTML = '<span style=\"color:red;\">Noe gikk galt!</span>';
	 }
  }
}
 
var numx; 
var node_id;
   
function tipafriend() 
{
  var from = document.getElementById( 'tiptext' ).value;
  var to = document.getElementById( 'tipfriend' ).value;
  var node_id = document.getElementById( 'node_id' ).value;
  
  var poststr = "from=" + encodeURI( from ) + "&to=" + encodeURI( to ) + "&node_id=" + encodeURI( node_id ) ;
  postRequest("/layout/set/ajax/vztlibrary/tipafriend", poststr);
}

function shareFacebook(strArtUrl,strArtTitle)
{
  var tmpUrl = encodeURIComponent(strArtUrl);
  var tmpTitle = encodeURIComponent(strArtTitle);
  window.open("http://www.facebook.com/sharer.php?u=" + tmpUrl + "&t=" + tmpTitle, "Facebook", "width=645,height=436,location=0,menubar=0,resizabl=1,scrollbars=0,status=0,toolbar=0");
}

function shareNettby(strArtUrl,strArtTitle)
{
  var tmpUrl = encodeURIComponent(strArtUrl);
  var tmpTitle = encodeURIComponent(strArtTitle);
  window.open("http://www.nettby.no/user/edit_link.php?name=" + tmpTitle + "&url=" + tmpUrl + "&description=", "Nettby", "width=450,height=430,location=0,menubar=0,resizabl=1,scrollbars=0,status=0,toolbar=0");
}

function shareMyspace(strArtUrl,strArtTitle)
{
  var tmpUrl = encodeURIComponent(strArtUrl);
  var tmpTitle = encodeURIComponent(strArtTitle);
  window.open("http://www.myspace.com/Modules/PostTo/Pages/?t" + tmpTitle + "&u=" + tmpUrl + "&description=", "Nettby", "width=450,height=430,location=0,menubar=0,resizabl=1,scrollbars=0,status=0,toolbar=0");
}

function swapImg( id )
{
	var map = document.getElementById( 'mapimg' );
	
	if ( id== 0 )
		map.src='http://studeriutlandet.no/extension/ezwebin/design/ezwebin/images/worldmap.gif';
	else
		map.src='http://studeriutlandet.no/extension/ezwebin/design/ezwebin/images/' + id + '.gif';
}

function swapbutton( div )
{
	var button = document.getElementById( div );
	button.style.color = '#737373';
}

function swapbuttonOUT( div )
{
	var button = document.getElementById( div );
	button.style.color = '#353535';
	
}
