var reWhitespace = /^\s+$/

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or
// whitespace characters only.

function isWhitespace (s)
{   // Is s empty?
    return (isEmpty(s) || reWhitespace.test(s));
}



/* ======================================================================
FUNCTION: 	This function accepts dates of format YYYY-MM-DD and returns the date in the DD-MM-YYYY

INPUT:		Input String in the format YYYY-MM-DD
				
RETURNS:		String in the form DD-MM-YYYY

DESC:							
====================================================================== */
function ConvertDateYYYYMMDDtoDDMMYYYY(input_date ){

 if (( input_date.length != 10  )||(isWhitespace(input_date))) {
   //alert('Date passed to the date conversion function is not of correct length');
   return "";
}
else {
    return input_date.substring(8,10)+ "-" + input_date.substring(5,7)+"-" + input_date.substr(0,4);
}


}  
/* ======================================================================
FUNCTION: 	This function accepts dates of format DD-MM-YYYY and returns the date in the YYYY-MM-DD

INPUT:		Input String in the format DD-MM-YYYY
				
RETURNS:		String in the form YYYY-MM-DD

DESC:							
====================================================================== */

function ConvertDateDDMMYYYYtoYYYYMMDD(input_date ){

if (( input_date.length != 10  )||(isWhitespace(input_date))) {
   //alert('Date passed to the date conversion function is not of correct length');
   return "";
}
else {
    return  input_date.substr(6,10) + "-" + input_date.substring(3,5) + "-" +input_date.substring(0,2);
}

}  

/* ======================================================================
FUNCTION: 	This function accepts two dates of format DD-MM-YYYY and returns the diffrence in years

INPUT:		Two Input String in the format DD-MM-YYYY
				
RETURNS:		No Years between the two specified dates

DESC:			to be used in conjunction with datediff_months. The diff will be calculated based on date_input1 - date_input2
====================================================================== */


function datediff_years(input_date1,input_date2) {

	var x =(Date.UTC(input_date1.substr(6,10),  input_date1.substring(3,5) ,input_date1.substring(0,2), 0, 0, 0) - Date.UTC(input_date2.substr(6,10),  input_date2.substring(3,5) ,input_date2.substring(0,2), 0, 0, 0));
	var no_years = x/(60*60*24*365*1000);

	var no_years_rounded  = Math.floor(no_years);
	
	if ( no_years_rounded < 0 ) {
   	 return "Error";
	}
	else {
   	 return no_years_rounded;   
	}

}

function datediff_months(input_date1,input_date2) {

	var x =(Date.UTC(input_date1.substr(6,10),  input_date1.substring(3,5) ,input_date1.substring(0,2), 0, 0, 0) - Date.UTC(input_date2.substr(6,10),  input_date2.substring(3,5) ,input_date2.substring(0,2), 0, 0, 0));
	var no_years = x/(60*60*24*365*1000);
	var no_years_rounded  = Math.floor(no_years);
   var no_months = Math.floor((no_years - no_years_rounded ) * 365/30);	
   
	if ( no_months < 0 ) {
   	 return "Error";
	}
	else {
   	 return no_months;   
	}

}

function pageaddr() {
  return location.protocol+'//'+location.host+location.pathname;
}


//open new window,use for open alert or precaution new window
function openNewWindow(pageName, tHeight, tWeight)
{
  abURL = pageName;
  wheight = tHeight;
  wwidth = tWeight;
  opts = 'width='+wwidth+',height='+wheight+',resize=yes,scrollbars=yes,statusbar=yes,menubar=yes,toolbar=yes,titlebar=yes,dependent=yes';
        
  popupWin = window.open(abURL,'abHistory', opts);
  
}

//Basic Validation functions

