/*************************************************************/
/* External JavaScript for Wroes Ltd.                        */
/* See comments for further information                      */
/* (c) Wroes Ltd. 2007                                       */
/* Developed by AC Multimedia                                */
/* http://www.acmultimedia.co.uk                             */
/*************************************************************/

document.onclick = hideQuickLook;

function homeSelect(){
	var department = document.getElementById('d').value;
	var brand = document.getElementById('b').value;
	if (department != ""){
		window.location = department;
	}
	if (brand != ""){
		window.location = brand;
	}
	return false;
}

function departmentSelect(){
	var brand = document.getElementById('b').value;
	if (brand != ""){
		window.location = brand;
	}
	return false;
}

function checkTerms(){
	var terms = document.getElementById('terms');
	if (terms.checked == true){
		return true;
	}else{
		alert("Please agree to our terms and conditions before proceeding.");
		return false;
	}
}

function hideQuickLook(){
	document.getElementById("quickLook").style.display = 'none';
}

function quickLook(textbox){
	var query = textbox.value;
	if (query.length > 2){
		
		document.getElementById("quickLook").style.display = 'inline';
		var poststr = "q=" + query;
		ajaxpack.postAjaxRequest("http://www.wroes.co.uk/scripts/ajax_search.php", poststr, alertContents, "text");
		
	}else{
		document.getElementById("quickLook").style.display = 'none';
	}
}

function alertContents() {
	var myajax=ajaxpack.ajaxobj;
	var myfiletype=ajaxpack.filetype;
	if (myajax.readyState == 4) {
		if (myajax.status == 200) {
			result = myajax.responseText;
			document.getElementById('quickLook').innerHTML = result;
			if (result != ""){
				document.getElementById('quickLook').style.display = "inline";
			}else{
				document.getElementById('quickLook').style.display = "none";
			}
		}else{
			//alert('There was a problem with the request.');
		}
	}
}

function searchInput(textinput, cssclass){
	if(textinput.value == "Enter keyword(s)"){
		textinput.value = "";
	}
	textinput.className = cssclass;
}