function showNotify(message) {
	document.getElementById("notify").innerHTML = message;
	document.getElementById("notify").className = 'notify_on';
	//clearTimeout(window);
	clearMessage = setTimeout("clearNotify()",3000);	
}


function clearNotify() {
	document.getElementById("notify").innerHTML = 'Briefcase actions here...';
	document.getElementById("notify").className = 'notify_off';
	clearTimeout(clearMessage);
}


function getAuthor() {
	var fname = document.getElementById("find_fname").value;
	var lname = document.getElementById("find_lname").value;
	
	if(lname == 'Search Authors'){
		
		return false;
	}
	
	var url = "/search/showAuthors.cfm?action=send" + "&firstname=" + escape(fname) + "&lastname=" + escape(lname);
	
//	AjaxRequest.get(
//		{
//		  'url':url
//		  ,'onSuccess':function(req){
//				document.getElementById("find_list").style.display ='block';
//				document.getElementById("find_list").innerHTML = req.responseText;
//				document.getElementById("find_list").focus();
//			}//function(req);
//		}
//	)
	
	Ext.Ajax.request({
	url : url, 
	method: 'GET',
	success: function ( result, request ) { 
	
		document.getElementById("find_list").style.display ='block';
		document.getElementById("find_list").innerHTML = result.responseText;
		document.getElementById("find_list").focus();
	
	},
	failure: function ( result, request) { 

	} 
});
	
	
	
	
}//getAuthor()



function editEvent(action, em_id, IsMultiDay) {//alert('search.js');
	var url = "/search/edit_event.cfm?action=" + escape(action) + "&event_id=" + escape(em_id) + "&ismultiday=" + escape(IsMultiDay);
	
	//AjaxRequest.get(
//		{
//		  'url':url
//		  ,'onSuccess':function(req){
//				if (document.getElementById) {
//					var theplus = document.getElementById("plus"+em_id);
//					var theminus = document.getElementById("minus"+em_id);
//				}		
//				if (theminus.style.display == "") {
//					theplus.style.display = "";
//					theminus.style.display = "none";
//					return;
//				}
//				else {
//					theplus.style.display = "none";
//					theminus.style.display = "";		
//				}
//			}//function(req);
//		}
//	)
	
	
if (IsMultiDay == 1 && escape(action) == 'add') {

//
//Ext.apply(Ext.form.VTypes, {
//    daterange : function(val, field) {
//        var date = field.parseDate(val);
//
//        if(!date){
//            return false;
//        }
//        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
//            var start = Ext.getCmp(field.startDateField);
//            start.setMaxValue(date);
//            start.validate();
//            this.dateRangeMax = date;
//        }
//        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
//            var end = Ext.getCmp(field.endDateField);
//            end.setMinValue(date);
//            end.validate();
//            this.dateRangeMin = date;
//        }
//        /*
//         * Always return true since we're only using this vtype to set the
//         * min/max allowed values (these are tested for after the vtype test)
//         */
//        return true;
//    }
//});
	
	
	var fp = new Ext.FormPanel({
		//	xtype: 'form',
			labelWidth: 65,
			frame: false,
			bodyStyle: 'background:transparent;padding:5px 10px 10px;',
			bodyBorder: false,
			border: false,
			defaults: {
        allowBlank: false
		},
			
				items:[ 
						{xtype: 'datefield',


							
	                	fieldLabel: 'Date',
	                	name: 'date',
						minValue:'11-28-2010', 
						maxValue:'12-03-2010'
						
	            		},{
						xtype: 'timefield',
							
	                	fieldLabel: 'Time',
	                	name: 'time',
	                	minValue: '7:30am',
	                	maxValue: '6:00pm'
				
	            		}
						
					],
					buttons: [{
						
						
			
            text: 'Add Event',
            handler: function(){

                if(fp.getForm().isValid()){
	       
                    fp.getForm().submit({
	                    url: url,
						method:'GET',
//						params: {comm:'#form.comm#'},
//	                    //waitMsg: 'Adding the Event...',
//				
	                    success: function(fp, o){
							win.close();

						if (document.getElementById) {
							var theplus = document.getElementById("plus"+em_id);
							var theminus = document.getElementById("minus"+em_id);
						}		
						if (theminus.style.display == "") {
							theplus.style.display = "";
							theminus.style.display = "none";
							showNotify('Event removed from briefcase');
							return;
						}else{
							theplus.style.display = "none";
							theminus.style.display = "";
							showNotify('Event added to briefcase');		
						}

//					
	                 },
						failure: function(form, action) {
//	                        Ext.MessageBox.alert('Add Document', 'There was a problem adding the file. Please try again later.');					
						}
	                });
           
           
                }else{
					
					
				}

            }
        }]
			
			  });	
	
	var win = new Ext.Window({
		id: 'DateTimeSelect',
		title: 'Event Date',
		width: 500,
		height: 200,
		//randnum:randomnumber,
		modal: true,
		autoScroll: true,
		//iconCls:iconCls,
	
	
		items:[fp]
	}).show();
	
	
}else {

		Ext.Ajax.request({
		url : url, 
		method: 'GET',
		success: function ( result, request ) { 
					if (document.getElementById) {
						var theplus = document.getElementById("plus"+em_id);
						var theminus = document.getElementById("minus"+em_id);
					}		
					if (theminus.style.display == "") {
						theplus.style.display = "";
						theminus.style.display = "none";
						showNotify('Event removed from briefcase');
						return;
					}else{
						theplus.style.display = "none";
						theminus.style.display = "";
						showNotify('Event added to briefcase');		
					}
	
		},
		failure: function ( result, request) { 
	
		} 
	});

}
	
}//editEvent(action, em_id)