function isAlpha(value) {
//-----------
// Description:check whether the field is a aplpha(a-z,0-9)
// Input:field value
// Ouput:true or false
//----------

 //var field = document.forms[0].elements[FieldName]
 field = value
 var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY"
 var ok = "yes";
 var temp;
 for (var i=0; i<field.length; i++) {
 temp = "" + field.substring(i, i+1);
 if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no") {

   return false
 }
 else{
   return true
     }   
}

  function isValidUserid(value){
     var str=new String(value);
       if(!(str.length<5)&&(!(str.length>21))){
        return false;
       } 
       else
       {
         return true;
       }
     }  

  function isValidPassword(value){
     var str= new String(value);
       if(!(str.length<5)&&(!(str.length>21))){
        return false;
       } 
       else
       {
         return true;
       }
     }  

  function isValidPassword(value){
     var str=value
       if(!(str.length<5)&&(!(str.length>21))){
        return false;
       } 
       else
       {
         return true;
       }
     }  
   
   function alpha_num(value)
{
//-----------
// Description:check whether the field is a aplpha(a-z,A-Z,0-9)
// Input:field value
// Ouput:true or false
//----------
 
 var field = value
 var valid =new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_");
 var ok = "yes";
 var temp;
 for (var i=0; i<field.length; i++) {

 temp = "" + field.substring(i, i+1);
 if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no") {

   return false
 }
 else{
   return true
	 }   
 }
	

//======
	
function IsDate(a) {
//-----------
// Description:check whether the date value is a correct format,the valid format is dd/mm/yyyy
// Input:date field value
// Ouput:true or false
//----------

var err=0

if (a=="") return false;
if (a.length != 10) err=1
d = a.substring(0, 2)// day
c = a.substring(2, 3)// '/' or '-'
b = a.substring(3, 5)// month
e = a.substring(5, 6)// '/' or '-'
f = a.substring(6, 10)// year
if (b<1 || b>12||!IsNumeric(b)) err = 1
if (!(((c=='-') && (e=='-')) || ((c=='/') && (e=='/')))) err = 1
//if (c != '-') err = 1
if (d<1 || d>31||!IsNumeric(d)) err = 1
//if (e != '-') err = 1
if (b==4 || b==6 || b==9 || b==11){
if (d==31) err=1
}
if (b==2){
var g=parseInt(f/4)
if (isNaN(g)) {
err=1
}
if (d>29) err=1
if (d==29 && ((f/4)!=parseInt(f/4))) err=1
}
if(!IsNumeric(f)) err=1
if (err==1) {
return false
}
else {
return true
   }
}

function checkvalid(y1,y2,m1,m2,d1,d2) {
//-----------
// Description:check whether value1<=value2 base the piroty of y,m,d
// Input:6 number values
// Ouput:true or flase
//----------
  
  if ( y1<y2 ) {return true}
  if ( y1==y2 ) {
     if ( m1<m2 ) {return true}
     if ( m1==m2 ) {return (d1<=d2)}
     else {return false}
  }
  else {return false}
}

