/* general scripts */

// globale variablen
var navAct;
var contentNavAct;
var selfUrl=document.location.href;


var flashvars = {};
var params = {quality: "high",allowFullScreen: "true",bgcolor: "#000000",wmode: "transparent",allowScriptAccess: "sameDomain"};
var attributes = {};

//jquery onReady
jQuery.noConflict();
jQuery(document).ready(function() {

	initNavImages();

	var ido6 = navigator.appVersion.indexOf('MSIE 6.0');
	if(ido6!=-1){ie6=true;}else{ie6=false;}
	
	if(ie6)jQuery('div.panel,#navigation,#content_navigation,#content_navigation_news,#content_navigation_final,.image_slice,.technews').pngFix();

	jQuery('.languageList').hide();	
	
	jQuery('#navigation li').hover( function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		if(!ie6){
			jQuery('#navimg'+id).attr('src',eval('nav'+id+'on.src'));
		}else{
			document.getElementById('navimg'+id).filters(0).src=eval('nav'+id+'on.src');
		}
	}, 
	function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		if(!ie6){
			if(id!=navAct)jQuery('#navimg'+id).attr('src',eval('nav'+id+'off.src'));
		}else{
			if(id!=navAct)document.getElementById('navimg'+id).filters(0).src=eval('nav'+id+'off.src');
		}
	});
	
	
	jQuery('#content_navigation li').hover( function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
	}, 
	function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
	});
	
	jQuery('#content_navigation li').click( function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		showContentLayer(id);
		contentNavAct=id;
	});
	
	
	
	
	jQuery('#content_navigation_news li').hover( function () {
		jQuery(this).attr('class','act');
	}, 
	function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		if(id!=contentNavAct)jQuery(this).attr('class','inact');
	});
	
	jQuery('#content_navigation_news li').click( function () {
		jQuery('#content_navigation_news li').attr('class','inact');
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		jQuery(this).attr('class','act');
		showNewsLayer(id);
		/* contentNavAct=id; */
		
		//Toggle Flash
		if(typeof onNav != 'undefined'){
			onNav(id);
		}
		
		/** hide glossary when selecting another news article via the navigation ***/
		if(jQuery("#glossaryContentSlider").is(":visible")){
			gid = -1;
			hideGlossary();
		}
	});
	
	jQuery(".modal").click( function () {
		var flash_src = jQuery(this).attr('flashsrc');
		var fb_src = jQuery(this).attr('fallbacksrc');
		
		var flash_width = jQuery(this).attr('flashwidth');
		var flash_height = jQuery(this).attr('flashheight');

		// CHANGE!
		var objSerialParams = jQuery(this).attr('flashparams');
		eval("var flash_params =" + objSerialParams);				
		var objSerial = jQuery(this).attr('flashvars');
		eval("var flash_vars =" + objSerial);		
		
		jQuery("#flash_content").html('<img src="'+fb_src+'">');

		var xxx = swfobject.embedSWF(flash_src, "flash_content", flash_width, flash_height, "9.0.45", false, flash_vars, flash_params, attributes);
		
		jQuery("#modal_bg").show();
		jQuery("#modal_content").show();
		jQuery("#modal_content_bg").show();
		jQuery("#modal_content_close").show();
	});
	
	jQuery("a[rel^=movieScreen_]").live("click",function(){
		var movieScreenId = jQuery(this).attr("rel").replace("movieScreen_","");
		
		var selector = "a[rel^=movieScreen_%]";
			selector = selector.replace("%", movieScreenId);
		
		showMovieScreen(selector);
		
		return false;
	});
	
	jQuery(".movieScreenBg, .close_movieScreen").live("click", function(){
		jQuery(".movieScreenBg table").attr("border","1");
		
		var movieScreenNumber = -1;
		
		if(jQuery.browser.msie){
			var movieScreenId = jQuery("#movieScreenIE").attr("class");
			movieScreenNumber = movieScreenId.replace("movieScreen_","");
			
			jQuery("#movieScreenIE").empty().html("<div id=\"movieContentIE\"></div>").hide();	
		}else{
			var movieScreenId = jQuery(".movieScreen:visible").attr("id");
			movieScreenNumber = movieScreenId.replace("movieScreen_","");
			
			jQuery(".movieScreen").hide();
		}
		jQuery("#stage_content.hasFlashBg #inner_content").css("z-index","50");
		
		jQuery("#flash_bg, #flash_bg_content").show();
		jQuery("#techno_"+movieScreenNumber).find(".ic_img, .jScrollPaneContainer, .#ToshibaHDDRHeadlines, .ic_headlines").fadeIn(1000);
		
		jQuery("a.close_movieScreen").hide();
		jQuery(".movieScreenBg").hide().removeClass("movieScreenBg");
	});
	
	
	jQuery('#content_navigation_final li').hover( function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		jQuery(this).attr('class','act');
		onNav(''+id, 'show');
		
	}, 
	function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		if(id!=contentNavAct)jQuery(this).attr('class','inact');
		onNav(''+id, 'hide');
		
	});
	
	
	jQuery("#content_navigation_final li").click( function () {
		jQuery('#content_navigation_final li').attr('class','inact');
		jQuery(this).attr('class','act');
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		contentNavAct=id;
		showHddLayer(id);
		
		/** hide glossary when opening a layer via the navigation ***/
		if(jQuery("#glossaryContentSlider").is(":visible")){
			gid = -1;
			hideGlossary();
		}
	});
	
	
	jQuery('.ic_img_slice a').hover( function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		jQuery('#content_navigation_final li#cn'+id).attr('class','act');
		
	}, 
	function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		if(id!=contentNavAct)jQuery('#content_navigation_final li#cn'+id).attr('class','inact');
	});
	
	jQuery(".ic_img_slice a").click( function () {
		var id = jQuery(this).attr("id");
		id = parseInt(id.substring(id.length - 1));
		contentNavAct=id;
		jQuery('#content_navigation_final li#cn'+id).attr('class','act');
		showHddLayer(id);
	});
	

	var gid;
	jQuery(".ic_glossary .ic_tagcloud a").hover(
	  function () {
	   	jQuery(this).css('color','#734e9f');
	  }, 
	  function () {
	  	var id = jQuery(this).attr("id");
		id = parseInt(id.split('_')[1]);
	    if(id!=gid)jQuery(this).css('color','#ffffff');
	  }
	);	
	
	jQuery(".ic_glossary .ic_tagcloud a").click(function() {
	
		if(!jQuery('#glossaryContentSlider').is(':animated')){/** START no content change while animated ***/		
	
			var id = jQuery(this).attr("id");
			id = parseInt(id.split('_')[1]);
	
			var isgidset = gid >= 0;
			
			gid=id;
			jQuery(".ic_glossary .ic_tagcloud a").css('color','#ffffff');
			jQuery(this).css('color','#734e9f');
				
			/*if(ie6){
				jQuery('#hddLayer'+hdAct).hide();
				jQuery('.modal_content_close_hdd').hide();
			}*/
			
			var id = jQuery(this).attr("id");
			id = parseInt(id.split('_')[1]);
			var innerDivHead = jQuery('#desc_'+id+' .glossary_head').html();
			var innerDivContent = jQuery('#desc_'+id+' .glossary_text').html();
			
			jQuery('#glossaryHeadline').html(innerDivHead);
			innerDivContent = '<div style="width:430px;padding:10px;">'+innerDivContent+'</div>';
			
			
			
			jQuery('#glossaryContent').css('zIndex','1');
					
			jQuery('#scrollpane_glossary').html(innerDivContent);
			
			jQuery('#glossaryContentSlider').css('visibility','hidden');
			jQuery('#glossaryContentSlider').css('display','block');
			jQuery('#scrollpane_glossary').jScrollPane({showArrows:true});
			jQuery('#glossaryContentSlider').css('display','none');
			jQuery('#glossaryContentSlider').css('visibility','visible');
				
			
			jQuery('#glossaryContent').css('zIndex','80');
			
			
			if (isgidset)
			{			
				jQuery('#glossaryContentSlider').show();
			}
			else
			{	
					jQuery('#glossaryContentSlider').animate({
						width: 'show'
					}, 1000, 'linear');
			}
		
		}/** END no content change while animated ***/
		
	});


	jQuery("a#close").click(function() {
		gid = -1;			
		/** EDIT: close now uses the hide glossary function which contains the "old" hide code ***/	
		hideGlossary();
	});
	
		
	jQuery("a#closeX").click(function() {
		jQuery('#glossaryContentSlider').animate({
			width: 'hide'
		}, 0);
		jQuery('#glossaryContent').css('zIndex','0');
	});
	jQuery("a#closeX").click();
	jQuery('#glossaryContentSlider').css('visibility','visible');
	
	jQuery("div.panel:last").css('width','234px');
	jQuery("a").focus( function () {
		jQuery(this).blur();
	});
	
	
