$(document).ready(function(){	

// cu3er script
	var flashvars = {};
	flashvars.xml = base_url+"media/config.xml";
	flashvars.font = "font.swf";
	var attributes = {};
	attributes.wmode = "transparent";
	attributes.id = "slider";
	swfobject.embedSWF(base_url+"media/cu3er.swf", "main-slider", "960", "430", "9", base_url+"js/swfobject/expressInstall.swf", flashvars, attributes);

// gallery home
	$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 8000, true);
	$("#featured02 > ul").tabs({fx:{opacity: "toggle"}});

//treeview
	$("#navigation").treeview({
		animated: "fast",
		persist: "location",
		collapsed: true,
		unique: true
	});	
	
// accordion sidebar	
	//$(".accordion div").eq(0).addClass("active");
	//$(".accordion ul").eq(0).show();
	
	
	
	if($(".accordion div").eq(0).hasClass('active')){
		$(".accordion ul").eq(0).show();
	}
	
	if($(".accordion div").eq(1).hasClass('active')){
		$(".accordion ul").eq(1).show();
	}
	
	if($(".accordion div").eq(2).hasClass('active')){
		$(".accordion ul").eq(2).show();
	}

	$(".accordion div").click(function(){
		$(this).next("ul").slideToggle("slow")
		.siblings("ul:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("div").removeClass("active");
	});

// accordion faq
	$(".accordion02 h3").eq(0).addClass("active");
	$(".accordion02 .accor-inside").eq(0).show();

	$(".accordion02 h3").click(function(){
		$(this).next(".accor-inside").slideToggle("slow")
		.siblings(".accor-inside:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});

// accordion type
	$(".accordion03 h4").eq(0).addClass("active");
	$(".accordion03 .accorspec").eq(0).show();

	$(".accordion03 h4").click(function(){
		$(this).next(".accorspec").slideToggle("slow")
		.siblings(".accorspec:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h4").removeClass("active");
	});

/*
// tab-content
	$('#mask').css({'height':$('#panel-1').height()});	
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));
	$('#panel div').width($('#mask').width());
	
	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {
		var panelheight = $($(this).attr('href')).height();
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');
		
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		$('#mask').scrollTo($(this).attr('href'), 800);	
		return false;
	});					   
*/	
//select form	
	$('.confirmation li').click(function(){
		$(this).toggleClass("active");
		$(this).siblings('.confirmation li').removeClass("active");
	}).mouseover(function() {
		$(this).css('backgroundColor','#222');
	}).mouseout(function() {
		$(this).css('backgroundColor','');	
	});

//color box
	$("a[rel='example4']").colorbox({slideshow:true, transition:"fade"});

//paging
	$("#news-paging").quickPager({pageSize: 5});
	$("#gallery-page").quickPager({pageSize: 5});
	$("#type-paging").quickPager({pageSize: 5});
	$("#thumb").quickPager({pageSize: 16});
		
//overlay
	$(".overlay").fadeTo("slow", 0.8); // This sets the opacity of the thumbs to fade down to 30% when the page loads
    $(".overlay").hover(function(){
    $(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
    },function(){
    $(this).fadeTo("slow", 0.8); // This should set the opacity back to 30% on mouseout
    });
	
// form validasi
	var validator = $("#form-kontak").livequery(function(){
		$(this).validate({
		event: "blur",
		rules: {
			company: "required",
			name: "required",
			address: "required",
			city: "required",
			email: {
				required: true,
				email: true
			},			
			phone: "required",			
			message: "required"
		},
		messages: {
			company: "Please insert your company",
			name: "Please insert your name",
			address: "Please insert your address",
			city: "Please insert your city",
			email: "Please insert your email",				
			phone: "Please insert your phone number",
			message: "Please insert your message"							
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent());
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function(form) {
			$("#result").hide();
			jQuery(form).ajaxSubmit({
				target: "#result",
				clearForm:true,
				success: function() {
					$("html:not(:animated),body:not(:animated)").animate({ scrollTop: 0}, 1000, function() {
						$("#result").show("normal");
						  $("#result").fadeTo(2000,1,function(){
   						 		$(this).fadeOut("slow");
  							});
					});					
				}
			});
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});
	});

});