function IsvalidDate(value,startDate,endDate){
//-----------
// Description:check whether the date field is between startdate and enddate,date format should be dd-mm-yyyy
// Input:a date field value,start date value, and end date value. startdate and end date must be date type data and startdate<enddate,one of the startdate and enddate can be "null"
// Ouput:true or flase
//----------
 
 if (value == "") return true;
 
 if ( !IsDate(value) ) {
   return false
 }

 a=value
 b = a.substring(0, 2)// day
 c = a.substring(2, 3)// '-'
 d = a.substring(3, 5)// month
 e = a.substring(5, 6)// '-'
 f = a.substring(6, 10)// year
 
 if ( startDate != "" ) {
   b1 = startDate.substring(0, 2)// day
   c1 = startDate.substring(2, 3)// '-'
   d1 = startDate.substring(3, 5)// month
   e1 = startDate.substring(5, 6)// '-'
   f1 = startDate.substring(6, 10)// year
  }
 if ( endDate != "" ) {
   b2 = endDate.substring(0, 2)// day
   c2 = endDate.substring(2, 3)// '-'
   d2 = endDate.substring(3, 5)// month
   e2 = endDate.substring(5, 6)// '-'
   f2 = endDate.substring(6, 10)// year
  }

  if ((startDate == "") && (endDate == "")) return true;
  if (startDate == ""){
      return checkvalid(f,f2,d,d2,b,b2)
  }
  else if (endDate == "") {
      return checkvalid(f1,f,d1,d,b1,b)
  }
  else{  
     return (checkvalid(f1,f,d1,d,b1,b)&checkvalid(f,f2,d,d2,b,b2))
  } 
 
}
function IsvalidFromDate(startDate,endDate){
var date1;
var date2;
 
 if ( startDate != "" ) {
   b1 = startDate.substring(0, 2)// day
   c1 = startDate.substring(2, 3)// '-'
   d1 = startDate.substring(3, 5)// month
   e1 = startDate.substring(5, 6)// '-'
   f1 = startDate.substring(6, 10)// year
  }
date1=f1+d1+b1;
//alert(date1);
date1=date1.toString();

 if ( endDate != "" ) {
   b2 = endDate.substring(0, 2)// day
   c2 = endDate.substring(2, 3)// '-'
   d2 = endDate.substring(3, 5)// month
   e2 = endDate.substring(5, 6)// '-'
   f2 = endDate.substring(6, 10)// year
  }
date2=f2+d2+b2;
//alert(date2);
date2=date2.toString();
if (parseInt(date1)<parseInt(date2)){
//alert("From date less than To date");
return true;
}
}

function IsNumeric(value) {
//-----------
// Description:check whether the field is a number
// Input:a field value
// Ouput:true or flase
//----------
 var field = value
 var valid = "0123456789"
 var ok = "yes";
 var temp;


 for (var i=0; i<field.length; i++) {

 temp = "" + field.substring(i, i+1);

 if (valid.indexOf(temp) == "-1") ok = "no";
   	
 }

 if (ok == "no") {
   return false
 }
 else{
   return true
 }   
}
function IsNumericZero(value) {
//-----------
// Description:check whether the field is a number
// Input:a field value
// Ouput:true or flase
//----------
 var field = value
 var valid = "123456789"
 var ok = "yes";
 var temp;
 for (var i=0; i<field.length; i++) {
 temp = "" + field.substring(i, i+1);
 if (valid.indexOf(temp) == "-1") ok = "no";
 }
 if (ok == "no") {
   return false
 }
 else{
   return true
 }   
}



function IsDecimal(value,num) {
//-----------
// Description:check whether the field is a decimal with num decimal point,if it is a decimal and its decimal point is num,then return true or return false.
// Input:a field value, number os decimal
// Ouput:true or flase
// if num is 100, then when the decimal point is more than 2, it will return true
//----------
  
  var a = value.indexOf(".")
 	
  if ( a!=-1) {
    var len = value.length
    num1 = value.substring(0,a-1)
    num2 = value.substring(a+1,len)
    if ( (num == len-a-1)&IsNumeric(num1)&IsNumeric(num2) ) {
       return true
    }else if ((num == 100)&IsNumeric(num1)&IsNumeric(num2)&(num2>2)) {
    		return true
    }
    else {
       return false    
    }
}
else {
     return false  
}

}



function pade2decimals(value){
  
  

  if (value == "") return "";
 
  if (IsNumeric(value.toString())) return value+".00";
  if (IsDecimal(value.toString(),1)) return value+"0";
  if (IsDecimal(value.toString(),2)) return value;
  if (IsDecimal(value.toString(),100)) return pade2decimals(Math.round(value*100)/100);
  return "-1";
}

function minMaxLengths(value,minlen,maxlen){
//-----------
// Description:check whether the field lengh is between minlen and maxlen
// Input:a field value,min length value, and max length value. minlen and maxlen must be integer and minlen<maxlen,one of the minlen and maxlen can be "null"
// Ouput:true or flase
//----------
  
  len = value.length
  if (minlen == ""){
     if (len <=maxlen) {return true}
     else {return false}
  }
  else if (maxlen == "") {
     if (minlen<=len) {return true}
     else {return false}
  }
  else{  
     if (minlen<=len & len<=maxlen){return true}
     else {return false}
  }
}

