/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();

jQuery(document).ready(function(){
jQuery("#xlsSearch").bind('keyup',autosuggest);	
});


/* -------------------------- */
/* setCaptchaImage -- used to refresh captcha images throughout the site
/* -------------------------- */
function setCaptchaImage(name){ $('#captcha-verif-img').attr('src', name); }

/* -------------------------- */
/* SEARCH					 */
/* -------------------------- */
function autosuggest(event) {
var search = document.getElementById('xlsSearch').value;
if (event.keyCode == 13) { document.location.href='/shop/index.php?search='+search; }
if (event.keyCode == 40) { traverse("down"); return;}
if (event.keyCode == 38) { traverse("up"); return;}

nocache = Math.random();
http.open('get', '/shop/xls_ajax_search.php?q='+search+'&nocache = '+nocache);
http.onreadystatechange = function() {//Call a function when the state changes.
	if(http.readyState == 4){
		var response = http.responseText;
		var e = document.getElementById('searchoptions');
		e.style.display='inline';
		if(response!=""){
			e.innerHTML=response;
			e.style.display="block";
		} else {
			e.style.display="none";
		}
	}
}
http.send(null);

}





jQuery(document).ready(function() {
jQuery('.sale-2').prepend('<div class="saley"></div>');
jQuery('.feature').prepend('<div class="featurey"></div>');
jQuery("ul.twitterblock li:last-child").addClass("last"); 
jQuery("#content ul.submenu li:first-child").addClass("first"); 
jQuery("#content ul.submenu li:last-child").addClass("last"); 
jQuery("select, input:checkbox, input:radio").uniform(); 
jQuery("input[type='search']").clone().attr("type", "text").attr("placeholder","Search For...").prependTo(".sbox");
jQuery("input[type='search']:not(.ac_input)").remove();

    

//------PLACEHOLDER---//
function activatePlaceholders() {
		var detect = navigator.userAgent.toLowerCase(); 
		if (detect.indexOf("safari") > 0) return false;
		var inputs = document.getElementsByTagName("input");
		for (var i=0;i<inputs.length;i++) {
			if (inputs[i].getAttribute("type") == "text") {
				var placeholder = inputs[i].getAttribute("placeholder");
				if (placeholder.length > 0) {
					inputs[i].value = placeholder;
					inputs[i].onclick = function() {
						if (this.value == this.getAttribute("placeholder")) {
							this.value = "";
						}
						return false;
					}
					inputs[i].onblur = function() {
						if (this.value.length < 1) {
							this.value = this.getAttribute("placeholder");
						}
					}
				}
			}
		}
	}
	
	window.onload = function() {
		activatePlaceholders();
	}
	})
	
	