/*** language selector **/
	jQuery(".languageSelector > a, .languageSelector .languageList").hover(
		function(){
			jQuery(".languageSelector .languageList").show();
		},
		function(){
			jQuery(".languageSelector .languageList").hide();
		}
	);
	
	/*jQuery(".languageSelector .languageList a").live("click",function(){
		//delete cookie
		document.cookie = "hddlocale="+lang+"; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
	
		var lang = jQuery(this).attr("class");
		var expirationDate = new Date();
			expirationDate.setDate(expirationDate.getDate() + 365);
		document.cookie = "hddlocale="+lang+"; path=/; expires="+expirationDate.toGMTString();
	});*/
/*** /language selector **/	
});
/*** END domready **/






function showMovieScreen(jQuerySelector){

	var movieScreenId = jQuery(jQuerySelector).attr("rel");
	var movieScreenNumber = movieScreenId.replace("movieScreen_","");
	
	jQuery("#modal_bg table").attr("border","0");
	jQuery("#modal_bg").addClass("movieScreenBg").show();
	jQuery("#stage_content.hasFlashBg #inner_content").css("z-index","501");
	
	
	var flashPlayer = eval("flashPlayer"+movieScreenNumber);
	
	var flashWidth = eval("flashWidth"+movieScreenNumber);
	var flashHeight = eval("flashHeight"+movieScreenNumber);
	
	var flashVars = eval("flashVars"+movieScreenNumber);
	var flashParams = eval("flashParams"+movieScreenNumber);
	var flashAttributes = eval("flashAttributes"+movieScreenNumber);
			
	jQuery("#"+movieScreenId).show();
	var offset = jQuery("#"+movieScreenId).offset();
	
	if(jQuery.browser.msie){
		jQuery("#movieScreenIE").css({"left": offset.left,"top": offset.top}).attr("class",movieScreenId);			
		
		jQuery("#"+movieScreenId).hide();
		jQuery("#movieScreenIE").addClass(movieScreenId).show();
		
		var movie = swfobject.embedSWF(flashPlayer, "movieContentIE", flashWidth, flashHeight, "9.0.45", false, flashVars, flashParams, flashAttributes);
	}
	else{
		var movie = swfobject.embedSWF(flashPlayer, "movieContent_"+movieScreenNumber, flashWidth, flashHeight, "9.0.45", false, flashVars, flashParams, flashAttributes);
	}
	
	var closeButtonPos = (parseInt(offset.left) + flashWidth) - 19;
	jQuery("a.close_movieScreen").show();//.css({"top":"5px","left":closeButtonPos+"px"})
	
	
	jQuery("#flash_bg, #flash_bg_content").hide();
	jQuery("#techno_"+movieScreenNumber).find(".ic_img, .jScrollPaneContainer, .#ToshibaHDDRHeadlines, .ic_headlines").hide();
	
	return false;
}

	
function changeContentToId(id){
	jQuery('#content_navigation_news li').attr('class','inact');
	jQuery('#content_navigation_news li#cn'+id).attr("class","act");
	showNewsLayer(id);
}


