
//Funktion zum Ändern des Status einer Checkbox
function checkbox_switcher(f){
  if (f.checked) {
     f.checked=false;
  }
  else
   f.checked=true;

}


function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }

var base_path = '';


var style_sheets = new Array(
	'/css/color_schemes/0.css',
	'/css/color_schemes/1.css',
	'/css/color_schemes/2.css',
	'/css/color_schemes/3.css',
	'/css/color_schemes/4.css'
);

function change_css(css_id)
{
	//CSS aendern
	var css_tag  = document.getElementById("color_style_tag");
	css_tag.href = base_path+style_sheets[css_id];
	
	//Klasse von Link auf 'cur_color' setzen
	var i = 0;
	var color_link = document.getElementById("color_switch").firstChild;
	while(color_link != null) {
		if(color_link.nodeName == "A") {
			if(i == css_id)
				color_link.setAttribute("id", "cur_color");
			else
				color_link.removeAttribute("id");
			
			i++;
		}
		
		color_link = color_link.nextSibling;
	}
	
	//Cookie setzen
	document.cookie = 'last_css='+css_id;
}


/*
 * Hintergrundfarbe beim Ueberfahren der Navi-Links im IE < 7
 */
function navi_bg_back(obj)
{
	obj.style.backgroundPosition = "0% 0px";
	obj.firstChild.style.backgroundPosition = "100% 0px";
	obj.style.cursor = 'pointer';
	obj.firstChild.style.color = '#ffffff';
}
function navi_bg(obj)
{
	obj.style.backgroundPosition = "0% -150px";
	obj.firstChild.style.backgroundPosition = "100% -150px";
	obj.style.cursor = 'hand';
	obj.firstChild.style.color = '#000000';
}

/*
 * Video-Navi Ueberfahren
 */

var was_current;
function video_navi_over(obj)
{
	var tmp = obj.src.split('/');
	if(tmp[tmp.length-1].indexOf('_off.jpg') == -1)
		was_current = true;
	else
		was_current = false;
	
	obj.src = obj.src.replace(/_off.jpg/g, '.jpg');
}

function video_navi_out(obj)
{
	if(!was_current)
		obj.src = obj.src.replace(/.jpg/g, '_off.jpg');
}

function video_navi_click()
{
	was_current = true;
}

/*
 * Newsletter-Bereich ausblenden
 */

function hide_newsletter_border()
{
	var obj = document.getElementById('newsletter');
	obj.style.borderTop = "0px";
}

var j_ = 8;
var j_pps = 1;
function hide_newsletter_end()
{
	var obj = document.getElementById('newsletter');
	
	obj.style.padding = j_+"px";
	
	if(j_ >= j_pps)
		j_ = j_ - j_pps;
	else
		j_ -= j_pps - (j_pps - j_);
	
	if(j_ > 0)
		window.setTimeout("hide_newsletter_end()", 50);
	else {
		obj.style.padding = "0px";
		window.setTimeout("hide_newsletter_border()", 50);
	}
}

var i_ = 31;
var i_pps = 3;
function hide_newsletter()
{
	var obj = document.getElementById('newsletter');
	
	obj.style.height = i_+"px";
	
	if(i_ >= i_pps)
		i_ = i_-i_pps;
	else
		i_ -= i_pps - (i_pps - i_);
	
	if(i_ > 0)
		window.setTimeout("hide_newsletter()", 30);
	else {
		obj.style.height = "0px";
		window.setTimeout("hide_newsletter_end()", 30);
	}
}


/* Video-Inhalt auf der Startseite aendern */
var cur_video = 4;
function change_video(wohin)
{
	//Nur auf der Startseite
	if(document.getElementById('video_content') == null)
		return false;

	//Content nachladen
	document.getElementById('video_content').removeChild(document.getElementById('video_content').firstChild);
	
	var player_div = document.createElement('div');
	player_div.setAttribute("id", "player");
	document.getElementById('video_content').appendChild(player_div);
	
	cur_video = wohin;	
	
	var so = new SWFObject(base_path+'/swf/flvplayer.swf','player','308','200','7');
	so.addParam("allowfullscreen","true");
	so.addVariable("file",base_path+"/swf/video."+cur_video+".flv");
	so.addVariable("image",base_path+"/0/images/video."+cur_video+".jpg");
	so.addVariable("logo",base_path+"/0/images/logo_webtv.png");
	so.addVariable("displayheight","200");
        so.addParam("wmode", "opaque");
	so.addVariable("autostart","false");
	so.addVariable("frontcolor","0xFFFFFF");
	so.addVariable("backcolor","0xFF007F");
	so.addVariable("screencolor","0xFFFFFF");
	so.write('player');


	/* Funktion aus ajax_content.js:
	 * -> Aendert rechts oben den Flash-Teaser in Produktanzeige, falls
	 *    nicht schon geladen */
	if(!init_state)
		change_flash_content(wohin);
	
	//navigation erneuern
	var menu = document.getElementById("video_nav").firstChild;
	while(menu != null) {
		if(menu.nodeName == "A" ) {
			var tmp = menu.firstChild.src.split('/');
			if(tmp[tmp.length-1].indexOf(wohin) == -1) {
				if(tmp[tmp.length-1].indexOf('_off.jpg') == -1)
					menu.firstChild.src = menu.firstChild.src.replace(/.jpg/g, "_off.jpg");
			} else 
				menu.firstChild.src = menu.firstChild.src.replace(/_off.jpg/g, ".jpg");
		}
		
		menu = menu.nextSibling;
	}
	
}


/*
 * Initialisieren - wird bei body:onload aufgerufen
 */

var init_state = true;
function init(base_path_)
{
	//Base-Path
	base_path = base_path_;
	
	//letztes stylesheet aus cookie holen und anwenden
	if(document.cookie) {
		var all_cookies = document.cookie.split(";");
		for(i = 0; i < all_cookies.length; i++) {
			var val = all_cookies[i].split("=");
			if(val[0] == "last_css")
				change_css(val[1]);
		}
	}

	//Startseiteninhalt laden
	//change_content('start');
	
	//Startvideo laden
	change_video(5);

	init_state = false;
}

function openPopUp(url,width,height){
	
	var nWindow = window.open(url,"PopUp","resizable=0,scrollbars=no,locationbar=no,width="+width+",height="+height);
	nWindow.focus(1);
	
}

