function ajax(url, parameters) {
    http_request = false;
    
    if( window.XMLHttpRequest ){ // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
        if( http_request.overrideMimeType ) http_request.overrideMimeType('text/html');
    } else if( window.ActiveXObject ){ // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e){
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e){}
        }
    }
    if( !http_request ){
        alert('ERROR: cannot execute ajax...');
        return false;
    }
    
    http_request.open('POST', url, false);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    http_request.send(parameters);
    
    if( http_request.readyState == 4 && http_request.status == 200 ){
        return http_request.responseText;
    } else return false;
}

function clearStart(){
	if(document.getElementById("seach_site").value == 'Quick Product Search'){
		document.getElementById("seach_site").value ='';
	}
}

function populateStart(){
	if(document.getElementById("seach_site").value == ""){
		document.getElementById("seach_site").value ='Quick Product Search';
	}
}

function changeArrow(id){
	
	if(document.getElementById(id+"_shopby_arrow").style.backgroundImage ==''){
		document.getElementById(id+"_shopby_arrow").style.backgroundImage = 'url("/images/shopby_arrow.png")';
	}else if(document.getElementById(id+"_shopby_arrow").style.backgroundImage == 'url("/images/shopby_arrow.png")'){
		document.getElementById(id+"_shopby_arrow").style.backgroundImage = 'url("/images/shopby_arrow_down.png")';
	}else if(document.getElementById(id+"_shopby_arrow").style.backgroundImage == 'url("/images/shopby_arrow_down.png")'){
		document.getElementById(id+"_shopby_arrow").style.backgroundImage = 'url("/images/shopby_arrow.png")';
	}
	
	//$('.side_nav_info_mask_btm').css('bottom', '0');
	/*$('.side_nav_shopby_wrapper').stop().animate({
		  backgroundColor: "#ff0000"
		}, 5000, function(){ 
			alert("h");
	})*/
}


function setOpacityElement( value, id ) {
 document.getElementById(id).style.opacity = value / 10;
 document.getElementById(id).style.filter = 'alpha(opacity=' + value * 10 + ')';
}
 
function fadeInMyElement(id) {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacityElement(' + (i / 10) + ', "'+id+'")' , 8 * i );
}
 
function fadeOutMyElement(id) {
	//if(document.getElementById(id).style.opacity > 0.2 || document.getElementById(id).style.filter > 20){	
		for( var i = 0 ; i <= 100 ; i++ ) {
		  setTimeout( 'setOpacityElement(' + (10 - i / 10) + ', '+id+')' , 8 * i );
		}
	//}
}
function loadProductImage(img, element){
	
	document.getElementById(element).innerHTML='';
	document.getElementById(element).style.opacity = 0;
 	document.getElementById(element).style.filter = 'alpha(opacity=0)';
	document.getElementById(element).innerHTML='<img src="'+img+'">';
	
	fadeInMyElement(element);
}

function forwardLink(url){
	window.open(url,'_blank');
}
