﻿
function Get_Cookie(check_name) 
        {
	        var a_all_cookies = document.cookie.split( ';' );
	        var a_temp_cookie = '';
	        var cookie_name = '';
	        var cookie_value = '';
	        var b_cookie_found = false; 
	        for ( i = 0; i < a_all_cookies.length; i++ )
	        {
		        a_temp_cookie = a_all_cookies[i].split( '=' );
		        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		        if ( cookie_name == check_name )
		        {
			        b_cookie_found = true;			
			        if ( a_temp_cookie.length > 1 )
			        {
				        cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			        }			
			        return cookie_value;
			        break;
		        }
		        a_temp_cookie = null;
		        cookie_name = '';
	        }
	        if ( !b_cookie_found )
	        {
		        return null;
	        }
      }
    function Set_Cookie( name, value, expires, path, domain, secure )
        {
            var today = new Date();
            today.setTime( today.getTime() );
            if (expires)
            {
            expires = expires * 1000 * 60 * 60 * 24;
            }
            var expires_date = new Date(today.getTime() + (expires));
            document.cookie = name + "=" +escape( value ) +
            ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
            ( ( path ) ? ";path=" + path : "" ) +
            ( ( domain ) ? ";domain=" + domain : "" ) +
            ( ( secure ) ? ";secure" : "" );
            }
            Set_Cookie( 'test','none', '', '/','','');
            if (Get_Cookie('test'))
            {
	            cookie_set = true;		
            }
            else
            {
            cookie_set = false;
            var answer = confirm ("Please Enable Cookies in your Browser for this Site to View")
            if (answer)
            alert ("Ok")
            else
            alert ("Site Will Close")
            self.close();
	
        }

function AlphaNavigation(name,id)
{
    var az = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
    var p,s;

    for (var i=0; i<=25; i++) 
    {
        if(az[i]==id)
        {
            s=i;
        }
        p=name.concat(az[i]);

        document.getElementById(p).className='Alpha_Active';
    }
    p=name.concat(az[s]);
    document.getElementById(p).className='Alpha_InActive';
}

function Check(name)
{
    try
    {    
    var list = document.getElementById(name);   
    var chkBox = list.getElementsByTagName("input");
    var count = 0;    
    for(var i=0;i<chkBox.length;i++)
    {
        if(chkBox[i].type == "checkbox" && chkBox[i].checked )
        {
            count++;
        }
    }        
    if(count == 0)
    {   
        alert("You must select atleast one item");
        return false;
    }
    else
    {
        var i = confirm('Are you sure want to delete?');
        if(i==1)
        {
            return true;
        }
        else 
            return false;
    }
    }
    catch(err)
    {
        alert("No item found.");
        return false;
    }        
}

function CheckCheckBox(name)
{
    try
    {    
    var list = document.getElementById(name);   
    var chkBox = list.getElementsByTagName("input");
    var count = 0;    
    for(var i=0;i<chkBox.length;i++)
    {
        if(chkBox[i].type == "checkbox" && chkBox[i].checked )
        {
            count++;
        }
    }        
    if(count == 0)
    {   
        alert("You must select atleast one item");
        return false;
    }
    else
    {       
            return true;
     }      
    }
    catch(err)
    {
        alert("No item found.");
        return false;
    }        
}

function checkAll()
{
      for(i = 0; i < document.forms[0].elements.length; i++)
      {
            elm = document.forms[0].elements[i]
            if (elm.type == 'checkbox')
            {                  
                elm.checked = true;                  
            }
      }
}

function uncheckAll()
{
      for(i = 0; i < document.forms[0].elements.length; i++)
      {
            elm = document.forms[0].elements[i]
            if (elm.type == 'checkbox')
            {                  
                elm.checked = false;                  
            }
      }
}


