<!--


function checkRecForm(theForm){
    
    if(document.theForm.fname.value=="" || document.theForm.femail.value=="" || document.theForm.aname.value=="" || document.theForm.info.value==""){
        alert("Fyll i alla obligatoriska fält");
        return(false);
    }
    
    if ( ((theForm.femail.value).indexOf('@') <0) || ((theForm.femail.value).indexOf('.') <0)  ){
        alert ("Ange en giltig e-postadress");
        return(false);
    }
    
  
    return(true);
}



function openSlideShow(aid){
   window.open("slideshow.php?aid=" + aid, "slideshow", 'width=720,height=540,location=no,toolbar=no,scrollbars=no');
}




function surenewsdelete(bid, pic){
  if (confirm("Är du säker på att du vill radera denna posten?")) {
    window.location="deletenews.php?nid="+bid + "&pic="+pic;
  }
}


function sureblogdelete(bid){
  if (confirm("Är du säker på att du vill radera denna posten?")) {
    window.location="deleteblog.php?bid="+bid;
  }
}

function addcomment(bid, aid){
   window.open("comment_add.php?aid="+aid+"&bid=" + bid, "comment", 'width=450,height=300,location=no,toolbar=no,scrollbars=no');

}


function showallcomment(bid, aid){
   window.open("comment_all.php?aid="+aid+"&bid=" + bid, "comment", 'width=450,height=300,location=no,toolbar=no,scrollbars=yes');

}

function show_bill(bid, print){
   add ="";
   if(print==1){
     add = "action=print&";
   }
   window.open("show_bill.php?"+add+"bid=" + bid, "bill_"+bid, 'width=450,height=340,location=no,toolbar=no,scrollbars=no');
}


function checkAnslag(mgalForm){


 var sel = document.mgalForm.typ.options[document.mgalForm.typ.selectedIndex].value;


  if (sel == 0){
    alert("Välj en kategori");
    return(false);
  }
  if(document.mgalForm.desc.value==""){
    alert("Du måste skriva lite text på din notis");
    return(false);
  }
  if(document.mgalForm.desc.value.length>300){
   alert("Max 300 tecken");
   return(false);
 }
}


function checkTillSalu(mgalForm, varTillSalu){

  extArray = new Array(".gif", ".jpg", ".png", ".jpeg",  ".tiff", ".tif", ".jpe", ".bmp");
   file = document.mgalForm.userfile.value;
   allowSubmit = false;
   if (!file){
     return false;
   }

   while (file.indexOf("\\") != -1)
   file = file.slice(file.indexOf("\\") + 1);
   ext = file.slice(file.indexOf(".")).toLowerCase();
   for (var i = 0; i < extArray.length; i++) {
      if (extArray[i] == ext) {
         allowSubmit = true;
          break;
      }
   }
   if(!allowSubmit){
      alert("Du kan bara ladda upp filer av typer:  "
      + (extArray.join("  ")) );
      return false;
   }

  var sel = document.mgalForm.status.options[document.mgalForm.status.selectedIndex].value;

  if( (sel == varTillSalu) && (document.mgalForm.price.value<=0) ){
    alert("Ange priset");
    return false;
  }


}

function changeBkg(color){
 // alert("color " + color);
  document.getElementById('cell').bgColor = color;
}

function changeFrame(set){
  //alert("ddd");
  document.getElementById('01').src = "../images/frames/set" + set+"/01.jpg";
  document.getElementById('03').src = "../images/frames/set" + set+"/03.jpg";
  document.getElementById('05').src = "../images/frames/set" + set+"/05.jpg";
  document.getElementById('07').src = "../images/frames/set" + set+"/07.jpg";
  //document.getElementById('02').bgColor = "#ffff00";

  newImage02 = "url(../images/frames/set"+ set+"/02.jpg)";
  document.getElementById('02').style.backgroundImage=newImage02;

  newImage04 = "url(../images/frames/set"+ set+"/04.jpg)";
  document.getElementById('04').style.backgroundImage=newImage04;

  newImage06 = "url(../images/frames/set"+ set+"/06.jpg)";
  document.getElementById('06').style.backgroundImage=newImage06;

  newImage08 = "url(../images/frames/set"+ set+"/08.jpg)";
  document.getElementById('08').style.backgroundImage=newImage08;
}


