function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>'); 
}

IncludeJavaScript('/admin/editor/scripts/innovaeditor.js');


var myWindow;

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 == '');
}

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 move(s, funk, ret)
{
	window.location.href='move.php?item=' + s + '&ret=' + ret + '&type=' + funk;
}

function openpageinfo(s)
{
	modalDialogShow("pageinfo.php?item=" + s ,450,585,window);
}

function openforms()
{
	modalDialogShow("forms/index.php",750,600,window);
}

function openAsset(s)
{
	modalDialogShow("editor.php?item=" + s ,920,600,window);
}
function add_galleri()
{
	modalDialogShow("create_galleri.php" ,450,300,window);
}
function add_posts(s)
{
	modalDialogShow("pageinfo.php" ,450,585,window);
}
function add_user(s)
{
	modalDialogShow("add_user.php?item=" + s ,450,430,window);
}
 
function upload(s)
{
	modalDialogShow("upload.php?gallery_id=" + s ,450,175,window);
}

function delete_galleri(s, ret)
{
	if (confirm('Vil du gerne slette dette galleri og alle billeder der høre til galleriet ?')) 
		window.location.href='delete_galleri.php?id=' + s + '&ret=' + ret;
}

function delete_user(s, ret)
{
	if (confirm('Vil du slette denne bruger ?')) 
		window.location.href='delete_user.php?id=' + s + '&return=' + ret;
}

function delete_posts(s, ret)
{
	if (confirm('Vil du Slette denne post ?')) 
		window.location.href='delete_posts.php?id=' + s + '&return=' + ret;
}
function updatepub(s, ret)
{
	sActiveAssetInput = s
	window.location.href='update_posts.php?id=' + s + '&return=' + ret;
}

function openFileManager()
{
    modalDialogShow("Filemanager/ajaxfilemanager.php" ,1020,520);
}

function openowner()
{
  modalDialogShow("ownerinfo.php" ,600,520,window);
}

function SetStatus(newStatus){
  document.getElementById('status').innerHTML = newStatus
  document.getElementById('status2').innerHTML = newStatus
}

function RemoveStatus(){
  document.getElementById('status').innerHTML = '';
  document.getElementById('status2').innerHTML = '';
}

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';	
}

