var indexsection=0;

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


function showwelcome(){
	try{
		
		$("#sectioncontents").load("welcome.php",null,function(){
			jQuery('#mycarousel').jcarousel({
		        auto: 5,
		        wrap: 'last',
				scroll: 1,
				animation: 'slow',
		        initCallback: mycarousel_initCallback
		    });
		});
		
		indexsection=0;
		savesession('indexsection',indexsection);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}

function showprofile(){
	try{
		
		
		$("#sectioncontents").load("profile.php",null,function(){
			jQuery('#mycarousel2').jcarousel({
		        auto: 5,
		        wrap: 'last',
				scroll: 4,
				animation: 'slow',
		        initCallback: mycarousel_initCallback
		    });
		});
		indexsection=1;
		savesession('indexsection',indexsection);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}


function showquote(){
	try{
		
		
		$("#sectioncontents").load("quote.php");
		indexsection=2;
		savesession('indexsection',indexsection);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}


function showcontactus(){
	try{
		
		
		$("#sectioncontents").load("contactus.php");
		indexsection=3;
		savesession('indexsection',indexsection);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}


function showproducts(){
	try{
		$("#sectioncontents").load("products.php");
		indexsection=7;
		savesession('indexsection',indexsection);
	}
	catch(e){
		alert(e.toString());
	}
}


function products(section){
	try{
		
		
		$("#sectioncontents").load("products.php",{sec: section},
		function(){
			jQuery('#mycarousel').jcarousel({
		        auto: 5,
		        wrap: 'last',
				scroll: 1,
				animation: 'slow',
		        initCallback: mycarousel_initCallback
		    });
		});
		indexsection=4;
		savesession('indexsection',indexsection);
		savesession('lastproductsection',section);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}

function showoffers(){
	try{
		
		
		$("#sectioncontents").load("offers.php");
		indexsection=5;
		savesession('indexsection',indexsection);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}



function showservices(service){
	try{
		
		
		$("#sectioncontents").load("services.php", {service: service});
		indexsection=6;
		savesession('indexsection',indexsection);
		
		
	}
	catch(e){
		alert(e.toString());
	}
}


function showproductsubsection(subsec){
	try{
		
		$("#productsdisplay").load("products.php", {subsec: subsec},
		function(){
			jQuery('#mycarousel').jcarousel({
		        auto: 5,
		        wrap: 'last',
				scroll: 1,
				animation: 'slow',
		        initCallback: mycarousel_initCallback
		    });
		});
		savesession('subsec',subsec);
		
	}
	catch(e){
		alert(e.toString());
	}
}



function showproductcontents(section){
	try{
		
		window.scrollTo(0,0);
		$("#productlist").load("productlist.php", {section: section});
		
	}
	catch(e){
		alert(e.toString());
	}
	
}


function searchsection(){
	try{
		
		
		$("#sections").load("sections.php", {section: $("#sectionsearch").val()})
		
		
	}
	catch(e){
		alert(e.toString());
	}
}
