﻿// JScript File

function galleryImageManager(thisCheckbox,thisForm,maxAllowed){

    if(thisForm.imagesChecked.value == maxAllowed && thisCheckbox.checked == true){
       alert("Sorry, you may select no more than " + maxAllowed + " images");
    }
    else{
       previouslySelected = thisForm.imagesChecked.value;
       if(thisCheckbox.checked == true){ 
            thisForm.imagesChecked.value = (parseInt(previouslySelected) + 1);
        }else{
            thisForm.imagesChecked.value = (parseInt(previouslySelected) - 1);
        }
    }
 // alert(thisForm.imagesChecked.value );
}
function openGallery(sItemCategory){

   if(sItemCategory =="ft"){  //feature
     var file ="ctlGallery.ascx?i=ft";
   }else{  //this is a logo
     var file ="ctlGallery.ascx?i=lg";
   }

    myRef = window.open(''+self.location,'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0');

}
function setVisibility(id, visibility,state) {

    if(state ==1 ){
        document.getElementById(id).className = "infoDivVisible";
    }else{
         document.getElementById(id).className = "infoDivHidden";
    }
}
function setVisibility2(id, visibility,state) {

    if(state ==1 ){
        document.getElementById(id).className = "infoDivVisible2";
    }else{
         document.getElementById(id).className = "infoDivHidden2";
    }
}

function setVisibility3(id, visibility,state) {

    if(state ==1 ){
        document.getElementById(id).className = "infoDivVisible3";
    }else{
         document.getElementById(id).className = "infoDivHidden3";
    }
}

function showLoading(){
     document.getElementById("divLoading").style.visibility="visible"; 
     document.getElementById("dGrab").style.visibility = "hidden";
     
}
function byeBye(){
/*   
  if( document.getElementById("merchantRegistered").value =="Y" ){
     window.open('bye.aspx','bybyeWindow','height=200,width=920'); 
   }else{ 
    //alert("don't show popup");
   } 
   */
}
function selectImageChange(imageNumber, rbId, hiddenId){
  
  //CHECK THE IMAGE
   document.getElementById(rbId).checked =true;
 
   var lastClicked = document.getElementById(hiddenId).value;
   
   //IF IT WAS THE LAST ONE CLICKED SUBMIT THE FORM
   if(lastClicked == imageNumber){
    document.forms[0].ctlImageManager_ctlWebPageImages_saveImages.click();
   }
   //SET THE LAST CLICKED AS THIS IMAGE
   else{
    document.getElementById(hiddenId).value = imageNumber;
   }
   
}
function previewSub(){
   
    window.document.previewSubcategory.submit();
}
function browserClosed(){

    if(  document.getElementById("ctl00_browserClosed").value==0){
         byeBye();
    }else{
      // alert("pass");
    }
}

function userBrowserUnload(){
  document.getElementById("ctl00_browserClosed").value=1; 
}

function resetBrowserCloser(){
    document.getElementById("ctl00_browserClosed").value=0;
}
function checkHTTPPrefix(websiteTextbox){

    var website = websiteTextbox.value;
    var websiteHttp = website.substring(4,0).toLowerCase()
    var websiteHttpS = website.substring(5,0).toLowerCase()

    if(websiteHttp != "http"  && websiteHttpS !="https"){
        websiteTextbox.value = "http://" + website;
    }else{
         websiteTextbox.value = website;
    }
    
 
}


function browserClosed(){

    if(  document.getElementById("ctl00_browserClosed").value==0){
         byeBye();
    }else{
      // alert("pass");
    }
}

function userBrowserUnload(){
  document.getElementById("ctl00_browserClosed").value=1; 
}

function resetBrowserCloser(){
    document.getElementById("ctl00_browserClosed").value=0;
}
<!--vicweb01-->