function getelm(x)
{
return document.getElementById(x);
}

function tabs() {
    for (var i=1; i<=arguments[2]; i++) {
        if  (getelm(arguments[1]+"_tc"+i)) {
            if (arguments[0] == i) {
			switch (i)
			{
			case 1:
                getelm(arguments[1]+"_tc"+i).className = "tb_block";
                getelm(arguments[1]+"_t"+i).className= "active firsta";
				break;
			
			case 5:
                getelm(arguments[1]+"_tc"+i).className = "tb_block";
                getelm(arguments[1]+"_t"+i).className= "lasta";
				getelm("t_t4").className = "prenor";
				break;
			
			case 2:
                getelm(arguments[1]+"_tc"+i).className = "tb_block";
                getelm(arguments[1]+"_t"+i).className= "active";
				getelm("t_t1").className = "prenor firstd";
				break;
				
			default:
                getelm(arguments[1]+"_tc"+i).className = "tb_block";
                getelm(arguments[1]+"_t"+i).className= "active";
				getelm(arguments[1]+"_t"+(i-1)).className = "prenor";
				break;
			}
            } else {
			switch (i)
			{
			case 1:
			
                getelm(arguments[1]+"_tc"+i).className = "deactblock";
				getelm(arguments[1]+"_t"+i).className = "firstd";
				break;
			
			case 5:
			
			    getelm(arguments[1]+"_tc"+i).className = "deactblock";
				getelm(arguments[1]+"_t"+i).className = "lastd";
				break;
				
			default:
                getelm(arguments[1]+"_tc"+i).className = "deactblock";
				getelm(arguments[1]+"_t"+i).className = " ";
				break;
			}
            }
        }
    }
}
























/* Javascript Functions to Validate String, Number, Email and String with specified Characters */

var whitespace = " \t\n\r";

function isEmpty(s)  //Checks whether string is Empty
	{  
		return ((s == null) || (s.length == 0))
	}

function isWhitespace (s) //Checks for White spaces in the string 
	{  
		var i;
	 	if (isEmpty(s)) return true;
	 	   for (i = 0; i < s.length; i++)
	 	   {   
	 	       var c = s.charAt(i);
	 	       if (whitespace.indexOf(c) == -1) return false;
	 	   }
		   return true;
	}

function noWhitespace (s) //no white space in between the string
	{  
		var i;
	 	if (isEmpty(s)) return true;
	 	   for (i = 0; i < s.length; i++)
	 	   {   
	 	       var c = s.charAt(i);
				if (whitespace.indexOf(c) == 0){
			   	   return true;
				}
	 	   }
		   return false;
	}

function isNumber (s) //Checks whether the number is numeric
	{  
	    var i;
		var bag="1234567890"
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}

function isAmount (s) //Checks whether the number is value in Rs
	{  
	    var i;
		var bag="1234567890."
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}

function hasComma (s) //Checks whether the number is numeric
	{  
	    var i;
		var bag=","
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}
function isCharsInBag (s, bag) /* Checks whether the string only contains the characters 
								specified in the parameter bag */
	{  
	    var i;
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}

function isHours (s) //Checks whether the string contains only numbers and .
	{  
	    var i;
		var bag="1234567890."
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}
	
function isString (s) //Checks whether the string contains only alphabets, . and _
	{  
	    var i;
		var bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz _."
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}

function isStringLength(s,l)
{
	
		if (parseInt(s.length) > parseInt(l) )
		{
		return true;
		}
		else
		{
		return false;
		}
	
	
}
	
function isValidFileName (s) //Checks whether the string contains only alphabets and _
	{  
	    var i;
		var bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}	
function isAlpha (s) //Checks whether the string contains only alphabets
	{  
	    var i;
		var bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
	    for (i = 0; i < s.length; i++)
	    {   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) return false;
	    }
	    return true;
	}
function isAlphaNumeric (s) //Checks whether the string contains only alphabets and Numbers
	{  
	    var i;
		var bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-/ ";
	    for (i = 0; i < s.length; i++)
	    {   var c = s.charAt(i);
			if (bag.indexOf(c) == -1) return false;
		}
		return true;
	}
	
	function isFileName (s) //Checks whether the string contains only alphabets and Numbers
	{  
	    var i;
		var bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
	    for (i = 0; i < s.length; i++)
	    {   var c = s.charAt(i);
			if (bag.indexOf(c) == -1) return false;
		}
		return true;
	}
function isTextNumeric (s) //Checks whether the string contains only alphabets and Numbers
	{  
	    var i;
		var bag="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	    for (i = 0; i < s.length; i++)
	    {   var c = s.charAt(i);
			if (bag.indexOf(c) == -1) return false;
		}
		return true;
	}
		
