$(function() {
    // init slider
    LoadSlider('/');
    
    // Music player
	$("#music").jPlayer({
		ready: function () {
			$(this).jPlayer("setMedia", {
				mp3: "http://www.sexygirljewelry.com/music/bgsong.mp3"
			}).jPlayer("play");
		},
		ended: function (event) {
			$(this).jPlayer("play");
		},
		solution: "html,flash",
		supplied: "mp3",
		swfPath: "../js"
	});
	
	// Loading email
	$(".contact").html('<a href="mailto:info@sexygirljewelry.com">Email</a>');
	
	// Disabling menu
	$(".menu a, .logo a").click(function(){
		DisplayContent($(this).attr('href'));
		return false;
	});
});


	
function LoadSlider(page) {
	if(page=='/designs') {
		$("#slider").html('<img src="images/designs.jpg" width="365" height="550" alt="" />');
	} else if(page=='/partners') {
		$("#slider").html('<img src="images/parners.jpg" width="365" height="550" alt="" />');
	} else {
		if(!$("#slider").has("ul").length) {
			$("#slider").html('<ul><li><img src="images/slider1.jpg" width="365" height="550" alt="" /></li><li><img src="images/slider2.jpg" width="365" height="550" alt="" /></li><li><img src="images/slider3.jpg" width="365" height="550" alt="" /></li><li><img src="images/slider4.jpg" width="365" height="550" alt="" /></li></ul>');
		}
        
        // Slider
        $("#slider ul").cycle({
            fx: 'fade',
            pause: 0.4
        });
        
	$("#slideshow").css("overflow", "hidden");
	
	$("ul#slides").cycle({
		fx: 'fade',
		pause: 1,
		prev: '#prev',
		next: '#next'
	});
	
	$("#slideshow").hover(function() {
    	$("ul#nav").fadeIn();
  	},
  		function() {
    	$("ul#nav").fadeOut();
  	});
	}
} // function slider


function DisplayContent(page) {
    $.ajax({
        cache: false,
        url: "/.inc/load.php",
        data: ({'page' : page}),
        context: document.body,
        statusCode: {
            404: function() {
                alert('Page not found.');
            }
        },
        success: function(data){
            if(page=='/partners') {
                $("#content").addClass('content').html(data); // let's not fade this page at all because of older versions of IE :)
            } else {
                if($.browser.msie) {
                     $("#content").removeClass('content').html(data);
                } else {
                    $('#content').fadeTo('fast', 0, function() {
                        $("#content").removeClass('content');
                        $(this).html(data).fadeTo('fast', 1);
                    });
                }
            }
            
            LoadSlider(page);
            
            // Demonstration image
            if(page=='/designs' && $('.demo').length==0){
                $("#slider").parent().append("<div class=\"demo\"><img src=\"/images/demonstration.jpg\" width=\"240\" height=\"180\" alt=\"\" /></div>\n");
            } else if($('.demo').length) {
                $(".demo").remove();
            }
        }
    }); // ajax
} // Display Content
