/*-------------------------------------------------------------------------------------------------------------
EVENT SEARCH PARAMETRES CLASS 
-------------------------------------------------------------------------------------------------------------*/


function generateEventSearchValueClass( sOutputFieldId,sOptionsContainerId,sOptionsId, sExtraData )
{   
	
	var oESV = new Object();
	
		oESV.body_content      = false;
		oESV.options_container = false;
		oESV.options_id        = sOptionsId;
		oESV.options           = new Array();
		oESV.out               = false;
		oESV.out_value         = '';
		oESV.value             = false;
		oESV.controller        = false;

		if ( sExtraData||false )
		{
			oESV[sExtraData] = false;
		}
		
		
		
		oESV.construct = function (iLength,eBC)
		{
			this.body_content = gid('ESBlock');
			this.out = gid(sOutputFieldId);
			this.options_container = gid(sOptionsContainerId);
			
			
			var iSelected = -1;
			this.options = new Array();
			
			for ( var i=0; i<iLength; i++ )
			{
				var eOption = gid(this.options_id+i);
					eOption.onclick = function () { oESV.select(this); };
				iSelected = eOption.getAttribute('is_selected')=='1' ? i : iSelected;
				this.options.push(eOption);
			}
			this.options['selected'] = iSelected;
			this.options['length'] = iLength;
			
			if ( iSelected>=0 ) {this.select(this.options[iSelected]);}
		};

		
		oESV.select = function (obj)
		{
			this.getOptionValue( obj );
			
			for ( var i=0; i<this.options['length']; i++ )
			{
				if ( obj.id!=this.options[i].id )
				{
					this.unselect_option(this.options[i]);
				}
				else
				{
					this.select_option(this.options[i]);
					this.options['selected'] = i;
				}
			}
			this.hide();			
			//this.out.focus();
		};
		
		
		oESV.getOptionValue = function(obj)
		{
			/*var obj = eParent.getElementsByTagName('span')[0];
			
			var sName   = obj.innerHTML;
			var sState  = obj.getAttribute('state');
			var iCityId = obj.getAttribute('city_id');
			*/

			this.value = obj.getAttribute('value');
			this.out_value = obj.getAttribute('out');
			this.out.value = this.out_value;
			
			if ( sExtraData ) {this[sExtraData] = obj.getAttribute(sExtraData);}
		};
		
		
		oESV.set = function ( sValue,sOutput )
		{
			var bOut = (sOutput||false) ? true : false; 
			this.value = sValue;

			for ( var i=0;i<this.options['length'];i++ )
			{
				eOption = this.options[i];
				if ( eOption.getAttribute('value')==this.value )
				{
					this.select_option(eOption);
					sOutput = bOut ? eOption.getAttribute('out') : eOption.getAttribute('out');
					bOut = true;
				}
				else
				{
					this.unselect_option(eOption);
				}
			}

			if ( bOut )
			{
				this.out_value = sOutput;
				this.out.value = this.out_value;
				//alert("hjk");				
				//this.out.focus();
			}
			
		};
		
		
		oESV.select_option = function (obj)
		{
			obj.setAttribute('is_selected',1);
			
			var eName = obj.getElementsByTagName('span')[0];
				eName.style.fontWeight = 'bold';
				eName.style.color = '#000000';
				
			var aImgs = obj.getElementsByTagName('img');
			for (var i=0, l=aImgs.length; i<l; i++) {if (aImgs[i].name=='tick') {aImgs[i].style.display = '';}}
		};


		oESV.unselect_option = function (obj)
		{
			obj.setAttribute('is_selected',0);
			
			var eName = obj.getElementsByTagName('span')[0];
				eName.style.fontWeight = '';
				eName.style.color = '#555555';
		
			var aImgs = obj.getElementsByTagName('img');
			for (var i=0, l=aImgs.length; i<l; i++) {if (aImgs[i].name=='tick') {aImgs[i].style.display = 'none';}}
		};
	

		oESV.display = function ( aPos, oController )
		{
			this.controller = oController;

			var obj = this.options_container;
			//alert(obj.style.display);

			obj.style.display = obj.style.display == 'none' ? '': 'none';
			
			//var aPos = getLeftTop(obj);
			//obj.style.left = aPos[0]+aDelta[0] + 'px';
			//obj.style.top  = aPos[1]+aDelta[1] + 'px';
			obj.style.left = aPos[0]+'px';
			obj.style.top  = aPos[1]+'px';
			
			
			this.body_content.onmouseup = function () {
			 oESV.hide(); 
			};

			this.controller.onmouseup = function(e)
			{
				//alert(this.alt);
				//this.style.border = "1px solid #000000";

				if( this.alt.indexOf('when')!=-1)
				{
					hideOthers(0);
				}
				else
				{
				    hideOthers(2);
				}

				if( !e )
				{
					e = window.event;
					e.cancelBubble = true;
					return false;
				}

				e.stopPropagation();
				return false;
			};
		};


		oESV.hide = function () 
		{
			var obj = this.options_container;
			if( this.controller ) {
		        this.controller.onmouseup = null;
			}	
			if ( obj.style.display!='none' )
			{
				obj.style.display = 'none';
				this.body_content.onmouseup = null;
			}
		};
	
        
	return oESV;
}




