<!--

function opencal(url){
   window.open (url,"admincal","width=850,height=630,toolbars=yes,scrollbars=yes");
}

function show_price_fields(radio_button){
    if(radio_button.value=='yes'){
        document.getElementById('price').style.display = 'block';
    }
    else{
        document.getElementById('price').style.display = 'none';
    }
}

function openColorChooser(typ, col){
  window.open ("colorchooser.php?typ="+typ+"&color="+col,"colorchooser","width=650,height=400,toolbars=yes,scrollbars=yes");
}

function openUserPicSettings(typ){
  window.open ("user_settings_pic.php?typ="+typ ,"settings","width=650,height=400,toolbars=yes,scrollbars=yes");
}

function check_reg_form(theForm){
    if(document.theForm.epost.value==""){
        alert("Fyll i din e-postadress");
        return(false);
    }
    
    if(!isValidEmail(document.theForm.epost.value) ){
        alert("Fyll i en giltig e-postadress");
        return(false);
    }
    return true;
}

function check_form_shout(theForm){
    txt = document.theForm.shout.value;  
   
    if(txt == ""){
        alert('Skriv i fältet');
        return(false);
    }

    if(txt.length>80){
        alert('Max 80 tecken');
        return(false);
    }

    if(!is_valid_input(txt)){
        alert('Otillåtna tecken');
        return(false);
    }

    if (confirm("Är du säker?")) {
        return(true);
    }
    return (false);
}

function check_form_reg(theForm){

    if(document.theForm.ep.value==""){
        alert("Fyll i din e-postadress");
        return(false);
    }
  
    if(!isValidEmail(document.theForm.ep.value) ){
        alert("Fyll i en giltig e-postadress");
        return(false);
    }
    
    if(document.theForm.fname.value=="" || document.theForm.lname.value=="" || document.theForm.log.value=="" || document.theForm.pass.value==""   ){
        alert("Fyll i alla fält");
        return(false);
    }
    
    
    log = "xx"+document.theForm.log.value;
    if(log.indexOf(" ") > 0){
        alert("Inga mellanslag i login");
        return(false)
    }

    epo = "xx"+document.theForm.ep.value;
    if(epo.indexOf(" ") > 0){
        alert("Inga mellanslag i e-postadress");
        return(false)
    }

    pass = "xx"+document.theForm.pass.value;
    if(pass.indexOf(" ") > 0){
        alert("Inga mellanslag i lösenord");
        return(false)
    }
    
    return true;

}




function isValidEmail(str) {
    str = "aaa" + str;
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}

function openpop(url){
   window.open (url,"adminadd","width=950,height=600,toolbars=yes,scrollbars=yes");
}

function sureDelete(page, txt){
  if (confirm(txt)) {
    window.location=page;
  }
}

function change_text_sixe(size){
    window.location.href="setting_handler.php?size="+size;

}

function check_form_pictures(theForm){
    info = document.theForm.pic_info.value;
    if(!is_valid_input(info)){
        alert("Får ej innehålla länkar");
        return false;
    }
    if(document.theForm.keyword.lenght>128){
        alert("För många sökord");
        return false;
    }
    return true;

}

function check_form_uinfo(theForm){

    short_info = document.theForm.short_info.value;

    if(!is_valid_input(short_info)){
        alert("Får ej innehålla länkar");
        return false;
    }

    long_info = document.theForm.long_info.value;
    if(!is_valid_input(long_info)){
        alert("Får ej innehålla länkar");
        return false;
    }
    exhibition = document.theForm.exhibition.value;
    if(!is_valid_input(exhibition)){
        alert("Får ej innehålla länkar");
        return false;
    }
    education = document.theForm.education.value;
    if(!is_valid_input(education)){
        alert("Får ej innehålla länkar");
        return false;
    }
    membership = document.theForm.membership.value;
    if(!is_valid_input(membership)){
        alert("Får ej innehålla länkar");
        return false;
    }
    return true;
}

function open_video(vid, uid){
    window.open('open_video.php?vid='+vid +'&uid='+uid, 'video', 'width=700,height=400,location=no,toolbar=no,scrollbars=no');
}




function is_valid_input(txt){
    var not_valid_chars = new Array();
    not_valid_chars[0] = "http";
    not_valid_chars[1] = "www";
    not_valid_chars[2] = ".com";
    not_valid_chars[3] = ".se";
    not_valid_chars[4] = "<";
    not_valid_chars[5] = ">";
    
    
    txt = "a"+txt;

    for (var i=0; i<not_valid_chars.length; i++) {
        x = not_valid_chars[i];
        if(txt.indexOf(x)>0){
            return false;
        }
    }   
    return true;
}

function check_kontakt_form(typ, i){
    //str.indexOf(".") > 2
    url_val = 'cc'+document.getElementById('url_value_'+i).value;
    //url_val =  'cc'+theForm.url_value.value ;
    //alert(url_val);

    if(typ != "Hemsida"){
        if(url_val.indexOf(typ.toLowerCase()) < 0){
            alert('Ej tillåten url');
            return false;
        } 
    }
    
    return true;
}