//technologies contentLayer
var id="0";

function showContentLayer(id){
	jQuery('.technodiv').hide();
	if((id=="null")&&(location.search)){
		id=location.search.split('cl=')[1];
	}else if(id=="null"){
		id=0;
	}
	contentNavAct=id;
	jQuery('#techno_'+id).show();
 	jQuery('#content_navigation li#cn'+id).attr('class','act');
	jQuery('#scrollpane'+id).jScrollPane({showArrows:true});
	
	if(ie6)jQuery('#techno_'+id+' .ic_headlines,#techno_'+id+' .ic_img').pngFix();
}

function showNewsLayer(id){
	jQuery('.technodiv:visible').hide();//.fadeOut(500);
	if((id=="null")&&(location.search)){
		id=location.search.split('cl=')[1];
	}else if(id=="null"){
		id=0;
	}
	contentNavAct=id;
	jQuery('#techno_'+id).fadeIn(2000);//.show();
	jQuery('#content_navigation_news li#cn'+id).attr('class','act');
	jQuery('#scrollpane'+id).jScrollPane({showArrows:true});
	if(ie6)jQuery('#techno_'+id+' .ic_headlines,#techno_'+id+' .ic_img').pngFix();
}

function closeModal(){
	swfobject.removeSWF("flash_content");
	jQuery("#modal_content").append('<div id="flash_content"></div>');
	jQuery("#modal_bg").hide();
	jQuery("#modal_content").hide();
	jQuery("#modal_content_bg").hide();
	jQuery("#modal_content_close").hide();
}

var hdAct;
function showHddLayer(id){
	jQuery(".hddLayer").hide();
	jQuery("#hddLayer"+id).show();
	jQuery("#hddLayer"+id+" .hdd_scrollable").jScrollPane({showArrows:true});
	jQuery(".modal_content_close_hdd").show();
	hdAct=id;
}

function hideHddLayer(){
	jQuery(".hddLayer").hide();
	jQuery(".modal_content_close_hdd").hide();
	contentNavAct="999";
	jQuery('#content_navigation_final li').attr('class','inact');
	hdAct = -1;
}


function doPngFix(){
	var ido6 = navigator.appVersion.indexOf('MSIE 6.0');
	if(ido6!=-1){ie6=true;}else{ie6=false;}
	
	if(ie6)jQuery('.ie6pngfix').pngFix();
	if(ie6){
		jQuery("#arrLeft").click( function(){
			stepcarousel.stepBy('image_gallery',-1);
		});
		jQuery("#arrRight").click( function(){
			stepcarousel.stepBy('image_gallery',1);
		});
	}
}

/*EDIT: hide glossary function containing the former close button function*/
function hideGlossary(){
	jQuery('#glossaryContentSlider').animate({
			width: 'hide'
		}, 1000, 'linear', function() {
		  jQuery(".ic_glossary .ic_tagcloud a").css('color','#ffffff');
		  jQuery('#glossaryContent').css('zIndex','0');
		/*if((ie6)&&(hdAct!=999)&&(hdAct>=0)){
		  	jQuery('#hddLayer'+hdAct).show();
			jQuery('.modal_content_close_hdd').show();
		}*/
	});
}



