function EW_checkMyForm(EW_this) {
//alert(EW_hasValue(EW_this.x_date_of_post, "TEXT" ));
if(EW_hasValue(EW_this.x_date_of_post, "TEXT" ) || EW_hasValue(EW_this.x_exp_date, "TEXT" )){
//alert("2");
	if (EW_this.x_date_of_post && !EW_hasValue(EW_this.x_date_of_post, "TEXT" )) {
		if (!EW_onError(EW_this, EW_this.x_date_of_post, "TEXT", "Please enter required field - From Date"))
			return false;
	}

	if (EW_this.x_date_of_post && !EW_checkeurodate(EW_this.x_date_of_post.value)) {
		if (!EW_onError(EW_this, EW_this.x_date_of_post, "TEXT", "Incorrect date, format = dd/mm/yyyy - From Date"))
			return false; 
	}
	if (EW_this.x_exp_date && !EW_hasValue(EW_this.x_exp_date, "TEXT" )) {
		if (!EW_onError(EW_this, EW_this.x_exp_date, "TEXT", "Please enter required field - To Date"))
			return false;
	}

	if (EW_this.x_exp_date && !EW_checkeurodate(EW_this.x_exp_date.value)) {
		if (!EW_onError(EW_this, EW_this.x_exp_date, "TEXT", "Incorrect date, format = dd/mm/yyyy - Date of Expire"))
			return false; 
	}
}

return true;
}


function setvisibility(id)
	{
		alert("Here i am")
	
	var id1="";
	id1=document.sform.closing.value+"1";
	nid=id+"1";
	
	
	id2=document.sform.closing.value+"2";
	txt=id+"2";
	
	if(nid!=id1){
	
	document.getElementById(id2).style.color="#000000";
	document.getElementById(txt).style.color="#761C7F";
	
	document.getElementById(id1).style.display="none";
	document.getElementById(nid).style.display="inline";
	
	}
	document.sform.closing.value=id;
		
	}



<!--
EW_dateSep = "/"; // set date separator	
//-->

<!--
var EW_HTMLArea;
//-->

var EW_HTMLArea = []; 
//-->


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The end date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The Start date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidateForm(){
/*
1. Date should be in proper format
2. If date from is specified then date to should be specified
3. Archivee result check box should check all items in the archieve
4. Search all text should search all the texts 

*/

/*
	var dt=document.form.x_date_of_post
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}

	ValidateForm1()
*/
//alert("--");
//	if(EW_checkMyForm(document.form)) {
//		loaddiv("document.form");
//		return true
//	}
//	return false;
	document.form.hdnAction.value = 'Search';
	country=document.form.hdncountry.value;
	//alert(country);
	document.form.action = 'http://'+location.host+'/'+country+'/information_centre';
	document.form.submit();
    
 }
function ValidateForm1(){
	//alert ("dsdsadsad")
	var dt1=document.form.x_exp_date
	if (!isDate(dt1.value)){
		dt1.focus()
		return false
	}
    return true
 }

// Replace TextArea by HTMLArea
function loaddiv(obj)
{
//  x_date_of_post,x_exp_date,category,textfield22
//alert("sdfsd");
	
	//ValidateForm()
	kwd=document.form.textfield22.value;
	ed=document.form.x_exp_date.value;
	dp= document.form.x_date_of_post.value;
		
	if (document.form.x_date_of_post.value == "" && document.form.x_exp_date.value != "" ) 
		{
			alert("Start date should come");
		}
	else if (document.form.x_date_of_post.value != "" && document.form.x_exp_date.value == "" ) 
		{
			alert(" End date should come");
		}
		
	else if(document.form.x_exp_date.value<document.form.x_date_of_post.value)
		{
   		 document.form.x_exp_date.value="";
		 alert("End date should come after Start Date");
		}
	else 
		{
 		 ca= document.form.category.value;
		
		 if(document.form.psearchtype2.checked)
		 {
		 	se="ON";
		 }
		 else
		 {
		 	se="";
		 }
		 str = "kwd=" + kwd + "&ed="+ed+"&dp=" + dp+ "&ca="+ca+ "&se="+se;
		 //alert(str);
		 showValues(str);
	    }
}
					
function joins()
	{
		if(document.form.x_exp_date.value!="")
			{
					if(document.form.x_exp_date.value<document.form.x_date_of_post.value)
						{
							document.form.x_exp_date.value="";
							alert("End date should come after Start Date");
						}
			}
	
	}

//***************************************************************************
//NAME: SubmitToPage						                                *
//                                                                          *
//INPUT:         1. The page to go to										*
//PROCESSING:    1. Set the form action as the page to go to and submit		*
//OUTPUT:        1. None													*
//***************************************************************************		
function SubmitToPage(strPageToGoTo)
{
	document.form.action = strPageToGoTo;
	document.form.submit();
}