/*
This Function chekc for require field and set focus on the controls.
Developed By Nikhil.27/12/2004
How to Use:
		  To Use this function you have to put required as starting of 
		  anf textbox field.
		  And put checkrquired(this) in submit button.	
*/
function enlarge(LImg,stitle)
{
myWindow = window.open("","", 'width=1,height=1,top=10,left=200,toolbar=yes,scrollbars=yes')
myWindow.document.write("<html><head><title>"+stitle+"</title></head>")
myWindow.document.write("<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onload='window.resizeTo(img.width+50,img.height+60);'>")
myWindow.document.write("<table width=100% border=0><tr bgcolor=#D0AA37><td style=PADDING-LEFT: 5px><font color=white size=2px face=Tahoma><b>"+stitle+"</b></font></td></tr></table>")
myWindow.document.write("<div align=Center><img  src='"+ LImg +"'  id='img'></div></body></html>")
myWindow.document.close()
}
function myPopUp(wt,ht,strscroll)
{
  window.open('Terms.aspx',null,'width='+wt+',height='+ht+',status= no, resizable= no, scrollbars='+strscroll+', toolbar=no,location=center,menubar=no, top=20, left=100');
}
function myPopUp1(ppt)
{
  window.open(ppt,null,'width=600,height=600,status= no, resizable= no, scrollbars=no, toolbar=no,location=center,menubar=no, top=20, left=100');
}		
function checkrequired(which) {
var blneCheck=false;
var pass=true;
if (document.images) 
{
  
  for (i=0;i<which.length;i++) 
	{
	var tempobj=which.elements[i];	
	if (tempobj.name.substring(0,8)=="required") 
		{		
		if (((tempobj.type=="text"||tempobj.type=="textarea")&&
		tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
		tempobj.selectedIndex==0)) 
			{
				pass=false;
				break;
			}
		}
   
	if (tempobj.name.substring(0,8)=="erequire") 
		{			
			if(tempobj.type=="text" && tempobj.value=='')
			{
				pass=false;
				break;
			}			
			else 
			{
				
				if(echeck(tempobj.value)==false)
				{						
					blneCheck=true;
					pass=false;
					break;					
				}
			 }					        
		}
	}
 }  

if (!pass) 
{

   if (tempobj.name.substring(0,8)=="required")
   {			
		shortFieldName=tempobj.name.substring(8,30).toUpperCase();		
		tempobj.focus();
		alert("Please make sure the "+shortFieldName+" field was properly completed.");
		return false;
	}
	if (tempobj.name.substring(0,8)=="erequire") 
	{
		if(!blneCheck)
		{
			shortFieldName=tempobj.name.substring(8,30).toUpperCase();
			tempobj.focus();
			alert("Please make sure the "+shortFieldName+" field was properly completed.");	
			return false;
		}
		else
		{
			shortFieldName=tempobj.name.substring(8,30).toUpperCase();
			tempobj.focus();
			alert("Please make sure email address in "+shortFieldName+" was properly completed.");	 
			return false;
		}
    }
}  
else
{
	return true;
}
	
}



/*
This Function check for valide emaill address.
Developed By Nikhil.27/12/2004
How to Use:
		   Just pass the string that has to be check for required email address.	
		  
*/


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){		   
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){		  
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){		   
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){		    
		    return false
		 }
 		 return true					
	}	


function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal) 
{

        re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon

        for(i = 0; i < document.forms[0].elements.length; i++) {

            elm = document.forms[0].elements[i]

            if (elm.type == 'checkbox') {

                if (re.test(elm.name)) {

                    elm.checked = checkVal

                }
            }
        }
	}

function CheckCheckBoxes(aspCheckBoxID, checkVal) 
{	
	re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon				
	var strcount="1";
	for(i = 0; i < document.forms[0].elements.length; i++) 
		{
			elm = document.forms[0].elements[i]
			if (elm.type == 'checkbox') 
			   {						
				if(elm.checked==true)
					{							
						strcount =strcount + "11" ;
				
					}
						
				}
		}				
	
	if(strcount=="1")
		{
					alert('No record selected.');
					return false;
		}
	else
		{
					return confirm('Are you sure to delete Record?')
					//return true;				
		}
				
	}	
function CheckEditCheckBoxes(aspCheckBoxID, checkVal) 
{	
	re = new RegExp(':' + aspCheckBoxID + '$')  //generated control name starts with a colon				
	var strcount="1";
	for(i = 0; i < document.forms[0].elements.length; i++) 
		{
			elm = document.forms[0].elements[i]
			if (elm.type == 'checkbox') 
			   {						
				if(elm.checked==true)
					{							
						strcount =strcount + "11" ;
				
					}
						
				}
		}				
	
	if(strcount=="1")
		{
					alert('No record selected.');
					return false;
		}
	else
		{
					
					return true;				
		}
				
	}		