function SetItemValue(ItemName,value) {
 //-----------
// Description:Set an item as a selected options in a drop down list
// Input:a select field name and a value to be set, the value must be one of the option for the select field
// Ouput:set the value to be selected or return the error message
//----------

 var obj = document.forms[0].elements[ItemName];
 i = 0;
 err = 1;
 //alert(ItemName);
 while ( (i<obj.length) & (err == 1) ) {
   
   if ( obj[i].value == value ) {
     obj[i].selected = true
     err = 0
   }
   i = i+1
 }
 
 if ( err == 1 ) {
   //alert("Sorry! You Set a wrong value in field:"+ItemName)  
 } 
}

function SetItemValueNew(obj,value) {
 //-----------
// Description:Set an item as a selected options in a drop down list
// Input:a select field name and a value to be set, the value must be one of the option for the select field
// Ouput:set the value to be selected or return the error message
//----------

 //var obj = document.forms[0].elements[ItemName];
 i = 0;
 err = 1;
 //alert(ItemName);
 while ( (i<obj.length) & (err == 1) ) {
   
   if ( obj[i].value == value ) {
     obj[i].selected = true
     err = 0
   }
   i = i+1
 }
 
 if ( err == 1 ) {
   //alert("Sorry! You Set a wrong value in field:"+ItemName)  
 } 
}

function SetRadioButtonValue(RadionName,value) {

 var obj = document.forms[0].elements[RadionName];
 i = 0;
 err = 1;
 //alert(ItemName);
 while ( (i<obj.length) & (err == 1) ) {
   
   if ( obj[i].value == value ) {
     obj[i].checked = true
     err = 0
   }
   i = i+1
 }
 
 if ( err == 1 ) {
   //alert("Sorry! You Set a wrong value in field:"+ItemName)  
 } 

}

function SetRadioButtonValueNew(obj,value) {

// var obj = document.forms[0].elements[RadionName];
 i = 0;
 err = 1;
 //alert(ItemName);
 while ( (i<obj.length) & (err == 1) ) {
   
   if ( obj[i].value == value ) {
     obj[i].checked = true
     err = 0
   }
   i = i+1
 }
 
 if ( err == 1 ) {
   //alert("Sorry! You Set a wrong value in field:"+ItemName)  
 } 

}

function SetRadioButtonDefault(RadionName,index) {

 var obj = document.forms[0].elements[RadioName];
 obj[index].checked = true;
}

function GetSelectedItem(ItemName) {
//-----------
// Description:get the selected item in the drop down list
// Input:a selected field name
// Ouput:the selected item value
//----------
   var obj = document.forms[0].elements[ItemName];
   	
	return obj[obj.selectedIndex].value;
}


function isSelectedItem(value) {

   if(value==""){
     return false;
  }else{
   return true;
 }
}

function validRange(value,value1,value2) {
//-----------
// Description:check whether the value is between value1 and value2
// Input:a number field value,two number, and value2>value1
// Ouput:true or false
//----------

  
  return((value >= value1)&(value<=value2)) 
}


function validvalue(v1,v2,op) {
//-----------
// Description:check whether v1 is "op" v2, "op" could be "=",">","<",">=" and "<="
// Input:two number and a operator
// Ouput:true or false
//----------

  if ( op == "=" ) {
     return (v1 == v2)
}else if(op == ">"){
     return (v1>v2)
}else if(op == "<"){
     return (v1<v2)
}else if(op == ">="){
     return (v1>=v2)
}else if(op == "<=") {
     return (v1<=v2)
}  

}
 
