﻿// JScript File
   function AlertMessage(msg)
    {
        document.getElementById("lblErrorMessage").innerText = msg;
        document.getElementById('lblErrorMessage').style.display = 'block';
    }  
/****************** Close Window ************************/
    var newwindow = '';

function popitup(url,name,width,height) {    
    if (!newwindow.closed && newwindow.location) { 
        newwindow.close();    
    }
    
    newwindow=window.open(url,name,'width=' + width + ',height=' + height + ',scrollbars=no');
	if (!newwindow.opener) newwindow.opener = self;
    
    if (window.focus) {newwindow.focus()}
    return false;
}

function popitups(url,name,width,height) {    
    if (!newwindow.closed && newwindow.location) { 
        newwindow.close();    
    }
    
    newwindow=window.open(url,name,'width=' + width + ',height=' + height + ',scrollbars=yes');
	if (!newwindow.opener) newwindow.opener = self;
    
    if (window.focus) {newwindow.focus()}
    return false;
}

function popitupclose() {       
    if (!newwindow.closed && newwindow.location) { 
        newwindow.close();    
    } 
}
   
function closeWindow()
{
     window.close();   
     return false;  
}

function checkPasswd()
    {
    if(document.getElementById("txtPassword").value=="") 
    // V alert("Password Cannot be blank");
    {
     document.getElementById("lblerrCnfrmPswrd").innerText = "Please enter your password";
     document.getElementById("lblerrCnfrmPswrd").style.display = "inline";
     return false;
     }
    }
 
function ValidateEmail()
{
var emailaddress="Please enter a valid email address";
var emailadd="Please enter your email address";
if(document.getElementById("txtEmailAddress").value =="")
    {  
       document.getElementById("lblEmailMsg").innerText=emailadd;
       document.getElementById("lblEmailMsg").style.display="inline";
     }  
    else
		document.getElementById("lblEmailMsg").style.display="none";

    if(document.getElementById("txtEmailAddress").value != "")
    {
        var email = TrimAll(document.getElementById("txtEmailAddress").value); 
        
        var regExpEmail =/\w+([.']\w+)*@\w+([.]\w+)*\.\w+([.]\w+)*/;
        
        if(email.search(regExpEmail) == -1)
            {    
                 document.getElementById("lblEmailMsg").innerText=emailaddress;
                 document.getElementById("lblEmailMsg").style.display="inline";
            }
            else
            {
                 document.getElementById("lblEmailMsg").style.display="none";
            }
    }
}	
//function AcceptConditions2()
//{
//alert('hi');
//var imageButtonAdd = document.getElementById("imbSubmitCase");
//if(document.getElementById("chkAccept").checked==false) 
//{
//    imageButtonAdd.disabled=false;

//    imageButtonAdd.src="../App_Themes/TWPI/images/buttons/submit_btn.gif";
//    document.getElementById("chkAccept").checked=false;

//}
//else
//{
//    imageButtonAdd.disabled=true;
//    imageButtonAdd.src="../App_themes/TWPI/images/buttons/submit_case2.gif";
//    document.getElementById("chkAccept").checked=true;
//}
//}		
//function validateCaseSearch()
	//{
	//if((document.getElementById("txtSearch").value)=="")
	//{
	   //document.getElementById("lblCaseSearchMsg").style.display="inline";
	   
	   //}
	   //else
	   //{
	    //document.getElementById("lblCaseSearchMsg").style.display="none";
	    //}
	// }   		
	 //Added By Vishad to format each header row of table.
    function formatHeaderRowOfTable(tableId, cell1CSSClass, endCellCSSClass, bgc){
        
        var tblObj = document.getElementById(tableId);
        if(tblObj != null && tblObj.rows.length>1){
            tblObj.rows[0].cells[0].className=cell1CSSClass;            
            tblObj.rows[0].cells[0].style.backgroundColor=bgc;  
            tblObj.rows[0].cells[tblObj.rows[0].cells.length-1].className=endCellCSSClass;  
            tblObj.rows[0].cells[tblObj.rows[0].cells.length-1].style.backgroundColor=bgc;  
            
        }
        
    }
    
    function formatHeaderRowOfTableLeft(tableId, cell1CSSClass, endCellCSSClass, bgc){
        var tblObj = document.getElementById(tableId);
        //alert(tblObj.rows.length);
        if(tblObj != null && tblObj.rows.length>1){
            tblObj.rows[0].cells[0].className=cell1CSSClass;            
            tblObj.rows[0].cells[0].style.backgroundColor=bgc;             
            
        }
        
    }
    function formatHeaderRowOfTableRight(tableId, cell1CSSClass, endCellCSSClass, bgc){
        
        var tblObj = document.getElementById(tableId);
        if(tblObj != null && tblObj.rows.length>1){     
            tblObj.rows[0].cells[tblObj.rows[0].cells.length-1].className=endCellCSSClass;  
            tblObj.rows[0].cells[tblObj.rows[0].cells.length-1].style.backgroundColor=bgc;  
            
        }
        
    }
        
    function downloadCustomerResponseDoc(relativeFilePath)
    {        
        window.open(relativeFilePath);
        window.close()
    }
    function  validateCharacterLimit(limitField, limitCount, limitNum){    
		
		if (limitField.value.length > limitNum) {
			limitField.value = limitField.value.substring(0, limitNum);
		} else {
			limitCount.value = limitNum - limitField.value.length;
		}

		
    }
    
function isDate(txtDate)
{  
   var objDate;  // date object initialized from the txtDate string  
   var mSeconds; // milliseconds from txtDate  
   
   // date length should be 10 characters - no more, no less  
   if (txtDate.length != 10) return false;  
   
   // extract day, month and year from the txtDate string  
   // expected format is dd/mm/yyyy  
   // subtraction will cast variables to integer implicitly  
   var day   = txtDate.substring(0,2)  - 0;  
   var month = txtDate.substring(3,5)  - 1; // because months in JS start with 0  
   var year  = txtDate.substring(6,10) - 0;  
   
   // third and sixth character should be /  
   if (txtDate.substring(2,3) != '/') return false;  
   if (txtDate.substring(5,6) != '/') return false;  
   
   // test year range  
   if (year < 999 || year > 3000) return false;  
   
   // convert txtDate to the milliseconds  
   mSeconds = (new Date(year, month, day)).getTime();  
   
   // initialize Date() object from calculated milliseconds  
   objDate = new Date();  
   objDate.setTime(mSeconds);  
   
   // compare input parameter date and created Date() object  
   // if difference exists then date isn't valid  
   if (objDate.getFullYear() != year)  return false;  
   if (objDate.getMonth()    != month) return false;  
   if (objDate.getDate()     != day)   return false;  
   
   // otherwise return true  
   return true;  
}  