<!-- Begin
// Montering av bild, Fixed by ME
//function openColourPickerDialog(wnd, field, dlgURL)
myPopup = '';
function openPopupImage(wnd, field, url) {
    myPopup = window.open(url,'popupWindow','width=570,height=450');
    if (!myPopup.opener)
     myPopup.opener = self; 
}

myPopup = '';
function openPopup(url) {
    myPopup = window.open(url,'popupWindow','width=550,height=450');
    if (!myPopup.opener)
     myPopup.opener = self; 
}




function Start(page) {
OpenWin = this.open(page, "view", "toolbar=no,menubar=yes,location=no,scrollbars=yes,maximize=no,resize=no,width=640,height=560");
}

function tips(page) {
OpenWin = this.open(page, "view", "toolbar=no,menubar=no,location=no,scrollbars=no,maximize=no,resize=no,width=400,height=400");
}

function EditImageWindow(page) {
OpenWin = this.open(page, "view", "toolbar=no,menubar=no,location=no,scrollbars=yes,maximize=no,resizable=1,width=800,height=600");
}

// Visa bild innan du laddar upp ''''''''''''''''''''''''''''''''''''''''''''
function previewImage(fileInfo) {
var filename = "";
//create the path to your local file
if (fileInfo == null) {
if (document.form1.file != "") {
filename = "file:///" + document.form1.file.value;
}
} else {
filename = fileInfo;
}
//check if there is a value
if (filename == "") {
alert ("Please select a image.");
document.form1.file.focus();
} else {
//create the popup 
/////popup = window.open('', 'imagePreview', 'width=400,height=350,left=100,top=75,screenX=100,screenY=75,scrollbars,location,menubar,status,toolbar,resizable=1');
popup = window.open('', 'imagePreview', 'width=400,height=350,left=100,top=75,screenX=100,screenY=75,scrollbars,status,menubar,resizable=1');

//start writing in the html code
popup.document.writeln("<html><body bgcolor='#FFFFFF'>");
//get the extension of the file to see if it has one of the image extensions
var fileExtension = filename.substring(filename.lastIndexOf(".")+1);
if (fileExtension == "jpg" || fileExtension == "jpeg" || fileExtension == "gif" 
|| fileExtension == "png")
popup.document.writeln("<img src='" + filename + "'>");
else
//if not extension fron list above write URL to file 
popup.document.writeln("<a href='" + filename + "'>" + filename + "</a>");
popup.document.writeln("</body></html>");
popup.document.close();
popup.focus();
}
}
// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


// Öppna popup med rätt storlek '''''''''''''''''''''''''''''''''''''''''
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this notice.

// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''




// Kontrollera Borttagning av objekt
function DeleteWarning(url)
{
	var yesno = confirm ("Är du säkert att du vill ta bort objektet ?","");
	if (yesno == true)
	{
		location=url;
	}
	else
	{
		alert ("Borttagning avbryten !");
	}
}

// Kontrolera popup fönster för markering av bild/fil
function myColourDialog(){var myColour;}
function openColourPickerDialog(wnd, field, dlgURL)
{
myColourDialog.myColour="";
if( wnd.showModalDialog(dlgURL, myColourDialog, "dialogHeight:400px;dialogWidth:550px;resizable: no; help: no; status: no; scroll: no; ")==true)
{
field.value = myColourDialog.myColour;
}
else
{
return;
}
}


// Kontrolera popup fönster för markering av användare
function myColourDialogNy(){var myID,myColour;}
function openColourPickerDialogNy(wnd, fieldID, field, dlgURL)
{
myColourDialog.myID="";
myColourDialog.myColour="";
if( wnd.showModalDialog(dlgURL, myColourDialog, "dialogHeight:400px;dialogWidth:550px;resizable: no; help: no; status: no; scroll: no; ")==true)
{
fieldID.value = myColourDialog.myID;
field.value = myColourDialog.myColour;
}
else
{
return;
}
}

// Funktion för att markera,avmarkera poster
function checkall(formname,checkname,thestate){
var el_collection=eval("document.forms."+formname+"."+checkname)
for (c=0;c<el_collection.length;c++)
el_collection[c].checked=thestate
}



// Kontrollera Användare modulen
function is_it_validUser() {
  var picked = false;
  if (document.form.UserRealName.value == "") {
    alert('Ange Namn för denna användare?...');
    return false;
  }
  
    if (document.form.UserEmail.value == "") {
    alert('Ange e-post för denna användare?...');
    return false;
  }
  
  return true;
}

// Göm eller visa WorkGroup
function visaEJ()
{
document.all["id1"].style.visibility = "hidden";

}
function visa()
{
document.all["id1"].style.visibility = "visible";
}