/*-------------------------------------------------------------------------------------------------------------
EVENT SEARCH  -->  WHERE 
-------------------------------------------------------------------------------------------------------------*/


var oESWhere = generateEventSearchValueClass('es_where','es_where_options','es_where_option_');
var sESWhere_body_content_id = false;
var curSel =0;
function displayESWhereOptions (obj)
{
	// x, y
	
	var aPosition = getLeftTop(obj);
	if(obj.id == 'es_where_search_button') {
		aPosition[0] -= 222;
		aPosition[1] += 25;
	} else {
		aPosition[0] -= 163;
		aPosition[1] += 20;
	}
		
	gid('es_where_search').style.display='none';
	oESWhere.display(aPosition, obj);
	hoverFunctionpop();
	
	
}


var displayESWhereSearch_jquery = function(){
	//oESWhere.hide();
		hidePopUp(2);
		if(gid('es_where_search')) {
			var obj = gid('es_where_search');
		} else {
			var obj = gid('es_where_search_button');
		}
		
		obj.style.display = obj.style.display=='none' ? '' : 'none';

		//$("div#es_where_search").fadeIn();
		var off = $("#displayWhereOptions").offset();
		var cur_left = off.left -162;
		var cur_top = off.top+20;
		$("div#es_where_search").css("left",cur_left + "px");
		$("div#es_where_search").css("top",cur_top + "px");

		gid('es_where_search_caption').style.display = '';
		gid('es_where_search_results_tr').style.display = 'none';

		//$("div#es_where_search").fadeOut();
		
		
};


function displayESWhereSearch (oContr)
{
	oESWhere.hide();
	//hidePopUp(2);
   gid('es_when_options').style.display = 'none';
	var obj = gid('es_where_search');
		obj.onmouseup = function () 
		{ 
			var oEvent = arguments[0];
			oEvent.cancelBubble = true;
			oEvent.stopPropagation();
		};
	var aPosition = getLeftTop( gid('es_where_search_button') );
		aPosition[0] -= 188;
		aPosition[1] += 21;

	obj.style.display = obj.style.display=='none' ? '' : 'none';

	obj.style.left = aPosition[0] + 'px';
	obj.style.top  = aPosition[1] + 'px';
	
	gid('es_where_search_caption').style.display = '';
	gid('es_where_search_results_tr').style.display = 'none';
	
	var bot = gid( sESWhere_body_content_id ? sESWhere_body_content_id : 'ESBlock');
	
	bot.onmouseup = function () {obj.style.display='none'; };
	
	if(oContr) {
		oContr.onmouseup = function(e){
			hideOthers(3);
			if( !e )
			{
				e = window.event;
				e.cancelBubble = true;
				//obj.style.display = obj.style.display=='none' ? '' : 'none';
				return false;
			}
			e.stopPropagation();
			return false;
		};
	}	
}
	
	

function searchESWhere ()
{
	var sSearch = gid('es_where_search_query').value;
	
	if ( !/[^\s\t]/.test(sSearch) ) {return false;}
	
	var url = 'ajax_events_list_city.php?search=' + sSearch + '&rnd=' + getRandom();
	
	
	var request = GetXmlHttpObject();
	var func = function ()
	{
		gid('es_where_search_caption').style.display = 'none';
		gid('es_where_search_results').innerHTML = request.responseText;
		gid('es_where_search_results_tr').style.display = '';
	};
	
	request.onreadystatechange = function() { onRSC(request,func); };
	request.open( "GET", url, true );
	request.send( null );
}


