﻿// JScript File
<!--
var popupWin = new Object();

function openDialogwithAttr(url, width, height, returnFunc, attributes, args)
{
  //  if (!popupWin.win || (popupWin.win && popupWin.win.closed))
  //  {

        // Initialize properties of the modal dialog object.
        popupWin.returnFunc = returnFunc;

        popupWin.returnValue = "";
        popupWin.returnValueExt = "";
        popupWin.args = args;
        popupWin.url = url;
        popupWin.width = width;
        popupWin.height = height;

        // Keep name unique so Navigator doesn't overwrite an existing dialog.
        popupWin.name = (new Date()).getSeconds().toString();

        // Assemble window attributes and try to center the dialog.
        // The best we can do is center in screen.
        popupWin.left = (screen.width - popupWin.width) / 2;
        popupWin.top = (screen.height - popupWin.height) / 2;
        var attr = 'left=' + popupWin.left + ',top=' + popupWin.top;
        attr += ',width=' + popupWin.width + ',height=' + popupWin.height + ',' + attributes;
        // Generate the dialog and make sure it has focus.

        //alert("About to open popup window: " + url);
        //alert(popupWin.name);
        popupWin.win=window.open(popupWin.url, popupWin.name, attr);
        popupWin.win.focus();

   // } else
  //  popupWin.win.focus();
} 
function ValidateContactUsForm()
{
    var oRD = document.aspnetForm.ctl00$ctl00$ContentPlaceHolder1$Contentplaceholder1$RadioButtonList1;
    var oEmail = document.aspnetForm.ctl00$ctl00$ContentPlaceHolder1$Contentplaceholder1$TextBoxEmail
    var oFirstName = document.aspnetForm.ctl00$ctl00$ContentPlaceHolder1$Contentplaceholder1$TextBoxFirstName
    var oLastName = document.aspnetForm.ctl00$ctl00$ContentPlaceHolder1$Contentplaceholder1$TextBoxLastName
    var oComments = document.aspnetForm.ctl00$ctl00$ContentPlaceHolder1$Contentplaceholder1$TextBoxComments
   
    if(!CheckforValue(oComments, "Please enter your questions or comments before submitting this form."))
            return;
            
    if (oRD[0].checked == true){
        if(!CheckforValue(oEmail, "To receive a copy of this message, your email is required"))
            return;
        if(!validateEmailWebsite(oEmail, "Email address", false, true))
            return;            
        if(!CheckforValue(oFirstName, "To receive a copy of this message, your first name is required"))
            return;
        if(!CheckforValue(oLastName, "To receive a copy of this message, your last name is required"))
            return;
    }
   document.aspnetForm.ctl00$ctl00$ContentPlaceHolder1$Contentplaceholder1$HiddenField1.value = "S";
   document.aspnetForm.submit();    
}
function CheckforValue(oField, sVal)
{
  
    if(oField.value.length < 1){
        alert(sVal);
        oField.focus();
        return false;        
    }
     return true;   
}
function validateEmailWebsite(oField,addtype,man,db) 
{
    var addr = oField.value;
            
    if (addr == '') {
        if(man){
            if (db) alert(addtype + ' is mandatory');
            return false;
        }
         else
            return true;
        }
                     
        var atPos = addr.indexOf('http://',0);
        if (atPos == 0) {
        if (db) alert('Please do not enter http://');
        return false;
    }
    var atPos = addr.indexOf('HTTP://',0);
    if (atPos == 0) {
        if (db) alert("Please do not enter  'http://' in your website address");
        return false;
    }
    if(addtype == 'Email address')
        var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
    else
        var invalidChars = '\'\\ ";:?!@()[]\{\}^|';
    for (i=0; i<invalidChars.length; i++) {
        if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
            if (db) alert(addtype + ' contains invalid characters');
            return false;
        }
    }
    for (i=0; i<addr.length; i++) {
        if (addr.charCodeAt(i)>127) {
            if (db) alert(addtype + ' contains non ascii characters.');
            return false;
        }
    }
    if(addtype == 'Email address'){
        var atPos = addr.indexOf('@',0);
        if (atPos == -1) {
            if (db) alert(addtype + '  must contain an @');
                return false;
        }
    }
    var atPos = addr.indexOf('.',0);
    if (atPos == -1) {
        if (db) alert(addtype + '  must contain an .');
        return false;
    }
    if (atPos == 0) {
        if (db) alert(addtype + '  must not start with .');
        return false;
    }
    if (addr.indexOf('..',0) != -1) {
        if (db) alert('two periods must not be adjacent in ' + addtype);
        return false;
    }
    // var suffix = addr.substring(addr.lastIndexOf('.')+1);
    // if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
    // if (db) alert('invalid primary domain in ' + addtype + '. Examples of primary domains are .com, .edu, .net and .org');
    // return false;
    // }
    return true;
} 
function resetCount(textArea,counterField,maxLength)
{
    counterField.value = maxLength - textArea.value.length;
}
function countCharacters(textArea, counterField, maxLength)
{
    if(textArea !=null && textArea.value != null) {
        if (textArea.value.length > maxLength){
            alert("Your message may not exceed " +  maxLength +" characters in length.");
            textArea.value = textArea.value.substring( 0, maxLength);
            //alert(textArea.value);
        } else {
            counterField.value = maxLength - textArea.value.length;
        }
    }
} 
function SelectedImage()
{
    nID = getQueryVariable("LID");
    
    sImageID = "img"+nID;
    sImgName = "hidimg" + nID;
   
   if(nID != ""){
    sImgSrc = document.getElementById(sImgName).value;
    
    document.getElementById(sImageID).src = sImgSrc;
    } 
    
  //  alert(document.getElementById(sImageID).src);
  //  alert(document.getElementById(sImageID).onmouseover);
    
}
function getQueryVariable(variable) {
    var temp = ""
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      temp = pair[1];
    }
  }  
  return  temp;
}
function handleOut(oField)
{
    sImgName = "hidimg" + nID;
    sImgSrc = document.getElementById(sImgName).value;
    sBWImgSrc = document.getElementById(sBWImage).value;
    imgID = oField.id;
    imgID2 = document.getElementById("img"+nID).id;
    document.getElementById(imgID).src = sBWImgSrc;
    //alert(oField.id);
    alert(oField.id == document.getElementById("img"+nID).id);
        
    alert(document.getElementById(imgID).src);
    if(imgID == imgID2)
        document.getElementById(imgID).src = sImgSrc;
    
    
}
function ShowArticle(oField, name)
{   
    if(oField.value.length > 0)
        window.location = name + '.aspx?NID=' + oField.value;
}

-->
