﻿//var dom=getObj
//init();

var dom=getObj

  function getObj(objID) 
	{
	    if (document.getElementById)
	    {
	        if (document.getElementById(objID)==null)
	        objID="ctl00_cphContent_"+objID;
	        
	        return document.getElementById(objID)
	    }
	    else if (document.all)
	    {
	        if (document.all(objID)==null)
	        objID="ctl00_cphContent_"+objID;
	        
	        return document.all[objID];
	    }
	    else if (document.layers)
	    {
	        if (document.layers(objID)==null)
	        objID="ctl00_cphContent_"+objID;
	        	    
	        return document.layers[objID];
	    }
	}

    function PasswordLength(sender,args)
    { 
        inputStr = getObj("txtPassword").value;
      
        if(inputStr.length > 5 && inputStr.length<=20 )
	    {
	        args.IsValid=true;
	        return;
	    }
	    args.IsValid=false;
	    return;
    }
    
    function RequiredConfirmPassword(sender,args)
    {
        inputStr1 = getObj("txtPassword").value;
        inputStr2 = getObj("txtConfirmPassword").value;
        
        if(inputStr1.length > 0 )
	    {
	        if(inputStr2.length < 1)
	        {
		        args.IsValid=false;
		        return;
		    }
	    }
	    args.IsValid=true;
	    return;
    }

//Function For Checking All Check box in Grid
function SelectGrid(oTemp,nGridNumber)
{
	
	var oGrid, sGrid;
	if (nGridNumber==1){ oGrid=eval("getObj('grdData')"); sGrid="grdData";}
	
	var sColor,sCheck;				
			
	if(oTemp.checked==true)
	{
		sColor = "#wwwwww";
		sCheck = true;
	}
	else
	{
		sColor = "#wwwwwww";
		sCheck = false;
	}
	
	
	for(i=2;i<=oGrid.rows.length+1;i++)
	{		
		if(i<10)
			{ctrli="0" + i;}
		else
			{ctrli= i;}
			
		var oCheck = eval("getObj('"+sGrid +"_ctl" + ctrli + "_chkDelete')");
		
		if (oCheck)
		{				
			if(oCheck.disabled==false)
			{
				oCheck.checked = sCheck;
			}
		}
	}
	

}

//Function For UnChecking All Check box in Grid
function UnSelectGrid(oTemp,nGridNumber,checkBoxName)
{
	var oGrid, sGrid;
	if (nGridNumber==1){ oGrid=eval("getObj('grdData')"); sGrid="grdData";}
	
	var sCheck;				
			
	if(oTemp.checked==true)
	{
		sCheck = true;
	}
	else
	{
		sCheck = false;
	}
	
	 for(i=1;i<=oGrid.rows.length+1;i++)
    {	
	
        if(i<10)
			    {ctrli="0" + i;}
		    else
			    {ctrli= i;}
				
	    var oCheck = eval("getObj('"+sGrid +"_ctl" + ctrli + "_chkDeleteAll')");
	    if (oCheck)
	    {			 					
		    if(sCheck==false)
		    {
			    oCheck.checked = false;
		    }
				
	    }
    }
	
	
}


//Function To Loop Through Checkboxes in Datagrid and check if any Checkbox is SELECTED
function confirmDelete(nGridNumber,what,page)
{
    var selected=0;
	var oGrid, sGrid;
	
	
	if (nGridNumber=='1'){oGrid=eval("getObj('grdData')"); sGrid="grdData";}
	

    for(i=1;i<=(oGrid.rows.length+1);i++)
    {	
	    
        if(i<10)
		    {ctrli="0" + i;}
	    else
		    {ctrli= i;}
				
	    var oCheck = eval("getObj('"+sGrid +"_ctl" + ctrli + "_chkDelete')");		    
	    
	    if (oCheck)
	    {		       
	        if (oCheck.checked)
	        {		
	    	    if(what != "Email" && what != "Donate")
			    {
			        selected=1;
				    return confirm ('Are you sure you want to' + ' ' + what + ' ' + 'your selection(s)?')
			    }
	        }
	    }
    }
    
    if(selected==0)
    { 
    
       // alert('Please select items to' + ' ' + what);
     
        alert('Please select which '+ page + '(s) you want to ' +what);
	    return false;
	}

}

//For Enter Button
function enterSubmit()
{   
    DisableSubmitButtonID = eval("getObj('ctl00_DisableSubmitButtonID').value");
    
    if(DisableSubmitButtonID != '0')
    {   
        var id = eval("getObj('ctl00_SubmitButtonID').value");
        if(id=="")
        {
            return;
        }
        else
        {
            if(id.indexOf(',') !=-1)
            {
                var obtnId = new Array();
                obtnId = id.split(',');
                for(i=0; i<obtnId.length;i++)
                {
                    if(getObj(obtnId[i]))
                    {
                       getObj(obtnId[i]).focus(); 
                     
                    }
                } 
            }
            else
            {
                getObj(id).focus();        
            } 
         }
    }
}

function disableSubmit()
{		
    getObj('ctl00_DisableSubmitButtonID').value="0";    
}

function enableSubmit()
{
    getObj('ctl00_DisableSubmitButtonID').value="1";
}


//Function for Redirecting the page to specified loacation within some time specified.
function SplashScreenSeconds(url, msg)
{
   var TARG_ID = "spanSplashScreenSeconds";//Span declared in html form
   var DEF_MSG = "Redirecting...";

   if( ! msg )
   {
      msg = DEF_MSG;
   }

   if( ! url )
   {
      throw new Error('You didn\'t include the "url" parameter');
   }

   var e = document.getElementById(TARG_ID);

   if( ! e )
   {
      throw new Error('"spanSplashScreenSeconds" element id not found');
   }

   var cTicks = parseInt(e.innerHTML);

   var timer = setInterval(function()
   {
      if( cTicks )
      {
         e.innerHTML = --cTicks;
      }
      else
      {
         clearInterval(timer);
         //document.body.innerHTML = msg;
         location = url;	  
      }

   }, 1000);
}

function resolveURLmouseovermouseout(buttonname,imageurl)
{
	document.getElementById(buttonname).src=imageurl;
}

 function RelativePath()
{

    // Remove any frames
//    if (top.location != self.location) {
//      top.location = self.location;
//    }

    var url = self.location.href;
    url = url.toLowerCase();
    var path = '';
    
    // determine the server   
    var local = 'localhost/';
    var server = 'server/';
    var live  = 'rusticmotel.com/';
    var livesitepreview  = '/rusticmotel-com';   
    var newwebsite  = '/newwebsite'; 
    
    if(url.lastIndexOf(local) > 1)
        path = "http://localhost/RusticMotel/";
    else if(url.lastIndexOf(server) > 1)
        path = "http://server/RusticMotel/";   
    else if(url.lastIndexOf(live) > 1)
        path = "http://www.rusticmotel.com/";
    else if(url.lastIndexOf(livesitepreview) > 1)
        path = "http://rusticmotel-com.sitepreview.ca/";
    else if(url.lastIndexOf(newwebsite) > 1)
        path = "http://rusticmotel-com.sitepreview.ca/newwebsite/";
    
    return path;
}