function setESWhere( sValue, sOutput )
{  
	
	oESWhere.set(sValue,sOutput);
	gid('es_where_search').style.display = 'none';
}




/*-------------------------------------------------------------------------------------------------------------
EVENT SEARCH  -->  WHEN
-------------------------------------------------------------------------------------------------------------*/


var oESWhen = generateEventSearchValueClass('es_when','es_when_options','es_when_option_','date');
var sESWhen_body_content_id = true;

function displayESWhenOptions (obj)
{
	//userSelect=false;
	//alert(userSelect);
	// x, y
	//gid('es_when_options').style.display = gid('es_when_options').style.display == 'none' ? '' : 'none' ;
///	alert(gid('es_when_options').style.display == 'none');

	gid('es_where_search').style.display = 'none';
	gid('es_where_options').style.display = 'none';
	oCalendarPopup.hide();
	var aPosition = getLeftTop(obj);
	if(obj.id == 'es_when') {
		aPosition[0] -= 2;
		aPosition[1] += 26;
	} else {
		aPosition[0] -= 163;
		aPosition[1] += 20;
	}
		oESWhen.display( aPosition, obj);
	hoverFunctionpop();
	
}
	// for j query hovering
	function hoverFunctionpop(){
		cur_id33 = null;
		$("div.what").hover(function(){			
		cur_id33="div#"+this.id;
		$(cur_id33+".what").css("background-color","#EDEDED");
		},function(){
		$(cur_id33+".what").css("background-color","#ffffff");
		});
		$('ul.FrMover1 li').hover(function(){
			$(this).addClass('Dffbg');
				},function(){
			$(this).removeClass('Dffbg');
		});

	}

function hideESWhenOptions ()
{
	oESWhen.hide();
}