function isEmail (emailStr) //Checks whether the given string is a valid EMail address
 	{
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

		var matchArray=emailStr.match(emailPat)

		if (matchArray==null) 
		{
			return false
		}
		
		var user=matchArray[1]
		var domain=matchArray[2]
		
		
		if (user.match(userPat)==null) 
		{
		    return false
		}
		
		var IPArray=domain.match(ipDomainPat)
		
		if (IPArray!=null) 
		{
		  	for (var i=1;i<=4;i++) 
		  		{
			    if (IPArray[i]>255) 
					{
			    		return false
			    	}
		    	}
		    return true
		}
	
		var domainArray=domain.match(domainPat)
		
		if (domainArray==null) 
			{
		    	return false
			}
		
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length

		if (domArr[domArr.length-1].length<2 || 
		    domArr[domArr.length-1].length>3) 
			{
			   return false
			}
		
		if (len<2) 
			{
			   var errStr="This address is missing a hostname!"
	   		   return false
			}

		return true;
	}

function isValidDate(dateStr) 	// Checks for the following valid date formats:
	{							// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
									
	
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
		
		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null) 
		{
			alert(dateStr + " Date is not in a valid format.")
			return false;
		}
		
		// parse date into variables
		
		month = matchArray[3];  // 1 and 3 are interchanged for dd/mm/yyyy format
		day = matchArray[1];
		year = matchArray[4];
		
		if (month < 1 || month > 12) 
		{ // check month range
			alert("Month must be between 1 and 12.");
			return false;
		}
		
		if (day < 1 || day > 31) 
		{	//check day range
			alert("Day must be between 1 and 31.");
			return false;
		}
		
		if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31) 
		{ //check whether the month has 31 days
			alert("Month "+month+" doesn't have 31 days!")
			return false;
		}
		if (month == 2) 
		{ // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); //leap year check
			if (day > 29 || (day == 29 && !isleap)) 
			{
				alert("February " + year + " doesn't have " + day + " days!");
				return false;
		    }
		}
//included by saravanan for checking year
		if(year < 1900 || year > 2100)
		{
			alert('year is  not valid')
			return false;
		}		
		return true; 
	}	
/* End of Validation Java Scripts */
/* Function added on 25/03/2002 By lingaraju */

function isGreaterDate(frmDate,toDate)
{
    //The function checks if toDate is greater than or equal to from date
	//Breaking up the start and End date into month, day, year formats
	var fromDatec =frmDate.split('/');
	var toDatec = toDate.split('/');

	if(eval(toDatec[2] > fromDatec[2]))
	    return true;
	else if(eval(toDatec[2] < fromDatec[2]))
	    return false;	
	else if(eval(toDatec[2] == fromDatec[2]))
	{
	   if (eval(toDatec[0] - fromDatec[0])>=1)
	   {
		     return true;
	   }
	   else if(eval(toDatec[0] - fromDatec[0])== 0)
	   {
		  if(eval(toDatec[1] -fromDatec[1]) >= 0)
		      return true;
	      else if(eval(toDatec[1] - fromDatec[1]) < 1)
		    { 
			   return false;
			}	 
	   }	
	   else if(eval(toDatec[0] - fromDatec[0]) < 1)
	   {
//	 	    alert('in month2 - month1'+eval(fromDatec[0] > toDatec[0]));
			return false;
	   }   	   	   	   
	}	
}
/* End of function to find wheter a give date is greater than equal to a date or not */	


/* fucntion added by saravanan to check whether end time is earlier than start date 
given the start noon and end noon by saravanan on 19/11/2004 */
function chkStartEndTime(startTime,startNoon,endTime,endNoon)
{
/*alert('startTime' + startTime)
alert('startNoon' + startNoon)
alert('endTime' + endTime) 
alert('endNoon' + endNoon)*/

	// start time is the time in integer 
	// startNoon is AM/PM
	
	// end time is the time in integer 
	// end Noon is AM/PM
	
	if(startNoon == 'AM')
	{
		var start = 1;
	}
	else
	{
		var start = 2;
	}
	
	if(endNoon == 'AM')
	{
		var end = 1;
	}
	else
	{
		var end = 2;
	}
	
	if(start==1)
	{
		if(end==2)
			{
				return true;
			}
		else
		{
			if(start==end)
			{
				if(parseInt(endTime)>=parseInt(startTime))
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
	}
	else
	{
		if(end==1)
		{
			return false;
		}
		else
		{
			if(parseInt(endTime)>=parseInt(startTime))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	return true;
			
	
	
	/*if(end == start)
	{
		if(parseInt(endTime) < parseInt(startTime))
		{
			return false;
		}
	}
	else
	{
		if(parseInt(endTime) >= parseInt(startTime))
		{
			return true;
		}	 
		else
		{
			return false;
		}
		
	}*/
}
/* end of function check end time */
/* popup function will open the url
	included by saravanan on 23/11/2004 
function popup(URL) 
{
window.open(URL) 
//window.open(URL, toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300);
}
end of popup function*/

 
function daysbtwdates(startdate,enddate)
{
  var startdate = new Date(startdate);
   var enddate = new Date(enddate);

   var daysDiff = (enddate.valueOf() - startdate.valueOf());
   daysDiff = Math.floor(Math.abs((((daysDiff  / 1000) / 60) / 60) / 24));
  document.strForm.noofdays.value = daysDiff;

   return true;
}

function isOnlyNumbers(s) //Checks whether the string contains only alphabets and Numbers
{  
    var i;
	var bag="0123456789";
    for (i = 0; i < s.length; i++)
    {
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) return false;
	}
	return true;
}