function checkCalForm(theForm){
 if(theForm.name.value == ''){
    alert("Du måste ange utställningens namn");
    return(false);
 }
 if(theForm.text.value.length>250){
   alert("Max 250 tecken");
   return(false);
 }
 if(theForm.userfile.value == '' && theForm.pic.value == ''){
    alert("Du måste ladda upp en bild");
    return(false);
 }
}

function open_vcard(calid){
   window.open("show_vcard.php?calid=" + calid, "vcard", 'width=640,height=460,location=no,toolbar=no,scrollbars=no');
}

function open_card(aid, w, h){
   window.open("show_card.php?aid=" + aid, "card", 'width='+w+',height='+h+',location=no,toolbar=no,scrollbars=no');
}


function sureDeleteComment(page){
  if (confirm("Är du säker på att du vill radera kommentaren")) {
    window.location=page;
  }
}

function sureAll(mgalid){
  if (confirm("Är du säker på att du vill radera meddelande?")) {
    window.location="deletemsg.php?mid="+mgalid;
  }
}

function delSales(sid){
  if (confirm("Är du säker på att du vill radera meddelande?")) {
    window.location="deletesales.php?sid="+sid;
  }
}


function sureDelete(page){
  if (confirm("Är du säker på att du vill radera inlägget?")) {
    window.location=page;
  }
}


function checkForm(theForm){
  if ( ((theForm.email.value).indexOf('@') <0) || ((theForm.email.value).indexOf('.') <0)  ){
    alert ("Ange en giltig e-postadress");
    return(false);
  }
  if((theForm.sender.value=="")||(theForm.email.value=="")||(theForm.comment.value=="")){
    alert("Fyll i alla obligatoriska fält");
    return(false);
  }
}


function checkGuestBook(theForm){
  if ( ((theForm.email.value).indexOf('@') <0) || ((theForm.email.value).indexOf('.') <0)  ){
    alert ("Ange en giltig e-postadress");
    return(false);
  }

  if((theForm.sender.value=="")||(theForm.email.value=="")||(theForm.comment.value=="") || (theForm.confirm_val.value="")){
    alert("Fyll i alla obligatoriska fält");
    return(false);
  }



}

function openpicmgal(pic, w, h, t){
	//alert("k"+pic);
   page = "openpicgal.php?pic=" + pic;
   //alert(page);
   picname = "name_"+pic ;
   window.open("openpicgal.php?pic=" + pic, t, 'width='+w+',height='+h+',location=no,toolbar=no,scrollbars=no');

}


function openpicblog(pic, w, h, t){
	//alert("k"+pic);
   page = "openpicblog.php?pic=" + pic;
   //alert(page);
   picname = "name_"+pic ;
   window.open("openpicblog.php?pic=" + pic, t, 'width='+w+',height='+h+',location=no,toolbar=no,scrollbars=no');

}

function openpic(id, w, h, picname){
   window.open("openpic.php?pid="+id, picname, 'width='+w+',height='+h+',location=no,toolbar=no,scrollbars=yes');
}

function checkGalleryForm(theForm){
    if((theForm.mgal_artistemail.value=="")||(theForm.mgal_name.value=="")||(theForm.mgal_password.value=="")||(theForm.mgal_artist.value=="")||(theForm.mgal_artistlastname.value=="")||(theForm.mgal_artistaddr.value=="")||(theForm.mgal_artistpostal.value=="") ){
      alert("Fyll i alla obligatoriska fält");
      return(false);
    }

    if (  (theForm.mgal_password.value).indexOf(' ') >0   ){
      alert ("Inga mellanslag i lösenordet");
      return(false);
    }

    if (!(theForm.accept.checked)) {
     alert ("Du måste godkänna att vi lagrar uppgifter enligt PUL");
     return(false);
    }

    if ( ((theForm.mgal_artistemail.value).indexOf('@') <0) || ((theForm.mgal_artistemail.value).indexOf('.') <0)  ){
     alert ("Ange en giltig e-postadress");
     return(false);
    }
    return(true);
}