var oESCalendar = new Object();
	oESCalendar.body = false;
	oESCalendar.anchor = false;
	
	oESCalendar.date = 0;
	oESCalendar.output_field = false;
	//Date Range
	oESCalendar.dr = false;
	oESCalendar.dr_start     = 0;
	oESCalendar.dr_start_e   = false;
	oESCalendar.dr_start_c   = false;
	oESCalendar.dr_start_out = '';
	oESCalendar.dr_end     = 0;
	oESCalendar.dr_end_e   = false;
	oESCalendar.dr_end_c   = false;
	oESCalendar.dr_end_out = '';
	
	oESCalendar.construct = function (divTemplate, popup, sContentID)
	{
		if(popup || false && sContentID || false) {
			oCalendarPopup.construct('e_search', '', gid(popup), sContentID, divTemplate);
		} else {
			oCalendarPopup.construct('e_search','','','',divTemplate);
		}
		
		oCalendarPopup.onclick = this.select_date;
		
		oESCalendar.output_field = gid('es_when');
		oESCalendar.anchor = gid('es_calendar_button');
	};
	
	
	oESCalendar.display = function (sDate, obj)
	{                                       		
		oCalendarPopup.visbility = false;

		var aPosition = getLeftTop(this.anchor);
		if(obj.id == 'es_when') {
			oCalendarPopup.url.extra += '&homepage=yes';
			aPosition[0] -= 222;
			aPosition[1] += 24;
		} else {
			aPosition[0] -= 189;
			aPosition[1] += 20;
		}
		

			
		oCalendarPopup.place(aPosition);
		var aDates = oESCalendar.parseDate(oESWhen.value);
		if(!aDates[0])
		{
			aDates[0] = document.getElementById('sToday').value;
		}
		var sDate = aDates[0];
		if ( aDates[1] )
		{
			this.dr = true;
			this.dr_start = aDates[0];
			this.dr_end   = aDates[1];
			//alert(aDates[0]);
		}
		else
		{
			this.dr = false;
			this.date = aDates[0];
		}
		
		
		if ( !this.body )
		{
			var bShowDR = this.dr ? 1 : -1;
			
			oCalendarPopup.url.extra += '&body=1';
			oCalendarPopup.onload = function ()
			{
				oCalendarPopup.popup_content = gid('calendar_box');
				oCalendarPopup.url.extra = '';
				oCalendarPopup.onload = function ()
				{
					if ( oESCalendar.dr ) {oESCalendar.mark_dates( oESCalendar.dr_start, oESCalendar.dr_end );}
					else {oESCalendar.mark_dates( oESCalendar.date );}
				};
				
				oESCalendar.body = oCalendarPopup.popup;
				oESCalendar.show_daterange(bShowDR);
				oESCalendar.mark_dates(aDates[0],aDates[1]);
				
				if ( bShowDR>0 )
				{
					oESCalendar.collect_daterange_elements();
					oESCalendar.dr_start_e.value = date_to_output(oESCalendar.dr_start);
					oESCalendar.dr_end_e.value   = date_to_output(oESCalendar.dr_end);
				}
			};
			
		}
		else
		{
			if (  this.dr )
			{
				this.dr_start = aDates[0];
				this.dr_end   = aDates[1];

				this.collect_daterange_elements();
				this.dr_start_e.value = date_to_output(oESCalendar.dr_start);
				this.dr_end_e.value   = date_to_output(oESCalendar.dr_end);
			}
			oESCalendar.show_daterange(bShowDR);
		}
		oCalendarPopup.load(sDate, obj);
	};

	
	oESCalendar.load_calendar = function (sDate)
	{
		oCalendarPopup.load(sDate);
	};


	oESCalendar.select_date = function ( bClearing )
	{
		var aDate = oCalendarPopup.get();
		var sOutput = aDate[2]+' '+aDate[3]+', '+aDate[1];
		oESCalendar.output_field.value = sOutput;
		oESCalendar.date = aDate[0];
		oESCalendar.mark_dates(aDate[0]);
		
		oESWhen.set(oESCalendar.date,sOutput);
	};

	
	oESCalendar.show_daterange = function ( iDirection )
	{
		if ( iDirection||false ) {this.dr = iDirection>0;}
		
		gid('calendar_DR').style.display  = this.dr ? '' : 'none';
		gid('buttonDR_on').style.display  = this.dr ? 'none' : '';
		gid('buttonDR_off').style.display = this.dr ? '' : 'none';
		
		if ( this.dr )
		{
			//this.clear_daterange();
			this.preset_daterange('start');
			
			oCalendarPopup.hide_after_click = false;
		}
		else
		{
			//this.clear_daterange();
			oCalendarPopup.onclick = this.select_date;
			oCalendarPopup.hide_after_click = true;
		}
	};
	
	
	oESCalendar.preset_daterange = function (sType)
	{
		var sColor = '#CCFF9A';
		var whitClolor = '#ffffff';
		var o;
		
		this.collect_daterange_elements();

		switch ( sType ) {
			case 'start' :
				this.output_field = this.dr_start_e;
				this.dr_start_c.style.backgroundColor = sColor;
				this.dr_end_c.style.backgroundColor = whitClolor;
				break;
				
			case 'end' : 
				this.output_field = this.dr_end_e;
				this.dr_start_c.style.backgroundColor = whitClolor;
				this.dr_end_c.style.backgroundColor = sColor;
				break;
				
			default : return false;
		}
		
		oCalendarPopup.onclick = function ()
		{
			var aDate = oCalendarPopup.get();
			var sOut  = aDate[2]+' '+aDate[3]+', '+aDate[1];
			oESCalendar.output_field.value = sOut;
			if ( sType=='start' )
			{
				oESCalendar.dr_start = aDate[0];
				oESCalendar.dr_start_out = sOut;
				oESCalendar.preset_daterange('end');
			}
			else
			{
				oESCalendar.dr_end = aDate[0];
				oESCalendar.dr_end_out = sOut;
				//oESCalendar.preset_daterange('start');
			}
			oESCalendar.mark_dates(oESCalendar.dr_start,oESCalendar.dr_end);
		};
		
	};
	
	
	oESCalendar.mark_dates = function ( iStart,iEnd )
	{
		if ( iStart||false ) {iEnd=(iEnd||false) ? iEnd : iStart;}
		else {return false;}
		
		if ( iEnd!=0 && iStart!=0 && iStart<=iEnd )
		{
			
			var aTC;
			var aTR = gid('calendar_table').tBodies[0].rows;
			var sDate;
			
			for (var i=0,l=aTR.length;i<l;i++)
			{
				aTC = aTR[i].cells;
				for (var k=0,m=aTC.length;k<m;k++)
				{
					if ( sDate=aTC[k].getAttribute('date') )
					{
						if ( iStart<=sDate && sDate<=iEnd )
						{
							aTC[k].style.backgroundColor ="#61A4EB";
							aTC[k].setAttribute('onmouseover','this.style.color=\'#ffffff\';');
							aTC[k].setAttribute('onmouseout','this.style.color=\'#000000\';');
						}
						else
						{
							aTC[k].style.backgroundColor ="#ffffff";
							aTC[k].setAttribute('onmouseover','this.style.color=\'#ffffff\';this.style.backgroundColor=\'#61A4EB\';');
							aTC[k].setAttribute('onmouseout','this.style.color=\'#000000\';this.style.backgroundColor=\'#ffffff\';');
						}
					}
				}
			}
			
		}
	};
	
	
	oESCalendar.clear_daterange = function ()
	{
		this.dr_start = 0;
		this.dr_start_e.value = '';
		this.dr_end = 0;
		this.dr_end_e.value = '';
		
		this.clear_calendar();
	};
	
	
	oESCalendar.clear_calendar = function ()
	{
		var aTC;
		var aTR = gid('calendar_table').tBodies[0].rows;
		for (var i=0,l=aTR.length;i<l;i++)
		{
			aTC = aTR[i].cells;
			for (var k=0,m=aTC.length;k<m;k++)
			{
				if ( sDate=aTC[k].getAttribute('date') )
				{
					aTC[k].style.backgroundColor ="#ffffff";
					aTC[k].setAttribute('onmouseover','this.style.color=\'#ffffff\';this.style.backgroundColor=\'#61A4EB\';');
					aTC[k].setAttribute('onmouseout','this.style.color=\'#000000\';this.style.backgroundColor=\'#ffffff\';');
				}
			}
		}
		
	};
	

	oESCalendar.set_daterange = function ()
	{
		if(this.dr_start > this.dr_end) {
			var sValue = this.dr_end+"|"+this.dr_start;
		} else {
			var sValue = this.dr_start+"|"+this.dr_end;
		}
		var firdate = date_to_output(this.dr_start);
		var secdate = date_to_output(this.dr_end);
		var firyear = firdate.split(', ');
		var secyear = secdate.split(', ');
		if(firyear[1] == secyear[1]) {
			var sOutput =  firyear[0] + ' - ' + secyear[0];
		} else {
			var sOutput =  firdate + ' - ' + secdate;
		}
		//var sOutput =  date_to_output(this.dr_start) + ' - ' + date_to_output(this.dr_end);
		oESWhen.set(sValue,sOutput);
		oCalendarPopup.hide();
	};
	
	
	oESCalendar.collect_daterange_elements = function ()
	{
		if ( !this.dr_start_e )
		{
			this.dr_start_c = gid('es_when_start_date_container');
			this.dr_start_e = gid('es_when_start_date');
			this.dr_end_c = gid('es_when_end_date_container'); 
			this.dr_end_e = gid('es_when_end_date'); 
		}
	};
	
	
	oESCalendar.parseDate = function (sDate)
	{
		if ( sDate )
		{
		if ( sDate.search(/|/)>-1 )
		{
			return sDate.split('|');
		}
		else
		{
			return new Array(sDate,false);
		}
		}
		else
                {
                        return new Array(sDate,false);
                }
	};


