//////////////////////////////////////////////////////
////// Function for Count the text for text area /////
//////////////////////////////////////////////////////

function textCounter(field1,maxlimit) {
field = document.getElementById(field1);

if (field.value.length > maxlimit) 
// if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////

//*******************************************//
//	  Function For Window Show and hide     //
//*****************************************//
//shailesh 29-3-2006
function see_more2(objec,sym1,sym2){
	symbl1 = document.getElementById(sym1);
	symbl2 = document.getElementById(sym2);
	obj = document.getElementById(objec);
	if (obj.style.display=='none')
	{
		obj.style.display='';
		symbl1.style.display='none';
		symbl2.style.display='';	

	}
	else{
	obj.style.display='none';
	symbl1.style.display='';
	symbl2.style.display='none';	

	}
}
//*******************************************//
//	  Function For Window popup             //
//*****************************************//

function window_location(file)
{
 window.location=file;
}
//*******************************************//
//	  Function For Email Validation         //
//*****************************************//

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){
//		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
//		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
//		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
//		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
//		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
//		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
//		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true					
	}


//*******************************************//
//	  Function For NullValue Validation     //
//*****************************************//
	
function nullval(m1,m2)
{
var msgarr=new Array();
var alt="";
msgarr=m1.split("!");
messarr=m2.split("!");
//alert(msgarr.length);
	for(j=1;j<msgarr.length;j++)
	{			
		var x=document.forms[msgarr[0]].elements[msgarr[j]].value;
              
		a=x.length;
           
            
	 
		for(i=0;i<x.length;i++)
		{	if(x.charAt(i)=="" || x.charAt(i)=="")
			{a=a-1;}
                     
		}
		if(a==0)
		{
			//var r= document.forms[msgarr[0]].elements[msgarr[j]].name+"\n";
			//alert(document.forms[msgarr[0]].elements[msgarr[j]].name);
			alt = alt+	messarr[j-1] +"\n";
		}
	}
       if(alt=="")
	{
             
		for(i=0;i<document.forms[msgarr[0]].length;i++)
		{
					
			if(document.forms[msgarr[0]].elements[i].id=='txtMail')
			{
				var s1=document.forms[msgarr[0]].elements[i].value;
				if(s1!="")
				{
					if(echeck(s1)==false)
					{
						alert('Please enter valid email address');
						return false;
					}
				}
			}

                     if(document.forms[msgarr[0]].elements[i].id='LocationImage1')
                    {
                          
                        var s1=document.forms[msgarr[0]].element[i].value;
                        
                        if(s1!="")
                        {
                            
                              if(echeck(s1)==false)
                              {
                                     alert('Please enter thumbnail image');
                                     return false;
                              }   
                         }
                    }
                    if(document.forms[msgarr[0]].elements[i].id='LocationImage2')
                    {
                          
                        var s1=document.forms[msgarr[0]].element[i].value;
                        
                        if(s1!="")
                        {
                            
                              if(echeck(s1)==false)
                              {
                                     alert('Please enter thumbnail image');
                                     return false;
                              }   
                         }
                    }

                     if(document.forms[msgarr[0]].elements[i].id='LocationImage3')
                    {
                          
                        var s1=document.forms[msgarr[0]].element[i].value;
                        
                        
                        if(s1!="")
                        {
                            
                              if(echeck(s1)==false)
                              {
                                     alert('Please enter thumbnail image');
                                     return false;
                              }   
                         }
                    }

                     if(document.forms[msgarr[0]].elements[i].id='LocationImage4')
                    {
                          
                        var s1=document.forms[msgarr[0]].element[i].value;
                        alert(s1)
                        return false;
                        if(s1!="")
                        {
                            
                              if(echeck(s1)==false)
                              {
                                     alert('Please enter thumbnail image');
                                     return false;
                              }   
                         }
                    }
 
                  
			if(document.forms[msgarr[0]].elements[i].id=='txtFileName')
			{
				count=0;
				var s1=document.forms[msgarr[0]].elements[i].value;
				for(strvar=0;strvar<s1.length;strvar++)
				{
					if(s1[strvar]==".")
					{
						count++;
					}
				}
				if(count>1 || count<=0)
				{
					alert("Please enter valid file name");
					return false;
				}
				
				else if(s1.indexOf(".")==s1.length-1)
					{
					alert("Please enter valid file name");
					return false;
					}
			 		result=s1.split(".");
					if(result[1]!="")
					{
						rs=result[1].toLowerCase();
						if(rs=="asp" || rs=="php" || rs=="aspx" || rs=="css" || rs=="cs" || rs=="js" || rs=="htm" || rs=="html" )
						{
						
						}
						else{
							alert("Please enter valid file name");
							return false;
							}
					
					}
					
				
				
			}
			
			if(document.forms[msgarr[0]].elements[i].id=='txtAcoEmail')
			{
				var s1=document.forms[msgarr[0]].elements[i].value;
				if(s1!="")
				{
					if(echeck(s1)==false)
					{
						alert('Please enter valid email address');
						return false;
					}
				}
			}					
			if(document.forms[msgarr[0]].elements[i].id=='Password')
			{
				if(document.forms[msgarr[0]].elements[i+1].id=='ConfPass')
				{
					if(document.forms[msgarr[0]].elements['Password'].value != document.forms[msgarr[0]].elements['ConfPass'].value)
					{
						alert("Password and  confirm password should same");
						return false;
					}
				}
			}
			
		}
		
		if(document.forms[msgarr[0]].id=='category_add')
		{		
			
				if(document.forms[msgarr[0]].elements['txtRange1'].value > document.forms[msgarr[0]].elements['txtRange2'].value)
					{
						alert("First value of range should be smaller then the second value");
						return false;
					}
				
		}
		//alert(document.forms[msgarr[0]].elements['txtInActiveDate'].value);
		//alert(document.forms[msgarr[0]].elements['txtActiveDate'].value);
		//return false;
		//alert(document.forms[msgarr[0]].id);
		if(document.forms[msgarr[0]].id=='adminadd')
		{
				var inactive= document.forms[msgarr[0]].elements['InActiveDate'].value;
				var active= document.forms[msgarr[0]].elements['ActiveDate'].value;
				
				if(inactive<active)
				{
					alert('Active date should be Less then to Inactive date');
					return false;
				}

				
		}
		
		if(document.forms[msgarr[0]].id=='pro_add')
			{
				if(imgno!=0)
				{
					for(i=0;i<imgno;i++)
					{
						var imgid='fileImage'+(i+1);
						if(document.forms['pro_add'].elements[imgid].value != "")
						 {
							var ext = document.forms['pro_add'].elements[imgid].value;
							ext = ext.substring(ext.length-3,ext.length);
							ext = ext.toLowerCase();
							if(ext == "jpg" || ext=="gif" || ext=="bmp" || ext=="png")
							{
							}
							else
							{
								alert('Property Image-'+(i+1)+' not valid, Please select valid image');
								return false;
							}
						}
					}
				}
			}
	  return true;
	}
	else
	alert('Please enter following\n\n'+alt);
	return false;
}