function EventValidation(FieldName1,v1,v2,op1,FieldName2,v3,v4,op2) {
//-----------
// Description:when the value of fieldname1 is match the event, check whether the value of fieldname2 is match the case.
//             the possible value for op1 and op2 is:in,=,>,<,>= and <=.If the value1 is between v1 and v2,or value1 "=" 
//             or ">" or "<" or ">=" or <=" v1, then check the same as value2
// Input:two number field names, two operators,4 number value.
// Ouput:true or false
//----------
    
    value1 = document.forms[0].elements[FieldName1].value
    value2 = document.forms[0].elements[FieldName2].value 
    if ( op1 == "in" ) {
       if ( op2 == "in") {
          return(validRange(Fieldname1,v1,v2)&validRange(FieldName2,v3,v4))
        }
      else {
          return(validRange(Fieldname1,v1,v2)&validvalue(value2,v3,op2))
     }
  }
  else {
      if ( op2 == "in") {
          return(validvalue(value1,v1,op1)&validRange(FieldName2,v3,v4))
        }
      else {
          return(validvalue(value1,v1,op1)&validvalue(value2,v3,op2))
     }
  }

}

function SetOffImage(obj) {
//set on image:called by SetOnOffImage(obj)
  var src = obj.src
  if ( src.charAt(src.length-5)=="1" ) {
  src = src.replace("1.gif","0.gif")
  }
  obj.src = src
}

function SetOnImage(obj) {
//set off image:called by SetOnOffImage(obj)
  var src = obj.src
  if ( src.charAt(src.length-5)=="0" ) {
  src = src.replace("0.gif","1.gif")
  }
  obj.src = src
}

function IsImageOn(obj) {
  var src = obj.src
  if ( src.charAt(src.length-5)=="1" ) {
    return true;
  }else{
    return false
  }
}

function SetOnOffImage(obj) {
//-----------
// Description:set the image to on or off,if it is on then set to off, if it is off then set to on
// Input:current object:this. can called like:onclick = "SetOnOffImage(this)",end by 0 means off, end by 1 menas on
// Ouput:image from on to off, from off to on
//----------
  var src = obj.src
  if ( src.charAt(src.length-5)=="1" ) {
    SetOffImage(obj)
    //src = src.replace("1.gif","0.gif")
}
else {
    SetOnImage(obj)
    //src = src.replace("0.gif","1.gif")
}
  //obj.src = src
   
}

function SwitchImage(obj) {
//-----------
// Description:set the image to on and set all image in the page to off
// Input:current object:this. can called like:onclick = "SwitchIamge(this)",the images file name should end by 1 and 0
// Ouput:image from off to on, other images is off
//----------
var src = obj.src
  if ( src.charAt(src.length-5)=="1" ) {
 }
 else {
    
    var iamgeslen = document.images.length
    for ( var i=0; i<iamgeslen; i++ ) {
       if ( document.images[i]!=obj ) {
           SetOffImage(document.images[i])
       }
   }  
   SetOnImage(obj)   
 }

}








function ParseQueryString()
//Purpose : The Query String is parsed and the for each variable passed in the QueryString, this script will declare corresponding javascript variables and assigns them the corresponding values.
{
var thisUrl=document.URL.toString(), start=1+thisUrl.indexOf('?'), qs=thisUrl.substring(start,thisUrl.length); // Capture the QueryString
if (start > 0) // If there is a QS then...
 { var sets=qs.split('&'), nsets=sets.length; // sets is an array of strings in the format var=value
   for(i=0;i<nsets;i++) // for each pair...
    { pair=sets[i].toString().split('=');    // splice it...
      eval("var "+pair[0]+"='"+pair[1]+"';");  // and eval it.
    }
 }

}   