function editEventExhibitor(action, exhibitorID) {
	var url = "/search/edit_event_exhibitor.cfm?action=" + escape(action) + "&exhibitorID=" + escape(exhibitorID);
	
//	AjaxRequest.get(
//		{
//		  'url':url
//		  ,'onSuccess':function(req){
//				if (document.getElementById) {
//					var theplus = document.getElementById("plus"+exhibitorID);
//					var theminus = document.getElementById("minus"+exhibitorID);
//				}		
//				if (theminus.style.display == "") {
//					theplus.style.display = "";
//					theminus.style.display = "none";
//					return;
//				}
//				else {
//					theplus.style.display = "none";
//					theminus.style.display = "";		
//				}
//			}//function(req);
//		}
//	)
	
	
	Ext.Ajax.request({
	url : url, 
	method: 'GET',
	success: function ( result, request ) { 

				if (document.getElementById) {
					var theplus = document.getElementById("plus"+exhibitorID);
					var theminus = document.getElementById("minus"+exhibitorID);
				}		
				if (theminus.style.display == "") {
					theplus.style.display = "";
					theminus.style.display = "none";
					return;
				}else{
					theplus.style.display = "none";
					theminus.style.display = "";		
				}

	},
	failure: function ( result, request) { 

	} 
});
	
}//editEventExhibitor(action, exhibitorID)



function getEventChildren(em_id) {
	var url = "/search/show_event_children.cfm?em_id=" + escape(em_id);
	
//	AjaxRequest.get(
//		{
//		  'url':url
//		  ,'onSuccess':function(req){
//				//document.getElementById("childEvents"+em_id).style.display ='block';
//				//document.getElementById("childEvents"+em_id).innerHTML = req.responseText;
//				//executeJavascript("childEvents"+em_id); 
//				
//				if (document.getElementById) {
//					var theplus = document.getElementById("showChildLink"+em_id);
//					var theminus = document.getElementById("hideChildLink"+em_id);
//					var showChildren = document.getElementById("childEvents"+em_id);
//				}		
//				if (theminus.style.display == "") {
//					theplus.style.display = "";
//					theminus.style.display = "none";
//					showChildren.style.display = "none";
//					return;
//				}
//				else {
//					theplus.style.display = "none";
//					theminus.style.display = "";
//					showChildren.style.display = "";
//				}
//				
//			}//function(req);
//		}
//	)
	
	Ext.Ajax.request({
	url : url, 
	method: 'GET',
	success: function ( result, request ) { 


				
				if (document.getElementById) {
					var theplus = document.getElementById("showChildLink"+em_id);
					var theminus = document.getElementById("hideChildLink"+em_id);
					var showChildren = document.getElementById("childEvents"+em_id);
				}		
				if (theminus.style.display == "") {
					theplus.style.display = "";
					theminus.style.display = "none";
					showChildren.style.display = "none";
					return;
				}else{
					theplus.style.display = "none";
					theminus.style.display = "";
					showChildren.style.display = "";
				}

			

	},
	failure: function ( result, request) { 

	} 
	});
	
	
	
	
}//getEventChildren(em_id)



function executeJavascript(divid){	//alert("divid: " + divid);
	//execute any javascript
	if(divid != "myText") {
	var d=document.getElementById(divid).getElementsByTagName("script");
	//alert("D: " + document.getElementById("center").innerHTML);
	for(var x=0;x<d.length;x++) {
		with(window) {
			eval(d[x].text);
		}// end with
	}// end for
	}
}


function cleartextfield(formfield){

	if(formfield.style.color != 'black'){
	formfield.style.fontStyle='normal';
	formfield.style.color='black';
	formfield.value='';
	}
	
}


function validateSearch(oForm){
	
if(oForm.textSearch.value == 'Search Events'){
	return false;
} 	else{
	
	return true;
}
/*
console.log(oForm);
return false;
	*/
}


function validateSavedSearch(oForm){
	
if (oForm.savedSearch.value == 'SavedSearches') {
	return false;
}else{
	return true;
}
	
}