//############################################//
//######  Function for Numaric Value  ########//
//############################################//
function numbersonly(evnt)
{
var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	
	if (unicode<46||unicode>57 || unicode==47){
		if(unicode == 43 || unicode == 32 || unicode == 8 ||  unicode == 9)
			return true;
		else
			return false;
	}
}

function isProper(evnt,id) 
{
    
   var iChars = "!~^-+=?/.*|,\"\:<>[]{}`\';()@&$#%";
   var unicode=evnt.charCode? evnt.charCode : evnt.keyCode;
   var val=iChars.length;
 	 for(checkval=0;checkval<val;checkval++)
	 {
	 	 var specialcode=iChars.charCodeAt(checkval);
		 //alert(specialcode);	
		if(specialcode == unicode || unicode == 92)
		{
          return false;
	  	}
		
	 }
} 
function isPropername(evnt,id) 
{
    
   var iChars = "!~^-+=?/*|,\"\:<>[]{}`\';()@&$#%";
   var unicode=evnt.charCode? evnt.charCode : evnt.keyCode;
   var val=iChars.length;
  
   for(checkval=0;checkval<val;checkval++)
	 {
	 	 var specialcode=iChars.charCodeAt(checkval);
		 //alert(specialcode);	
		
		if(specialcode == unicode || unicode == 92)
		{
          return false;
	  	}
		
	 }
} 


function add_more_upload1() 
{
	var new_total = Math.round(document.frmevent.TOTAL_FILE.value) + 1;
	document.getElementById('attach_'  + document.frmevent.TOTAL_FILE.value).innerHTML = "<input type='file' size='30' class='cstextbox' name='EventImage[" +  new_total  + "]' /></p><p id='attach_" + new_total  + "'>";
	document.frmevent.TOTAL_FILE.value++;
}

function deleteconf1()
{
	var conf=confirm("Are you sure you want to delete Image?");
	if(conf==true)
	{
		return true;
	}
	return false;
}

function getTheTime()
{
	var timehrs = document.getElementById("txthrs").value;
	var timemin = document.getElementById("txtmin").value;
	var timeampm = document.getElementById("txtampm").value;
	
	var timehrs1 = document.getElementById("txthrs1").value;
	var timemin1 = document.getElementById("txtmin1").value;
	var timeampm1 = document.getElementById("txtam_pm1").value;
	
//	alert(timehrs);
//	alert(timehrs1);

	
	if(timehrs==timehrs1 && timemin==timemin1)
	{
		if(timeampm==timeampm1)
		{
			var err = "End time should be greater than start time";
			alert(err);
			return false;
		}
	}
	
	if((timehrs > timehrs1 && timemin > timemin1) || (timehrs > timehrs1 && timemin <= timemin1))
	{
		if(timeampm==timeampm1)
		{
			var err = "End time should be greater than start time";
			alert(err);
			return false;
		}
	}
	
	if((timehrs<=timehrs1 && timemin>=timemin1)||(timehrs<timehrs1 && timemin<timemin1))
	{
		if(timeampm!=timeampm1)
		{
			var err1 = "End time should be greater than start time";
			alert(err1);
			return false;
		}
	}
	return true;
}





function mobval(evnt)
{
var unicode=evnt.charCode? evnt.charCode : evnt.keyCode
	if (unicode<47||unicode>57)
	return false

}

/*## Add by ketan ####*/
function checkValidNumber()
{
	val = event.keyCode;
   	if(val<48)
	{
	  event.keyCode=0;
	
	  }
	if(val>57)
	{
	  event.keyCode=0;
	
	  }
	return true;
}
/*## End ####*/
