if(!window.SKIP_FLASH_NAVI) {
	// by Andy Weisner for RSK Group, Project : NISSAN Aftersales
	// created:  2008.12.16
	// last updated : 2008.12.16
	// embed flash Navigation using swfobject

	var flashvars = {};
	var attributes = {};
	var params = {wmode:"transparent",scale:"noscale"};
	swfobject.embedSWF("i/flash/DynamicNavigation.swf", "navigation", "100%", "100%", "7.0.0", false, flashvars, params, attributes);
	swfobject.embedSWF("i/flash/headbanner.swf", "hauptbild", "100%", "100%", "7.0.0", false, flashvars, params, attributes);
	//var naviIsClosed=true;
	
	
	// resize flash Navigation DIV layer height , shows hides Subnavigation to prevent flash subbnavigation blocking HTML links
	function toggleFlashNavigation(dir) {
		var naviDiv = document.getElementById('navigation');
		if(naviDiv && naviDiv.style) {
			if (dir=="OPEN")	{
	//			naviIsClosed=false;
				naviDiv.style.height="230px";
			} else if (dir=="CLOSE") {
	//			naviIsClosed=true;
				naviDiv.style.height="66px";
			}
		}
	}
}
function dealersearch(url) {
	return rsk.utils.popup(url, "Nissan Suche", "width=800,height=500,scrollbars=yes");
}

// --------------------- Real Scripts ;) -------------- //
window.rsk = window.rsk || {};
rsk.utils = rsk.utils || {};
rsk.utils.popup = function(url, windowname, params) {
	var win = window.open(url, windowname, params);
	if(win) {
		win.focus();
		return false;
	} else {
		return true;
	}
}
if(!String.prototype.insertAt) {
	String.prototype.insertAt = function(pos, insert) {
		return this.substring(0, pos) + insert + this.substring(pos);
	}
}
if(!String.prototype.insertAfterLast) {
	String.prototype.insertAfterLast = function(needle, insert) {
		var pos = this.lastIndexOf(needle);
		if(pos != -1) {
			return this.insertAt(pos, insert);
		} else {
			return this;
		}
	}

}
if(!String.prototype.getAfterLast) {
	String.prototype.getAfterLast = function(needle) {
		var pos = this.lastIndexOf(needle);
		if(pos != -1) {
			return this.substr(pos+1);
		} else {
			return "";
		}
	}
}

$(function(){
	$('.swapImg img').each(function(){
		var src = this.src;
		this.osrc = src.insertAfterLast(".", "-x");
		var img = new Image();
		img.src = this.osrc;
		$(this).hover(
			function() { this.asrc = this.src; this.src = this.osrc; },
			function() { this.src = this.asrc; }
		);
			
	});

	$('#NaviRechts > div').each(function(i){
		if(i==0) {
			$(this).show();
		} else {
			$(this).hide();
		}
	});
	$('#NaviRechts > a').click(function() {
		var refId = this.href.getAfterLast('#');
		$('#NaviRechts > div').each(function(){
			if(this.id == refId) {
				$(this).show('fast');
			} else {
				$(this).hide('fast');
			}
		});
		
	});
});
