﻿// JScript File
   function isValidEntry()
   {
   
     var errorHeader = 'Please correct the following errors:\n';
     var errorMessage= '';
     
     var allNodes = $('txtName', 'txtEmail', 'txtComment');
     
     for(i=0; i<allNodes.length; i++)
     {
          
       if(allNodes[i].value.empty() || allNodes[i].value.blank())     
       {
         switch(i)
         {
          case 0:
            errorMessage += '- name should not be blank\n';
            break;
          case 1:
            errorMessage += '- email should not be blank\n';
            break;
          case 2:
            errorMessage += '- comment should not be blank\n';
            break;
         }
       }
     }
     
     if(!isEmailAddress($F('txtEmail')))
     {
       errorMessage +='- email should not be in a valid format\n';
     
     }
     
     if(errorMessage != '')
     {
       alert(errorHeader + errorMessage);
       $('txtName').focus();
       return false;
       
     }
        return true;
      
    }     
    
    function sendMail()
    {

       var formName = $('contactUsForm');
       
       formName.request(
        {
         onComplete: mailResponse
        
        }
       
       );

    }
    
    function mailResponse(originalRequest)
    {
        windowjsAlert(originalRequest.responseText);   

//        var formName = $('contactUsForm');
//        formName.reset();
//        $('txtName').focus();
        

    }
    
    function doSendAction()
    {
      if(isValidEntry())
      {
       sendMail();
       return true;
      }
      else
      {
       return false;
      
      }
    
    }
    
    function blurAnchors()
    {
        if(document.getElementsByTagName)
        {
            var a = document.getElementsByTagName("a");
            for(var i = 0; i < a.length; i++)
            {
                a[i].onfocus = function(){this.blur()};
            }
        }
    }
    
    // image gallery script
    
    function showImage(img_id, img_cat_id)
    {
     
     var url= "getimagepath.ashx";
     var par= "img_id=" +img_id+ "&img_cat_id=" +img_cat_id;
     var myAjax = new Ajax.Request(
                  url,
                  {
                    method: 'get',
                    parameters: par,
                    onComplete: showResponse
                  });
    
    }
    
    
    function showResponse(originalRequest)
    {
     $("divImage").innerHTML = originalRequest.responseText;
    }
    
    function returnImgfile(img_file)
    {
    
       window.opener.document.getElementById('ctl00_ContentPlaceHolder1_txt_imgFilename').value = img_file;
       window.opener.document.getElementById('ctl00_ContentPlaceHolder1_divImageHolder').innerHTML= "<img width='200' height='220' src='../_admin/_uploads/" + img_file + "'/>"
       
       window.close();
    }   
    
    function openGalleryViewer()
    {
       window.open("aspnet_imageViewer.aspx","myWindow","location=1, status=1, scrollbars=1, width=600, height=510");
       return false;
    
    }
    
    function confirmDelete(message, URL)
    {
     Dialog.confirm(message,
      {
       width: 300,
       className: "alphacube",
       okLabel: "Delete",
       cancelLabel: "Cancel",
       id: "myDialogID",
       onOk: function(){location.href= URL; return true;}
      });
    }
    
    function showBlurbPopup(imagePath, blurbTitle)
    {
     var win = new Window(
     {
        className: "alphacube",
        title: blurbTitle,
        width: 500,
        height: 600,
        destroyOnClose: true,
        recenterAuto: true
     });
   
    win.getContent().update("<img src=" + imagePath + "></img>");
    win.showCenter();
    
    }
    
    function windowjsAlert(message)
    {
     Dialog.alert(message,{
       width: 300,
       className: "alphacube",
       okLabel: "Ok",
       id: "myDialogID",
       onOk: function(){window.location="index.aspx";}
     });
    
    }
    
  
    
    