function checkGalleryTextForm(theForm){
  if(theForm.mgal_artisttext.value==""){
       alert("Fyll i alla obligatoriska fält");
      return(false);
  }
 return(true)
}


function checkGalleryLinkForm(theForm){
	/*
	a = (theForm.mgal_linkname.value=="") ;
	b = (theForm.mgal_link1.value.lenght<=7);
    */

  // xor
  if( ( (theForm.mgal_linkname.value=="")&& (theForm.mgal_link1.value.length<=7)) || !( (theForm.mgal_linkname.value=="")|| (theForm.mgal_link1.value.length<=7))  ){
       alert("1111Fyll i bägge fält");
      return(false);
  }

 return(true)
}



function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function init(id, opacStart, opacEnd, millisec){
	 changeOpac(0, id);
	 opacity(id, opacStart, opacEnd, millisec);
	}


function sureDeleteCat(cid, catname){
  if (confirm("Är du säker på att du vill radera kategorin "+catname+" och flytta tillhörande blogginlägg till Allmänt?")) {
    window.location="blog_editcat_handler.php?todo=delete&catid="+cid;
  }
}



function sureDeletePicCat(cid, catname){
  if (confirm("Är du säker på att du vill radera kategorin "+catname+" och flytta tillhörande bilder till Övrigt?")) {
    //alert("sss gallery_cat_edit.php?todo=delete&catid="+cid);
    //window.location="gallery_cat_edit.php?todo=delete&catid="+cid;
    theFormCat.submit();
  }
}

function sureDeleteVideo(id){
  if (confirm("Är du säker på att du vill radera videon?")) {
    window.location="gallery_video.php?todo=delete&vid="+id;
  }
}

function openvideo(film, aid, w, h){
//alert(film);
   window.open("showvideo.php?aid="+aid+"&film="+film, "video", 'width='+w+',height='+h+',location=no,toolbar=no,scrollbars=no');
}




function checkUploadVideo(theForm){

  extArray = new Array(".mpeg", ".mpg", ".avi", ".mov", ".qt", ".wmv");
   file = document.theForm.userfile.value;
   allowSubmit = false;
   if (!file){
     return false;
   }

   while (file.indexOf("\\") != -1)
   file = file.slice(file.indexOf("\\") + 1);
   ext = file.slice(file.indexOf(".")).toLowerCase();
   for (var i = 0; i < extArray.length; i++) {
      if (extArray[i] == ext) {
         allowSubmit = true;
          break;
      }
   }
   if(!allowSubmit){
      alert("Du kan bara ladda upp filer av typer:  "
      + (extArray.join("  ")) );
      return false;
   }


}


 function checkForm_Pin(theForm){
/*
  if ( ((theForm.buypin_epost.value).indexOf('@') <0) || ((theForm.buypin_epost.value).indexOf('.') <0)  ){
    alert ("Ange en giltig e-postadress");
    return(false);
  }
  */
  if((theForm.buypin_name.value=="")||(theForm.buypin_address.value=="")||(theForm.buypin_postnr.value=="") ||(theForm.buypin_city.value=="") ||(theForm.buypin_amount.value=="") ){
    alert("Fyll i alla fält");
    return(false);
  }
}

function print_membercard(){
       window.open("print_membercard.php", "member_card", 'width=150,height=70,location=0,toolbar=0,scrollbars=0,resizable=0');

}

function allow_comments(allow, id){
    window.location = "wip_edit_handler.php?allow="+allow+"&wip="+id;
    
}

function show_hide_price() {
    mgalForm
    opt = document.mgalForm.status.options[document.mgalForm.status.selectedIndex].value;
    if (opt==3 || opt==0) {
        document.mgalForm.price.disabled=true;
    }
    else {
        document.mgalForm.price.disabled=false;
    }
      
}

function isNumeric(){
    var numericExpression = /^[0-9]+$/;
    elem = document.sale_form.bid.value;
    if(elem) {
        if(elem.match(numericExpression)){
            return true;
        }
        else{
            alert('Ange endast beloppet med siffror i budfältet');
            return false;
        }
    }
    else {
        return true;
    }
}


// -->