// Kontrollera WorkGroup modulen
function is_it_validWorkGroup() {
  var picked = false;
  if (document.form.Group.value == "") {
    alert('Ange namn för denna arbetsgrupp?...');
    return false;
  }
  
   if (document.form.URL.value == "") {
    alert('Ange hela vägen till arbetsfoldern?...');
    return false;
  }
}






// Kontrollera dokumant/Nyheter modulen
function is_it_valid_news() {
  var picked = false;
    if (document.form.VERSION.value == "") {
    alert('Välj språkversion?...');
    return false;
  }
    
    if (document.form.TYP.value == "") {
    alert('Välj dokummenttyp?...');
    return false;
  }
  
  if (document.form.Titel.value == "") {
    alert('Ange Titel för denna artikel?...');
    return false;
  }
  
  
  return true;
}



// Kontrollera monterabild_dokument modulen
function is_it_validImage() {
  var picked = false;
  if (document.form.Bild.value == "") {
    alert('Välj bild/artikel som ska monteras/Bifogas?...');
    return false;
  } 
  return true;
}



// Kontrollera länk modulen
function is_it_validLink() {
  var picked = false;
  if (document.form.Titel.value == "") {
    alert('Ange Titel för denna länk?...');
    return false;
  }
  
   if (document.form.URL.value == "") {
    alert('Ange hela länken?...');
    return false;
  }
}


// Kontrollera Filhanterare modulen
function is_it_validFilemanager() {
  var picked = false;
  if (document.NewFolder.FolderName.value == "") {
    alert('Ange ett namn för den nya foldern?...');
    return false;
  } 
  return true;
}


// ********   GroupMail  '''''''''***********

function is_it_valid_GruppMail() {
  var picked = false;
  if (document.form.Subject.value == "") {
    alert('Skriv in Ämne?...');
    return false;
  } 
  return true;
  
   if (document.form.Message.value == "") {
    alert('Skriv in Meddelande?...');
    return false;
  } 
  return true;
}

function is_it_validEmail() {
  var picked = false;
  if (document.form.WorkGroup.value == "") {
    alert('Välj Arbetsgrupp?...');
    return false;
  }
    
  if (document.form.RealName.value == "") {
    alert('Skriv in namnet?...');
    return false;
  }
  
    if (document.form.Email.value == "") {
    alert('Skriv in E-post adressen?...');
    return false;
  }
  
  return true;
}

/* KONTROLLERA PERSONAL */

function is_it_valid_person() {
  var picked = false;
  
    if (document.Form.Namn.value == "") {
    alert('Skriv in namn?...');
    return false;
  }
      
    if (document.Form.Efternamn.value == "") {
    alert('Ange Efternamn?...');
    return false;
  }
  return true;
}



//************* Kontrollera Upload ..........................................
function checkFileUpload(form,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09
  document.MM_returnValue = true;
  for (var i = 0; i<form.elements.length; i++) {
    field = form.elements[i];
    if (field.type.toUpperCase() != 'FILE') continue;
    checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
} }

function checkOneFileUpload(field,extensions,requireUpload,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight) { //v2.09
  document.MM_returnValue = true;
  if (extensions != '') var re = new RegExp("\.(" + extensions.replace(/,/gi,"|").replace(/\s/gi,"") + ")$","i");
    if (field.value == '') {
      if (requireUpload) {alert('Välj fil som du vill placera på webbserver!');document.MM_returnValue = false;field.focus();
      window.document.location.reload(true);
      return;}
    } else {
      if(extensions != '' && !re.test(field.value)) {
        alert('Denna filformat är inte tillåtet.\nEndast dessa filformat är tillåtet att placera på webbservern: ' + extensions + '.\nVälj en annan bild.');
        document.MM_returnValue = false;field.focus();
        window.document.location.reload(true);
        return;
      }
    document.PU_uploadForm = field.form;
    re = new RegExp(".(gif|jpg|png|bmp|jpeg)$","i");
    if(re.test(field.value) && (sizeLimit != '' || minWidth != '' || minHeight != '' || maxWidth != '' || maxHeight != '' || saveWidth != '' || saveHeight != '')) {
      checkImageDimensions(field,sizeLimit,minWidth,minHeight,maxWidth,maxHeight,saveWidth,saveHeight);
    } }
}

