var myWindow;

function openCenteredWindow(url) {
    var width = 620;
    var height = 500;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + ",screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "JH Maskinteknik", windowFeatures);
}


function toggle(items) {
	var ele = document.getElementById("News_"+ items);
	var ele1 = document.getElementById("N_"+ items);

	if(ele.style.display == "block") {
    		ele.style.display = "none";
  		    ele1.style.backgroundColor = 0xffffff;
  	}
	else {
		ele.style.display = "block";
		ele1.style.backgroundColor = 0xf9f1ee;
		
	}
} 

function close_editor() 
{
	document.getElementById('editor').innerHTML='';
	new Effect.Fade('editor_div', {duration:0.1});
	new Effect.Fade('editor_bg', {duration:0.5});
}

function get_editor_SC() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		blanket_size();
		document.getElementById('editor').innerHTML=xmlHttp.responseText;
		new Effect.Appear('editor_div', {duration:0.1, from:0.0, to:1});
		new Effect.Appear('editor_bg', {duration:0.5, from:0.0, to:0.2});
	}
}

function get_calender_item(item) 
{
    xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your b-rowser does not support AJAX!");
		return;
	}
	//url = url + "&sid="+Math.random();
	xmlHttp.onreadystatechange=get_editor_SC;
	xmlHttp.open("GET",'/includes/get_cal.php?itemid=' + item ,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

function blanket_size() 
{
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('editor_bg');
	blanket.style.height = blanket_height + 'px';
}

function standardTopMenu(menuId){
	document.getElementById('textLink'+menuId).className='topMenuHref';
	document.getElementById('txtDiv_id'+menuId).className='tMenuTxtDiv';
	document.getElementById('button_id'+menuId+'_left').style.background='url(/pictures/bg/button_left.jpg) top left no-repeat';
	document.getElementById('button_id'+menuId+'_repeat').style.background='url(/pictures/bg/button_repeat.jpg) top left repeat-x';
	document.getElementById('button_id'+menuId+'_right').style.background='url(/pictures/bg/button_right.jpg) top right no-repeat';	
}
function standardTopMenuOver(menuId){
	document.getElementById('textLink'+menuId).className='topMenuHrefOver';
	document.getElementById('txtDiv_id'+menuId).className='tMenuTxtDivOver';
	document.getElementById('button_id'+menuId+'_left').style.background='url(/pictures/bg/button_left_over.jpg) top left no-repeat';
	document.getElementById('button_id'+menuId+'_repeat').style.background='url(/pictures/bg/button_repeat_over.jpg) top left repeat-x';
	document.getElementById('button_id'+menuId+'_right').style.background='url(/pictures/bg/button_right_over.jpg) top right no-repeat';	
}

