﻿function openPopupWindow(winWidth,winHeight,winURL,winName,winInstance) {
    
    screenWidth = window.screen.width;
    screenHeight = window.screen.height;                        
    
    popupOffsetX=(screenWidth/2) - (winWidth/2);
    popupOffsetY=(screenHeight/2) - (winHeight/2);
                
    winFeatures = "toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=0,scrollbars=0,width="+winWidth+",height="+winHeight+",left="+popupOffsetX+",top="+popupOffsetY+"modal=yes";
   
    winInstance = window.open(winURL, winName, winFeatures);     
    winInstance.focus();                 
}

function submitForm(pageIndex) {
    
    document.forms[0].page.value = pageIndex;
    document.forms[0].submit();
}

function previuosPage() {
    
    document.forms[0].page.value = parseInt(document.forms[0].page.value) - 1;
    document.forms[0].submit();
}

function nextPage() {
    
    document.forms[0].page.value = parseInt(document.forms[0].page.value) + 1;            
    document.forms[0].submit();
}   

function imageHoverOnOff(imageInstance,imageUrl) {
    
    imageInstance.src=imageUrl;
}


function openPictureWindow(imgName,width,height) {
    
    winWidth = window.screen.width;
    winHeight = window.screen.height;
    
    popupWidth=width;
    popupHeight=height;
    
    popupOffsetX=(winWidth/2) - (popupWidth/2);
    popupOffsetY=(winHeight/2) - (popupHeight/2);
        
    winPopup = window.open('showimage.html','Blank','toolbar=0,menubar=0,location=0,directories=0,status=0,resizable=0,width='+popupWidth+',height='+popupHeight+',left='+popupOffsetX+',top='+popupOffsetY+'modal=yes');     
    winPopup.document.open();
    winPopup.document.write("<html><head></head><body leftmargin='0' topmargin='0' bottommargin='0' rightmargin='0' bgcolor='#000000'>");
    winPopup.document.write("<img src='" + imgName + "' width='" + width + "' height='" + height + "' border='0' alt=''>");
    winPopup.document.write("</body></html>");
    winPopup.document.close();
    
    winPopup.focus();    
}

function validateNumber(event, obj) {

    var code = (event.which) ? event.which : event.keyCode;
    var character = String.fromCharCode(code);
 
    if ((code >= 48 && code <= 57)) { 
    
      if (obj.value.indexOf(".") == obj.value.length-1) { 
      
        if (code == 48) {
          return false;
        }
        else {
          return true;
        }
      } else {
        return true;
      }
    }
    else if (code == 46) { 
    
      if (obj.value.indexOf(".") < 0) return true;
    }
    else if (code == 8) {
      return true;
    }   
 
    return false;
} 
  
  
function validateField(obj) { 
   
    if (obj.value.indexOf(".") == obj.value.length-1) {

        obj.value = obj.value.substring(0, obj.value.length-1)
    } 
    if (obj.value == "") {

        obj.value = "0"
    } 
} 

function mailCheck(email) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   
   if(reg.test(email) == false) {      
      return false;
   }
   return true;
}