function addcomment(id, typ, uid){
   window.open("../user/comment_add.php?id="+id+"&type="+typ+"&uid="+uid , "comment", 'width=450,height=320,location=no,toolbar=no,scrollbars=no');

}


function open_sales_form(uid, pid){
   window.open("sales_form.php?uid="+uid+"&pid="+pid , "sales", 'width=650,height=400,location=no,toolbar=no,scrollbars=no');

}

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

function check_comment_form(theForm){
    ep = theForm.cepost.value;
    if(ep>''){
        ep = "xxx" + ep;
        if(!isValidEmail(ep) ){
            alert("Fyll i en giltig e-postadress");
            return(false);
        }
        
        if(epo.indexOf(" ") > 0){
            alert("Inga mellanslag i e-postadress");
            return(false);
        }
    }

    if(theForm.cname.value==''){
        alert('Skriv i ditt namn');
        return(false);
    }
    
    if(theForm.comment.value==''){
        alert('Skriv i din kommentar');
        return(false);
    }
    
    if(theForm.comment.value.length > 161){
        alert ('Max 160 tecken');
        return(false);
    }
    
    return true;
}

function sort_member(url, sort){
    window.location.href = url+"&sort="+sort;
}

function show_info_divs(div){
    div_arr = new Array();
    div_arr[0] = 'name';
    div_arr[1] = 'email';
    div_arr[2] = 'login';
    div_arr[3] = 'pass';
    
    for(i in div_arr){
        d = div_arr[i];
        if(d != div){
            document.getElementById(d).style.display = 'none';
        }
        else{
            document.getElementById(d).style.display = 'block';
        }
    }
    
}

function check_form_name(theForm){
    if(theForm.fname.value==''){
        alert('Fyll i ditt namn');
        return(false);
    }
    if(theForm.lname.value==''){
        alert('Fyll i ditt efternamn');
        return(false);
    }
    return(true);
}

function check_form_login(theForm){
    if(theForm.log.value==''){
        alert('Fyll i din login');
        return(false);
    }
    return(true);
}

function check_form_epost(theForm){
    ep = theForm.epost.value;

    if(ep>''){
        ep = "xxx" + ep;
        if(!isValidEmail(ep) ){
            alert("Fyll i en giltig e-postadress");
            return(false);
        }
        
        if(ep.indexOf(" ") > 0){
            alert("Inga mellanslag i e-postadress");
            return(false);
        }
    }
    if(ep==''){
        alert('Fyll i din e-postadress');
        return(false);
    }
    return(true);
}




function check_form_pass(theForm){
    if(theForm.curr_pass.value==''){
        alert('Fyll i ditt nuvarande lösenord');
        return(false);
    }
    if(theForm.new_pass.value==''){
        alert('Fyll i ditt nya lösenord');
        return(false);
    }
    return(true);
}

function check_sales_form(theForm) {
    ep = theForm.sales_email.value;

    if(ep>''){
        ep = "xxx" + ep;
        if(!isValidEmail(ep) ){
            alert("Fyll i en giltig e-postadress");
            return(false);
        }
        
        if(ep.indexOf(" ") > 0){
            alert("Inga mellanslag i e-postadress");
            return(false);
        }
    }
    if(ep==''){
        alert('Fyll i din e-postadress');
        return(false);
    }

    sname = theForm.sales_name.value;
    
    if(sname==''){
        alert('Fyll i ditt namn');
        return(false);
    }
    
    return (true);
}


function banner_upload_check() {
     extArray = new Array(".gif", ".jpg", ".png", ".jpeg");
   file = document.annons.userfile.value;
   allowSubmit = false;
   if (!file){
     alert('Välj en fil för att ladda upp');
     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;
   }

   return true;
}

function banner_confirm_form(type, formid){
    if(type == 'delete') {
        txt = "radera";
    }
    else {
        txt = "godkänna";
    }
    var agree=confirm("Är du säker att du vill "+ txt +" annonsen");
    if (agree) {
        return true;
    }
    else {
        return false;
    }
}

function OpenCalDialog(cal_id) {
      /*
        $("#dialog").dialog("destroy");
        $("#dialog").dialog({ modal: true, bgiframe: true });
      */
    $.post("open_cal.php",{ cid: cal_id},
            function(data){
                $("#dialog").dialog("destroy");
                $("#dialog").dialog({ modal: true, bgiframe: true, width:550,
                    title: 'Utställning'});
                $('#dialog').html(data);
            }, "html");
    
      return false;      
}

function OpenCalDialogUser(cal_id) {

    $.post("open_cal.php",{ cid: cal_id},
            function(data){
                $("#dialog_user").dialog("destroy");
                $("#dialog_user").dialog({ modal: true, bgiframe: true, width:550,
                    title: 'Utställning'});
                $('#dialog_user').html(data);
            }, "html");
      return false;      
}
// -->