function displayESCalendar( sDate, obj )
{   
	gid('es_when_options').style.display = 'none';
	gid('es_where_search').style.display = 'none';
	gid('ESBlock').onmouseup = function () {if(gid('find_event2').style.display !='none'){oCalendarPopup.hide();} };
	oESCalendar.display( sDate,obj );
	
}


function loadESCalendar( sDate )
{
	oESCalendar.load_calendar( sDate );
}


function showDateRange ( dir )
{
	oESCalendar.clear_daterange();
	oESCalendar.show_daterange( dir );
}


function presetDateRange( sType )
{
	oESCalendar.preset_daterange(sType);
}


function setDateRange ()
{
	oESCalendar.set_daterange();
}


function setDateRangeFromInput ( obj )
{
	var value  = obj.id=='es_when_start_date' ? 'dr_start' : 'dr_end';
	var out    = value+'_out';
	var sInput = obj.value;
	
	if ( oESCalendar[out]!=sInput )
	{
		if ( aRes=parse_date_input(sInput) ) 
		{
			oESCalendar[value] = aRes[0];
			oESCalendar[out]!=sInput;
			oESCalendar.mark_dates(oESCalendar.dr_start,oESCalendar.dr_end);
		}
	}
}


function setInputDate( obj )
{
	var sInput = obj.value;
	if ( oESWhen.out_value!=sInput )
	{
		var aDates = sInput.match(/[\da-z-_.]{8,}/ig);
		if ( !aDates ) {return false;}
		
		var sValue;
		var d0,d1;
		
		switch ( aDates.length )
		{
			case 1 :
				sValue = (d0=parse_date_input(aDates[0])[0]) ? d0 : false;
				break;
			
			case 2 :
				d0 = parse_date_input(aDates[0])[0];
				d1 = parse_date_input(aDates[1])[0];
				sValue = (d0&&d1) ? d0+'|'+d1 : false;
				break;
				
			default :
				sValue = false;
		}
		
		oESWhen.set( sValue ? sValue : sInput,false );	
	}
}