function checkNric(nric) {
		var s = nric;
		var sum, checkDigit, checkDigitStr, checkDigitStrFor;
		
		s = s.toUpperCase();
	 	if ( s.charAt(0) == 'S'  || s.charAt(0) == 'T' || s.charAt(0) == 'F' || s.charAt(0) == 'G' || s.charAt(0) == 'X' )
		{
			//Cater for 6 digits nric with prefix F
			//if ( s.charAt(0) == 'F' && s.length == 8 )  
			//	return true;
				
			if (s.length != 9 )		
				return false;

			sum = 2 * s.charAt(1) +
				7 * s.charAt(2) +
				6 * s.charAt(3) +
				5 * s.charAt(4) +
				4 * s.charAt(5) +
				3 * s.charAt(6) +
				2 * s.charAt(7) ;

			if (s.charAt(0) == 'T' || s.charAt(0) == 'G' ) sum = sum + 4;
			checkDigit = 11 - (sum % 11);

			if ( checkDigit == 1 )
			{
				checkDigitStr = "A";
				checkDigitStrFor = "K";
			}
			else if (checkDigit == 2)
			{
				checkDigitStr = "B";
				checkDigitStrFor = "L";
			}
			else if (checkDigit == 3)
			{
				checkDigitStr = "C";
				checkDigitStrFor = "M";
			}
			else if (checkDigit == 4)
			{
				checkDigitStr = "D";
				checkDigitStrFor = "N";
			}
			else if (checkDigit == 5)
			{
				checkDigitStr = "E";
				checkDigitStrFor = "P";
			}
			else if (checkDigit == 6)
			{
				checkDigitStr = "F";
				checkDigitStrFor = "Q";
			}
			else if (checkDigit == 7)
			{
				checkDigitStr = "G";
				checkDigitStrFor = "R";
			}
			else if (checkDigit == 8)
			{
				checkDigitStr = "H";
				checkDigitStrFor = "T";
			}
			else if (checkDigit == 9)
			{
				checkDigitStr = "I";
				checkDigitStrFor = "U";
			}
			else if (checkDigit == 10)
			{
				checkDigitStr = "Z";
				checkDigitStrFor = "W";
			}
			else if (checkDigit == 11)
			{
				checkDigitStr = "J";
				checkDigitStrFor = "X";
			}

			if (checkDigitStr == null) 
				return false;
			
			if (s.charAt(0) == 'S' || s.charAt(0) == 'T')
			{
			  	if ( checkDigitStr != (s.charAt(8))) 
			  		return false;
			  	else return true;
			} else if (s.charAt(0) == 'F' || s.charAt(0) == 'G' ) 
			{
					if ( checkDigitStrFor != (s.charAt(8)))
						return false;
					else return true;
			}
			else
				return false;

		} else if ( s.charAt(0) == 'C' || s.charAt(0) == 'E' )
				return true;
		else
				return false;
		
	}


function trim(value)
{
  flag = true;
  i=0;
  while(flag && (i<value.length))
  {
    if (value.charAt(i) != " ")
    {
      flag = false;
    }
    i=i+1;
  }
 
  value1 = value.substring(i-1,value.length);

  flag = true;
  i=value1.length-1;
  
  while(flag && (i>=0))
  {
    if (value1.charAt(i) != " ")
    {
      flag = false;
    }
    i=i-1;
  }
  
  value2 = value1.substring(0,i+2);
  //alert("k"+value+"k");
  //alert("k"+value1+"k");
  //alert("k"+value2+"k");
  return value2;
}

function currentDate()
{
	today = new Date();
	var screenday = today.getDate();
	if(screenday<10){screenday = "0"+screenday;}
	var screenmonth = today.getMonth()+1;
	if(screenmonth<10){screenmonth = "0"+screenmonth;}
	var screenyear = today.getFullYear();
	var screendate = screenday+"/"+screenmonth+"/"+screenyear;
	return screendate;

}

function lastyear_currentDate()
{
	today = new Date();
	var screenday = today.getDate();
	if(screenday<10){screenday = "0"+screenday;}
	var screenmonth = today.getMonth()+1;
	if(screenmonth<10){screenmonth = "0"+screenmonth;}
	var screenyear = today.getFullYear()-1;
	var screendate = screenday+"-"+screenmonth+"-"+screenyear;
	return screendate;
	//document.forms[0].elements['CURRENTDATE'].value = screendate;
	
}