function showImageDimensions(fieldImg) { //v2.09
  var isNS6 = (!document.all && document.getElementById ? true : false);
  var img = (fieldImg && !isNS6 ? fieldImg : this);
  if (img.width > 0 && img.height > 0) {
  if ((img.minWidth != '' && img.minWidth > img.width) || (img.minHeight != '' && img.minHeight > img.height)) {
    alert('Denna fil är för liten för att använda på hemsidan!!\nTillåten storlek är minst: ' + img.minWidth + ' x ' + img.minHeight); 
    window.document.location.reload(true);
    return;}
  if ((img.maxWidth != '' && img.width > img.maxWidth) || (img.maxHeight != '' && img.height > img.maxHeight)) {
    alert('Denna fil är för stor för att använda på hemsidan!\nTillåten storlek är: max ' + img.maxWidth + ' x ' + img.maxHeight); 
    window.document.location.reload(true);
    return;}
  if (img.sizeLimit != '' && img.fileSize > img.sizeLimit) {
    alert('Denna fil är för stor för att använda på hemsidan!\nTillåten storlek är: max ' + (img.sizeLimit/1024) + ' KBytes'); 
    window.document.location.reload(true);
    return;}
  if (img.saveWidth != '') document.PU_uploadForm[img.saveWidth].value = img.width;
  if (img.saveHeight != '') document.PU_uploadForm[img.saveHeight].value = img.height;
  document.MM_returnValue = true;
} }

function checkImageDimensions(field,sizeL,minW,minH,maxW,maxH,saveW,saveH) { //v2.09
  if (!document.layers) {
    var isNS6 = (!document.all && document.getElementById ? true : false);
    document.MM_returnValue = false; var imgURL = 'file:///' + field.value.replace(/\\/gi,'/').replace(/:/gi,'|').replace(/"/gi,'').replace(/^\//,'');
    if (!field.gp_img || (field.gp_img && field.gp_img.src != imgURL) || isNS6) {field.gp_img = new Image();
		   with (field) {gp_img.sizeLimit = sizeL*1024; gp_img.minWidth = minW; gp_img.minHeight = minH; gp_img.maxWidth = maxW; gp_img.maxHeight = maxH;
  	   gp_img.saveWidth = saveW; gp_img.saveHeight = saveH; gp_img.onload = showImageDimensions; gp_img.src = imgURL; }
	 } else showImageDimensions(field.gp_img);}
}

function showProgressWindow(progressFile,popWidth,popHeight) { //v2.09
  var showProgress = false, form, field;
  for (var f = 0; f<document.forms.length; f++) {
    form = document.forms[f];
    for (var i = 0; i<form.elements.length; i++) {
      field = form.elements[i];
      if (field.type.toUpperCase() != 'FILE') continue;
      if (field.value != '') {showProgress = true;break;}
  } }
  if (showProgress && document.MM_returnValue) {
    var w = 480, h = 340;
    if (document.all || document.layers || document.getElementById) {
      w = screen.availWidth; h = screen.availHeight;}
    var leftPos = (w-popWidth)/2, topPos = (h-popHeight)/2;
    document.progressWindow = window.open(progressFile,'ProgressWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + popWidth + ',height='+popHeight);
    document.progressWindow.moveTo(leftPos, topPos);document.progressWindow.focus();
		window.onunload = function () {document.progressWindow.close();};
} }

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.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
// Kontrollera Upload..........................................................




// Hjälper till med att visa eller göma olika felt på en form
if(!document.getElementById && document.all) 
document.getElementById = function(id){ return document.all[id]} 
function showHide (id) 
{ 
var style = document.getElementById(id).style 
if (style.visibility == "hidden") 
style.visibility = "visible"; 
else 
style.visibility = "hidden"; 
} 

if(!document.getElementById && document.all) 
document.getElementById = function(id){ return document.all[id]} 
function Hide (id) 
{ 
var style = document.getElementById(id).style 
if (style.visibility == "visible") 
style.visibility = "hidden";  
} 

function oneOrNoCheckboxGroup (checkbox) {
  var checkboxGroup = checkbox.form[checkbox.name];
  for (var c = 0; c < checkboxGroup.length; c++)
    if (checkboxGroup[c] != checkbox)
      checkboxGroup[c].checked = false;
}


/* KONTROLLERA Markering  */

function is_it_valid_markerad() {
  var picked = false;
  
    if (document.form.PersonalID.checked == false) {
    alert('Markerea minst ett objeket?...');
    return false;
  }
  return true;
}

/* KONTROLLERA Stuga  */

function is_it_valid_stuga() {
  var picked = false;
  
    if (document.Form.Fastighet.value  == 0) {
    alert('Ange fastighetsbetekning?...');
    return false;
  } 
  return true;
}

/* KONTROLLERA Båtplats  */

function is_it_valid_batplats() {
  var picked = false;
  
    if (document.Form.Fastighet.value  == 0) {
    alert('Ange fastighetsbetekning? Om du saknar fastighetsbetekning, fyll i tre punkter(...)');
    return false;
  } 
  return true;
}

/* KONTROLLERA SMS (Korta meddelande) */

function is_it_valid_sms() {
  var picked = false;
  
    if (document.Form.Typ.value == "") {
    alert('Välj typ för denna meddelande?...');
    return false;
  }
   
   
   if (document.Form.Titel.value == "") {
    alert('Ange titel för denna meddelande?...');
    return false;
  }
  return true;
}

// -->