function date_to_output ( sDate )
{
	var tmp = aMonthes;
	var aDate = sDate.split('-');
	var sOutput = aMonthes[parseInt(aDate[1],10)]+' '+aDate[2]+', '+aDate[0];
	
	return sOutput;
}




/*-------------------------------------------------------------------------------------------------------------
SEARCHING EVENTS
-------------------------------------------------------------------------------------------------------------*/



function getESQuery ()
{
	var sDate  = oESWhen.value;
	var sPlace = oESWhere.value;
	var sTxt = gid('es_what').value
	if(sTxt == 'Whatcha feel like doing?') {sTxt ='';}
	sTxt = encodeURIComponent(sTxt);
	
	var sDistance = encodeURIComponent(gid('es_within').value);
	if(sDate === false)
	{
	        return 'q=place:' + sPlace +
                      		';squery:' + sTxt + 
                        	';dist:' + sDistance+"&srch=1"; 

	}
	return 'q=sdate:'+sDate + 
			';place:' + sPlace + 
			';squery:' + sTxt + 
			';dist:' + sDistance+"&srch=1"; 
}

var userSelect = false;
function searchEvent ()
{
	if(gid('es_within').value == '0') {
		return false;
	}
	if(userSelect == true) {
		searchHomeESWhere();
		return false;
	}

	window.location.href = 'events_list.php?'+getESQuery();
}




/*-------------------------------------------------------------------------------------------------------------
ADD SEARCH ACTION ON "ENTER/RETURN" KEY PRESSING  
-------------------------------------------------------------------------------------------------------------*/


function setSearchAction(e)
{
	e=e||window.event;
	if (e.keyCode==13) {
	
		if(userSelect == true) {
			searchHomeESWhere();
			return false;
		}
		if(gid('es_where_options').style.display=='none' && gid('es_when_options').style.display=='none' && gid('es_where_search').style.display=='none' ) {
			searchEvent();
		}
		
	}
}




/*-------------------------------------------------------------------------------------------------------------
POPUPS MANAGEMENT
-------------------------------------------------------------------------------------------------------------*/


function hidePopUp(iIndex)
{

	switch(iIndex)
	{
		case 0 :
		    //oESWhen.hide();
		    break;
		case 1 :
			oCalendarPopup.hide();
			break; 
		case 2 :
			/*if(gid('homelocChanged')) {
				curSel = oEsArrow.currentSelection;
				alert(curSel);
				removeEvent(gid('es_where'),'keydown');
			}*/
			oESWhere.hide();
			break;
		case 3 :
			/*if(gid('homelocChanged')) {
				removeEvent(gid('es_where'),'keydown', null);
			}*/
			gid('es_where_search').style.display = 'none';
			break;
	}
}

function hideOthers(iNotHide)
{

	for(var i=0; i<iNotHide; i++)
	{
		hidePopUp(i);
	}
	
	var iS = iNotHide+1;

	for(var i=iS; i<4; i++)
	{
	    hidePopUp(i);
	}

}

function stopEvent(e)
{
	/*
	if( !e )
	{
		e = window.event;
		e.cancelBubble = true;
		return false;
	}
	e.stopPropagation();
	*/
	return false;
}


//ADDED BY DIVYA FOR RETURN KEY
function checkEnter(e){
var characterCode;
	 if(e && e.which){
	 e = e;
	 characterCode = e.which;
	 }
	 else{
	 e = event;
	 characterCode = e.keyCode;
	 }	 
	 if(characterCode == 13){
 	 searchEvent();
 	 return false;
	 }
return true;
	
}

function checkVal(obj, val) {
	if(obj.value == '') {
		obj.value = val;
	}
}