function CheckRadioButton(name)
{
    try
    {
        var list = document.getElementById(name);               
        var radio = list.getElementsByTagName("input");                 
        var isCheck = false;        
        for(var i=0;i<radio.length;i++)
        {
            if(radio[i].type == "radio" && radio[i].checked )
            {
                isCheck = true;
            }
        }                
        if(isCheck)
        {           
            return true;
        }
        else
        {
            alert("You must select atleast one item");
            return false;
        }
     }        
     catch(err)
     {         
        alert("No item found.");
        return false;                 
     }
}
function doClick(buttonName,e)
{
    //the purpose of this function is to allow the enter key to 
    //point to the correct button to click.
    var key;
    if(window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox
    
    if (key == 13)
    {
    
      //Get the button the user wants to have clicked
        var btn = document.getElementById(buttonName);
        if (btn != null)
        { //If we find the button click it
            btn.click();
            return false;
            
        }
    }
}
function Confirm(message)
{
    var i = confirm(message);
    if(i==1)
    return true;
    else  
    return false;
}
function SetUniqueRadioButton(nameregex, current)
{
      re = new RegExp(nameregex);
      for(i = 0; i < document.forms[0].elements.length; i++)
      {
            elm = document.forms[0].elements[i]
            if (elm.type == 'radio')
            {
                  if (re.test(elm.name))
                  {
                          elm.checked = false;
                  }
             }
      }
      current.checked = true;
}
 function ValidateEmails(evt)
      {
        var charCode = (evt.which) ? evt.which : event.keyCode        
         if(charCode>47 && charCode<58)
         {
            return true;
         }
         if(charCode==8)
         {
            return true;
         }
         if(charCode>64 && charCode<91)
         {
            return true;
         }     
          if(charCode>96 && charCode<123)
         {
            return true;
         } 
         if(charCode==64)
         {
            return true;
         }
         if(charCode==190)
         {
            return true;
         }
         alert('Only Alphanumeric Characters ,@,dot are allowed')
         return false;
      }
      function ValidateDescription(evt)
      {
         if(charCode==8)
         {
            return true;
         }
        if(charCode==34)
         {
            return true;
         }
         if(charCode==39)
         {
            return true;
         }
         if(charCode>47 && charCode<58)
         {
            return true;
         }
         if(charCode>64 && charCode<91)
         {
            return true;
         }     
          if(charCode>96 && charCode<123)
         {
            return true;
         }
          if(charCode==188)
         {
            return true;
         }
         if(charCode==190)
         {
            return true;
         }
         alert('Only Alphanumeric Characters ,comma,dot,",Single Quotes  are allowed')
         return false;
      }
       function ValidateUrl(evt)
      {
        var charCode = (evt.which) ? evt.which : event.keyCode
         if(charCode==8)
         {
            return true;
         }
          if(charCode==38)
         {
            return true;
         } 
          if(charCode==45)
         {
            return true;
         }
         if(charCode>46 && charCode<58)
         {
            return true;
         }
          if(charCode==63)
         {
            return true;
         }
         if(charCode>64 && charCode<91)
         {
            return true;
         }
          if(charCode>94 && charCode<123)
         {
            return true;
         }          
         if(charCode=190)
         {
            return true;
         }        
         alert('Only Alphanumeric Characters ,?,/,dot,&,Hypen is allowed')
         return false;
      }
      function ValidateText(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode  
          if(charCode==8)
         {
            return true;
         }      
         if (charCode==32)
         {
             return true;
         }
         if(charCode>47 && charCode<58)
         {
            return true;
         }
         if(charCode>64 && charCode<91)
         {
            return true;
         }
          if(charCode>96 && charCode<123)
         {
            return true;
         } 
         alert('Only Alphanumeric Characters and whitespace is allowed')
         return false;
      }
     function tab3(val, name, num){
	var b = name;
	var a = val;
		if(val==1){
			document.getElementById(b+'_1').className='Visible';
			document.getElementById(b+'_2').className='Invisible';	
			document.getElementById(b+'_ImgL_1').className='st3';
			document.getElementById(b+'_ImgR_1').className='st12';
			document.getElementById(b+'_ImgR_2').className='st10';
			document.getElementById(b+'_ImgH_1').className='st2';
			document.getElementById(b+'_ImgH_2').className='st1';
		}
		if(val==2){
			document.getElementById(b+'_2').className='Visible';
			document.getElementById(b+'_1').className='Invisible2';
			document.getElementById(b+'_ImgL_1').className='st3a';
			document.getElementById(b+'_ImgR_1').className='st12a';
			document.getElementById(b+'_ImgR_2').className='st10a';
			document.getElementById(b+'_ImgH_1').className='st1';
			document.getElementById(b+'_ImgH_2').className='st2';
		}
} 
function tab4(divStart, id, no)
{
	for (var i=1; i<=no; i++) 
	{	
	    document.getElementById(divStart+'_'+i).className='Invisible';	
	    document.getElementById(divStart+'t'+i).className='tabnoactive';		
	}
	document.getElementById(divStart+'_'+id).className='Visible';	
	document.getElementById(divStart+'t'+id).className='tabactive';			
}
function PopUpWin(Url, Width, Height) 
{
    w = screen.availWidth;
    h = screen.availHeight;

    var popW = Width, popH = Height;

    var leftPos = (w-popW)/2, topPos = (h-popH)/2;

    //half the screen width minus half the new window width (plus 5 pixel borders).
    iMyWidth = (window.screen.width/2) - (Width + 10);
    
    //half the screen height minus half the new window height (plus title and status bars).
    iMyHeight = (window.screen.height/2) - (Height + 50);
    
    //Open the window.
    newWindow=window.open(Url,'popup','width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos);
    newWindow.focus();

}
