// JavaScript Document

$(document).ready(function() {
						   
	var section = document.body.className;

//config sIFR
	if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac){
		sIFR.setup();
		sIFR.replaceElement("li.nolink", named({sFlashSrc: "interstate.swf", sColor: "#ffb300", sWmode: "transparent"}));
		sIFR.replaceElement("li.active", named({sFlashSrc: "interstate.swf", sColor: "#626272", sWmode: "transparent"}));
		sIFR.replaceElement("#leftColumn li", named({sFlashSrc: "interstate.swf", sColor: "#01adff", sHoverColor: "#626272", sWmode: "transparent"}));
		sIFR.replaceElement("h1, h2", named({sFlashSrc: "interstate.swf", sColor: "#626272", sWmode: "transparent"}));
		};

	//mouseover script using jQuery					   
$("#rightColumn #galnav img").mouseover(function(){
	if (this.src.indexOf("_active.gif") == -1){																		 		this.src = this.src.replace('.gif', '_over.gif');
	}
});

$("#rightColumn #galnav img").mouseout(function(){
	if (this.src.indexOf("_active.gif") == -1){
		this.src = this.src.replace('_over.gif', '.gif');
	}
});

$("#centreColumn #subnav img").mouseover(function(){
	if (this.src.indexOf("_active.gif") == -1){																		 		this.src = this.src.replace('.gif', '_over.gif');
	}
});

$("#centreColumn #subnav img").mouseout(function(){
	if (this.src.indexOf("_active.gif") == -1){
		this.src = this.src.replace('_over.gif', '.gif');
	}
});


$("#centreColumn #indeximg img").mouseover(function(){
	if (this.src.indexOf("_active.gif") == -1){																		 		this.src = this.src.replace('.gif', '_over.gif');
	}
});

$("#centreColumn #indeximg img").mouseout(function(){
	if (this.src.indexOf("_active.gif") == -1){
		this.src = this.src.replace('_over.gif', '.gif');
	}
});
// Slide Up and Down function for subnav
$("#subnavlabel img").click(function(){
	if ($("#subnav").is(":hidden")) {
		this.src = this.src.replace('rechts.gif','onder.gif');
		$("#subnav").slideDown(500);
	}	else {
		this.src = this.src.replace('onder.gif','rechts.gif');
		$("#subnav").hide();
	}
});

$("#subnavlabel h2").click(function(){
	if ($("#subnav").is(":hidden")) {
		$("subnavlabel img").src = $("subnavlabel img").src.replace('rechts.gif','onder.gif');
		$("#subnav").slideDown(500);
	}	else {
		$("subnavlabel img").src = $("subnavlabel img").src.replace('onder.gif','rechts.gif');
		$("#subnav").hide();
	}
});

//config jCarousel
if (section.indexOf('home') != -1) {
	    jQuery('#mycarousel').jcarousel({
       	itemVisible: 1,
		itemScroll: 1,
		autoScroll: 5,
		noButtons: true,
		wrap: true
    });
	}
	
if (section.indexOf('contact') != -1) {
	    jQuery('#mycarousel').jcarousel({
       	itemVisible: 1,
		itemScroll: 1,
		autoScroll: 4,
		noButtons: true,
		wrap: true
    });
	}

//positioning pointer, needs dimensions plugin (for offset function)
	var nav_pos = $('#leftColumn li#' + section).offset();
	$('img#pointer').css({top: nav_pos.top+6});
	
//mouseovers

//hide/show paragraph of portfolio AND switching from plusimage to minimage ande vice versa
	if (section.indexOf('portfolio') != -1) {
		$('div#subnav> div').hide(); 
		$('div#subnav> img#subnav-plus').click(function() {
			this.src = (this.src.indexOf('plus') == -1) ? 'images/p-plus.gif' : 'images/p-min.gif';
			$(this).next().slideToggle('fast');
		});
	}
});
