/*---------------------------------- global lang-select ----------------------------------------------*/

var mainURL = "http://www.raidsonic.de";
var langDe = mainURL;
var langEn = mainURL + "/en/home.php";
var langFr = mainURL + "/fr/home.php";

function switchLang(langKey) {
	switch (langKey) {
	case "De":
		document.location.replace(langDe);
		break;
	case "En":
		document.location.replace(langEn);
		break;
	case "Fr":
		document.location.replace(langFr);
		break;
	}
}

/*---------------------------------- global jQuery init ----------------------------------------------*/

jQuery().ready(function() {
	
	/*---------------------------------- start preload navi_img ------------------------------------*/
		
	var preImg = new Array('home', 'produkte', 'neuigkeiten', 'raidsonic', 'service', 'kontakt', 'login');
	var imgAll = new Array();
	
	for (y = 0; y < preImg.length; y++) {
		imgAll[y * 2] = new Image();
		imgAll[y * 2].src = navPath + preImg[y] + ".png";
		imgAll[y * 2 + 1] = new Image();
		imgAll[y * 2 + 1].src = navPath + preImg[y] + "_a.png";
	}

	/*---------------------------------- navi products accordeon ------------------------------------*/
	
	animatedcollapse.addDiv('lvl2_2_1', 'fade=0,speed=600,group=navimain,hide=1');
	animatedcollapse.addDiv('lvl2_2_2', 'fade=0,speed=600,group=navimain,hide=1');
	animatedcollapse.addDiv('lvl2_4_1', 'fade=0,speed=800,group=navimain,hide=1');
	//animatedcollapse.addDiv('lvl2_2_4', 'fade=0,speed=800,group=navimain,hide=1');
	//animatedcollapse.addDiv('lvl2_2_5', 'fade=0,speed=800,group=navimain,hide=1');
	//animatedcollapse.addDiv('lvl2_4_1', 'fade=0,speed=600,group=navimain,hide=1');
	//animatedcollapse.addDiv('lvl2_2_7', 'fade=0,speed=800,group=navimain,hide=1');
	//animatedcollapse.addDiv('lvl2_2_8', 'fade=0,speed=400,group=navimain,hide=1');
	//animatedcollapse.addDiv('lvl2_2_9', 'fade=0,speed=800,group=navimain,hide=1');
	
	/*---------------------------------- navi service accordeon ------------------------------------*/
	
	animatedcollapse.addDiv('lvl4_5_4', 'fade=0,speed=600,group=naviserv,hide=1');
	
	/*---------------------------------- productdetail accordeon ------------------------------------*/
	
	if ($('#allg').length > 0) {
		animatedcollapse.addDiv('allg', 'fade=1,speed=300,group=naviprodukt,hide=0');
		animatedcollapse.addDiv('pic', 'fade=1,speed=300,group=naviprodukt,hide=1');
		animatedcollapse.addDiv('be_az', 'fade=1,speed=300,group=naviprodukt,hide=1');
		animatedcollapse.addDiv('serv', 'fade=1,speed=300,group=naviprodukt,hide=1');
		animatedcollapse.addDiv('tec_log', 'fade=1,speed=300,group=naviprodukt,hide=1');
		
		animatedcollapse.addDiv('faq', 'fade=1,speed=300,group=naviservice_faq,hide=1');
		animatedcollapse.addDiv('treiber', 'fade=1,speed=300,group=naviservice_faq,hide=1');
		animatedcollapse.addDiv('support', 'fade=1,speed=300,group=naviservice_faq,hide=1');
		
		animatedcollapse.addDiv('action_pic1', 'fade=1,speed=300,group=navimain,hide=1');
		animatedcollapse.addDiv('action_pic1', 'fade=1,speed=300,group=naviprodukt,hide=1');
		animatedcollapse.addDiv('action_pic1', 'fade=1,speed=300,group=naviservice_faq,hide=1');
	}
	
	animatedcollapse.init();

	/*---------------------------------- home img-slide ------------------------------------*/
	
	if ($('#imgBoxHome').length > 0) {
		$('#imgBoxHome').cycle({
			fx:     'fade',
			speed:  500,
			timeout: 0,
			pager:  '#clickBoxHome',
			pagerAnchorBuilder: function(idx, slide) {
				return '<div style="float:left;"><a href="#"><img src="/de/gfx/home/trans_pic_week1.gif" width="50" height="50" border="0" /></a></div>';
			}
		});
	}

	/*---------------------------------- productdetail img-slide ------------------------------------*/
	
	if ($('#imgBox').length > 0) {
		$('#imgBox').cycle({
			fx:     'fade',
			speed:  500,
			timeout: 0,
			pager:  '#clickBox',
			pagerAnchorBuilder: function(idx, slide) {
				return '<div style="float:left;"><a href="#"><img src="/de/gfx/home/trans_pic_week1.gif" width="70" height="70" border="0" /></a></div>';
			}
		});
	}

	/*---------------------------------- productdetail lightbox ------------------------------------*/
	
	if ($('a.lBox').length > 0) {
		$('a.lBox').colorbox({
			transition: 'elastic', 
			speed: 300, 
			opacity: 0.7
		});
	}
	if ($('a.lBox3d').length > 0) {
		$('a.lBox3d').colorbox({
			inline: true,
			href:"#3danimated",
			transition: 'elastic', 
			speed: 300, 
			opacity: 0.7
		});
	}
	if ($('a.lBoxMov').length > 0) {
		$('a.lBoxMov').colorbox({
			inline: true,
			href:"#youtubemov",
			transition: 'elastic', 
			speed: 300, 
			opacity: 0.7
		});
	}
	
	/*---------------------------------- topnavi img-hover ------------------------------------*/
	
	//var imgID = $("#home").attr("id");
	$(".naviTop").hover( 
		function () {
			$(this).attr("src", navPath + $(this).attr("name") + "_a.png");
		}, 
		function () {
			$(this).attr("src", navPath + $(this).attr("name") + ".png");
		}
	);
	
	/*---------------------------------- leftnavi img-hover ------------------------------------*/
	
	$(".naviLeft").hover( 
		function () {
			$(this).attr("background", "/de/gfx/navi_left/bg_but_aktiv.gif");
		}, 
		function () {
			$(this).attr("background", "/de/gfx/navi_left/bg_but.gif");
		}
	);
	
	/* rollover img missing
	$(".naviLeftSub").hover( 
		function () {
			$(this).attr("background", "/de/gfx/navi_left/bg_but_aktiv.gif");
		}, 
		function () {
			$(this).attr("background", "/de/gfx/navi_left/bg_but.gif");
		}
	);
	*/
	
	/*---------------------------------- content-tabs img-hover ------------------------------------*/
	
	// e.g. Company, ...
	var hoverOn = function() {
		$(this).attr("src", $(this).attr("name") + "_a.png");
	};
	var hoverOff = function() {
		$(this).attr("src", $(this).attr("name") + ".png");
	};
	
	/* 1st level*/
	var clickOn = function () {
		$('.tabImgHover').each(hoverOff).bind('mouseleave', hoverOff);
		$(this).attr("src", $(this).attr("name") + "_a.png").unbind('mouseleave', hoverOff);
	};
	$('.tabImgHover').bind('mouseenter', hoverOn);
	$('.tabImgHover').bind('mouseleave', hoverOff);
	$('.tabImgHover').bind('click', clickOn);
	$('.tabImgHover:first').trigger('click');
	
	/* 2nd level*/
	var l2clickOn = function () {
		$('.l2tabImgHover').each(hoverOff).bind('mouseleave', hoverOff);
		$(this).attr("src", $(this).attr("name") + "_a.png").unbind('mouseleave', hoverOff);
	};
	$('.l2tabImgHover').bind('mouseenter', hoverOn);
	$('.l2tabImgHover').bind('mouseleave', hoverOff);
	$('.l2tabImgHover').bind('click', l2clickOn);
	$('.l2tabImgHover:first').trigger('click');
	
	// Productdetail
	var hover2On = function() {
		$(this).attr("src", $(this).attr("name") + "_a.gif");
	};
	var hover2Off = function() {
		$(this).attr("src", $(this).attr("name") + "_n.gif");
	};
	var click2On = function () {
		$('.tab2ImgHover').each(hover2Off).bind('mouseleave', hover2Off);
		$(this).attr("src", $(this).attr("name") + "_a.gif").unbind('mouseleave', hover2Off);
	};
	$('.tab2ImgHover').bind('mouseenter', hover2On);
	$('.tab2ImgHover').bind('mouseleave', hover2Off);
	$('.tab2ImgHover').bind('click', click2On);
	$('.tab2ImgHover:first').trigger('click');


});

/*---------------------------------- win open ----------------------------------------------*/

function newWin() {
	var anfahrtWin = window.open("/mo/pages/unter/anfahrt.html","lageplan","width=435,height=286,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no")
}

/*---------------------------------- navi left dropdown ----------------------------------------------*/

function switchDis(div) {
	aktState = document.getElementById(div).style.display;
	document.getElementById(div).style.display = (aktState == 'inline') ? 'none' : 'inline';
}

/*---------------------------------- navi left dropdown ----------------------------------------------*/

function setEmo(imgSrc) {
	$(".emote").attr("background", '/de/gfx/emotes/'+imgSrc);
}

/*---------------------------------- dw scripts ----------------------------------------------*/

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

