
var UA = navigator.userAgent.toLowerCase();
var isIE = (UA.indexOf('msie') >= 0) ? true : false;
var isNS = (UA.indexOf('mozilla') >= 0) ? true : false;

function modalDialog2(url,width,height){
    //var left = screen.availWidth/2 - width/2;
    //var top = screen.availHeight/2 - height/2;
    //activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top+",scrollbars=yes,resizable=yes");
    //window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};

    if(typeof(modalDialogShow) == "undefined") {
    
      var id = "ID"+(new Date()).getTime();
      var f = new ISWindow(id);
      f.iconPath = oUtil.scriptPath + "icons/";
      f.show({width:width+"px", height:height+"px",overlay:false,center:true, url:url, openerWin:null, options:null});
    
    } else {
        modalDialogShow(url, width, height );
    }
    
    }
function modalDialog(url,width,height,title) {
    if (title)
        box.open({ url: url, type: 'iframe', width: width + 'px', height: height + 'px', title: title, adjY: '20px', overlay: true });
    else
        box.open({ url: url, type: 'iframe', width: width + 'px', height: height + 'px', adjY: '20px', overlay: true });
    }


function mDialogInline(url, width, height, title, overlay, parent, addscript, addclass) {
    if (isIE) height = height + 10;
    if (title)
        box.open({ url: url, type: 'inline', width: width + 'px', height: height + 'px', title: title, adjY: '20px', overlay: overlay, parent: parent });
    else
        box.open({ url: url, type: 'inline', width: width + 'px', height: height + 'px', adjY: '20px', overlay: overlay, parent: parent });
    if (addscript) eval(addscript);
    if (addclass) 
        {
        box.rt.ca.className = addclass;
        }
    else 
        {
        box.rt.ca.className = 'content_area';
        }
    }
function icCloseDlg(){
    box.close();
    }
function areaOver(s) {
    if (document.getElementById('divAddModule_' + s))
        document.getElementById('divAddModule_' + s).style.visibility = 'visible';
    }
function areaOut(s) {
    if (document.getElementById('divAddModule_' + s))
        document.getElementById('divAddModule_' + s).style.visibility = 'hidden';
    }

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",'get_cal.php?itemid=' + item ,true);
	xmlHttp.send(null);
}

function get_news_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",'get_news.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 MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) 
  {
    d=parent.frames[n.substring(p+1)].document; 
	n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) 
    x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) 
    x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
    x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) 
    x=d.getElementById(n); 
  return x;
}
 
function MM_validateForm() 
{ //v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	{ 
		test=args[i+2]; 
		val=MM_findObj(args[i]);
		if (val) 
		{ 
			nm=val.id; 
			if ((val=val.value)!="") 
			{
				if (test.indexOf('isEmail')!=-1) 
				{ 
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1)) 
						errors+='- '+nm+' skal indholde en gyldig E-Mail adresse.'+"\r\n";
				}
				else if (test!='R') 
				{ 
					num = parseFloat(val);
					if (isNaN(val)) errors+='- '+nm+' Skal indholde tal.'+"\r\n";
					if (test.indexOf('inRange') != -1) 
					{ 
						p=test.indexOf(':');
						min=test.substring(8,p); 
						max=test.substring(p+1);
						if (num<min || max<num) 
						errors+='- ' + nm + ' Skal indholde tal mellem '+min+' og '+max+'.'+"\r\n";
					} 
				} 
			} 
			else if (test.charAt(0) == 'R') 
				errors += '- '+nm+' skal udfyldes.'+"\r\n"; 
		}
	} 
	if (errors) 
		alert('Du mangler at udfylde f\u00F8lgende felter:'+"\r\n"+errors);
	document.MM_returnValue = (errors == '');
}

