if(location.hostname == 'localhost')
siteUrl = "http://localhost/clients/newsite";
else
siteUrl = "http://createcafe.tri-comm3.co.uk";

function selectAction1(f){
	if(document.actionForm.selAction.value == ''){
			
			alert("Please select an action to be performed");
				
			return false;
			
	}
	if(document.actionForm.selAction.value != 'drop'){
	document.listingForm.mode.value = "performAction";
	document.listingForm.selectedAction.value = document.actionForm.selAction.value;
	sendRequest(f,'performAction');
	}
	else{
	document.listingForm.mode.value = "performDelete";
	document.listingForm.selectedAction.value = document.actionForm.selAction.value;
	sendRequest(f,'performDelete');
	}
	
	//document.listingForm.submit();
	return false;
}


function selectAction(){
	
	if(document.actionForm.selAction.value == ''){
			
			alert("Please select an action to be performed");
				
			return false;
			
	}
	if(document.actionForm.selAction.value != 'drop')
	document.listingForm.mode.value = "performAction";
	else
	document.listingForm.mode.value = "performDelete";
	document.listingForm.selectedAction.value = document.actionForm.selAction.value;
	document.listingForm.submit();
	return false;
}


function showNextPage(path, extraParams){

	var redirectURL = path + extraParams + "mode=list&page=" + document.getElementById('pageSelect').value;
	sendRequest(redirectURL);
	/*window.location.href = redirectURL;*/
}



function FormField(name, description, type, additional_params){
	
	this.name = name;
	this.description = description;
	this.type = type;	
	this.additional_params = additional_params; // multi-use
	this.isValid = function(f){
			
				switch(this.type){
					case "text" :
					return (f.elements[this.name].value != "");
					break;
					
					case "number" :
					var number_regex = /^[0-9]+$/;
					return ( number_regex.test(f.elements[this.name].value));
					break;
					
					case "email" :
					var email_regex = /^([a-z0-9_-]+\.)*[a-z0-9_-]+@([a-z0-9_-]+\.)+[a-z]{2,3}$/i;
					return (email_regex.test(f.elements[this.name].value));
					break;
					
					default : return false;
				};
		};
	
}


function validateForm(f){
	
		var fields_with_errors = new Array();
		for (var i in required_fields){
				if(!required_fields[i].isValid(f)){
					
					fields_with_errors[fields_with_errors.length] = required_fields[i].description;
				}
		}
		
		if(fields_with_errors.length > 0){
			alert("Make sure following fields are complete and correct:\n\n-" + fields_with_errors.join("\n -"));
			return false;
		}else{
		return true;
		}
		return false;
}




function changeDate(val,elem){
	
	
elem.value = val;
}


function changeID(id,f){

document.listingForm.id.value =	id;
document.listingForm.mode.value =	'edit';

sendRequest(f);
}


function changeMode(mode,f){
f.mode.value =	mode;
sendRequest(f);
}
//window.onload = timer();

function timer()
{
				setTimeout("timer()", 1000);
				var date = new Date();
				//document.getElementById("showtime").innerHTML = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
				
}

function checkSearch(){
	
	
	if(document.searchForm.searchField.value == '')	{
	document.getElementById("divSearchError").style.display  = "";
	document.searchForm.searchValue.blur();
	return false;
	}
	else{
		document.getElementById("divSearchError").style.display  = "none";;
	}
	return true;
	
}
	
	
	
	
