function slideShow(speed) {

    //append a LI item to the UL list for displaying caption
    $('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h23></h23><p></p></div></li>');

    //Set the opacity of all images to 0
    $('ul.slideshow li').css({opacity: 0.0});

    //Get the first image and display it (set it to full opacity)
    $('ul.slideshow li:first').css({opacity: 1.0});
    $('ul.slideshow li:first').addClass('show');

    //Get the caption of the first image from REL attribute and display it
    $('#slideshow-caption h23').html($('ul.slideshow li:first').find('img').attr('title'));
    $('#slideshow-caption p').html($('ul.slideshow li:first').find('img').attr('alt'));


    //Display the caption
    $('#slideshow-caption').css({opacity: 0.7, bottom:0});

    //Call the gallery function to run the slideshow    
    var timer = setInterval('gallery()',speed);

    //pause the slideshow on mouse over
    $('ul.slideshow').hover(
        function () {
            clearInterval(timer);   
        },  
        function () {
            timer = setInterval('gallery()',speed);         
        }
    );

}

   
 function gallery() {  
   
   
     //if no IMGs have the show class, grab the first image  
     var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));  
   
     //Get next image, if it reached the end of the slideshow, rotate it back to the first image  
     var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));  
           
     //Get next image caption  
     var title = next.find('img').attr('title');   
     var desc = next.find('img').attr('alt');      
           
     //Set the fade in effect for the next image, show class has higher z-index  
     next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);  
       
     //Hide the caption first, and then set and display the caption  
     $('#slideshow-caption').animate({bottom:-70}, 300, function () {  
             //Display the content  
             $('#slideshow-caption h23').html(title);  
             $('#slideshow-caption p').html(desc);                 
             $('#slideshow-caption').animate({bottom:0}, 500);     
     });       
   
     //Hide the current image  
     current.animate({opacity: 0.0}, 1000).removeClass('show');  
   
 }  
// JvaScript Document
var last_category='';
var last_brand='';
var last_stype='';
var last_minp=0;
var last_maxp=0;


/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* The variable http will hold our new XMLHttpRequest object. */
var http2 = createRequestObject();
var http3 = createRequestObject();
var http4 = createRequestObject();

function doClick(page){
		document.getElementById('content').innerHTML = '<div class="spacer"><br /><br /></div><div align="center" class="centercontent"><img align="center" src="img/loading.gif"></div><div class="spacer"><br /><br /></div>';
	http4.open('post',page);
	http4.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http4.onreadystatechange = handleClick;
	http4.send(null);
	}

function handleClick(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http4.readyState == 4){ //Finished loading the response
	
		var response = http4.responseText;
		document.getElementById('content').innerHTML = '';
		document.getElementById('content').innerHTML = response;
	}
}




function doSearch(limit){
	document.getElementById('content').innerHTML = '<div class="spacer"><br /><br /></div><div align="center" class="centercontent"><img align="center" src="img/loading.gif"></div><div class="spacer"><br /><br /></div>';
	http3.open('post',  'search.php?');
	var s=limit;
	http3.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http3.onreadystatechange = handleSearch;
	http3.send('q='+document.search_form.q.value+'&s='+s);
	}

function handleSearch(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http3.readyState == 4){ //Finished loading the response
	
		var response = http3.responseText;
		document.getElementById('content').innerHTML = response;
	}
}


function getProducts(category,brand,stype,minp,maxp){
	document.getElementById('content').innerHTML = '<div class="spacer"><br /><br /></div><div align="center" class="centercontent"><img align="center" src="img/loading.gif"></div><div class="spacer"><br /><br /></div>';
	last_category=category;
	last_brand=brand;
	last_stype=stype;
	last_minp=minp;
	last_maxp=maxp
	if(stype=="cat"){
		http2.open('post',  'products_cat.php?');
		http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http2.onreadystatechange = handleGetProducts;
		http2.send('select_category='+category);
	}
	else if(stype=="cat_brand"){
		http2.open('post',  'products_cat_brand.php?');
		http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http2.onreadystatechange = handleGetProducts;
		
		http2.send('select_category='+category+'&select_brand='+brand);
		
	}
	else if(stype=="brand"){
		http2.open('post',  'products_brand.php?');
		http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http2.onreadystatechange = handleGetProducts;
		http2.send('select_brand='+brand);
	
	}
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleGetProducts(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http2.readyState == 4){ //Finished loading the response
		var response2 = http2.responseText;
		document.getElementById('content').innerHTML = response2;
		
	}
	
}
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 50);
    }
}


function getProductsNew(category,brand,stype,minp,maxp){
	document.getElementById('content').innerHTML = '<div class="spacer"><br /><br /></div><div align="center" class="centercontent"><img align="center" src="img/loading.gif"></div><div class="spacer"><br /><br /></div>';
	last_category=category;
	last_brand=brand;
	last_stype=stype;
	last_minp=minp;
	last_maxp=maxp
	if(stype=="cat"){
		http2.open('post',  'products_cat_new.php?');
		http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http2.onreadystatechange = handleGetProducts;
		http2.send('select_category='+category);
	}
	else if(stype=="cat_brand"){
		http2.open('post',  'products_cat_brand_new.php?');
		http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http2.onreadystatechange = handleGetProducts;
		
		http2.send('select_category='+category+'&select_brand='+brand);
		
	}
	else if(stype=="brand"){
		http2.open('post',  'products_brand_new.php?');
		http2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http2.onreadystatechange = handleGetProducts;
		http2.send('select_brand='+brand);
	
	}
}