function calendarbox(fieldName)
{
  if (self.isOpenCalendar == true)
                if (calWin.closed == false) 
                        calWin.close();

        self.dateField = document.forms[0].elements[fieldName];
        self.time = "";
        self.currentDate = new Date();

        var winWidth = 200;
        var winHeight = 150;

        if (navigator.appName == "Netscape")
        {
                winWidth += 5;
                winHeight += 10;
        }

        var winStyle = 'statusbar=no,resizable=no,height=' + winHeight.toString() + ',width=' + winWidth.toString() + ',scrollbars=no,titlebar=no,toolbar=no';
        calWin = self.open('../share/calendar.html', fieldName, winStyle);
        self.isOpenCalendar = true;
 
}



function IsValidEmail(x){

	var c1=0,c2=0,c3=0
	a= x
	str = new String(a)
	//if(str =="")
	//{
		//return false;
	//}
	//else {
		for(i=0;i<str.length;i++)
		{	
			temp = str.charAt(i)
			if(temp =="@")
			{	
				c1 = i;
			}
			//else if(temp ==" ")
			//{c3++;}
			//else {}
		}
		if((c1==0) || (c1 == (str.length-1)))
        		{
			//alert("Invalid Email ID" + x);
			//document.forms[0].Email.focus();
		 	return false;
		}
		//return false;
		//else {alert("valid Email ID")}
	//}
  //alert("valid email" + x);
	return true;
}

function isCheckBoxCheck(checkboxobj){

var selectedCount = 0;
for ( var i=0; i<checkboxobj.length; i++ ) {
    if ( checkboxobj[i].checked ) selectedCount++;
}
if ( selectedCount > 0) 
{
    return true;
    
}
else 
{
    return false;
}

}

function isValidFax(value){
     var str=value
       if(!(str.length==7)||(!IsNumeric(value))){
        return false;
       } 
       else
       {
         return true;
       }
     } 
          
function isTime(a){
var err=0;
if(a=="") return false;
if(a<5 || a>5) err=1;
h=a.substring(0,2)//hh
c=a.substring(2,3)// :
m=a.substring(3,5)//mm
if(h<0 || h>24 ||!IsNumeric(h)) err=1;
if (c != ':') err=1;
if(m<0 || m>60 || !IsNumeric(m))err=1;
if (err==1) {
return false;
}
else {
return true;
   }
}

function getRadioSelectValue(fieldname){
		var obj = document.forms[0].elements[fieldname];
		
		for(var i=0;i<obj.length;i++){
			if(obj[i].checked) {
				return obj[i].value
			}
		
		}
		
		return "";

}

function setRadioUnchecked(fieldname){
		var obj = document.forms[0].elements[fieldname];
		
		for(var i=0;i<obj.length;i++){
			obj[i].checked = false;
				
		}
		
	
}
    
function WithoutContent(ss) {
if(ss.length > 0) { return false; }
return true;
}

function NoneWithContent(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].value.length > 0) { return false; }
	}
return true;
}

function NoneWithCheck(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].checked) { return false; }
	}
return true;
}

function WithoutCheck(ss) {
if(ss.checked) { return false; }
return true;
}

function WithoutSelectionValue(ss) {
for(var i = 0; i < ss.length; i++) {
	if(ss[i].selected) {
		if(ss[i].value.length) { return false; }
		}
	}
return true;
} 

function isValidFiles(value) {
	
	valid_file = new Array(".gif",".jpg",".swf");
	
	if (value == "") {
	   return true;
	}else{
		for (var i=0;i<valid_file.length;i++) {			
		  if (value.lastIndexOf(valid_file[i]) == valid_file.length - 4){
		  	return true;
		  }		  	
		}
		return false;
	}	
	
}