jQuery(document).ready(function() {
	jQuery('span.LEMSpan').mouseover(function(){this.style.display='inline';});
	jQuery('span.LEMSpan').mouseover(function(){this.style.background='#F5B800';});
	jQuery('span.LEMSpan').mouseover(function(){this.style.border='0px';});
	jQuery('span.LEMSpan').mouseover(function(){this.style.float='left!important';});
	jQuery('span.LEMSpan').mouseover(function(){this.style.overflow='hidden';});
	
	jQuery('#mycarousel, #mycarousel1').jcarousel();
	if (jQuery("select").length > 0) {
		jQuery("#Navigation>li>ul").bgiframe({ opacity: false, src: '' });
	}
});

jQuery(document).ready(function() {
	jQuery("#linkNaviMenu>li>ul").hide();
	jQuery("#linkNaviMenu>li").hover(
		function() {
			jQuery(this).find(">ul").stop().height('auto').slideDown("fast");
		},
		function() {
			jQuery(this).find(">ul").stop().slideUp("fast");
		}
	);
});

/* Correct hspace and vspace assigned by hybris wysiwyg editor */
jQuery(document).ready(function() {
	jQuery("img[hspace]").each(function() {
		var hspace = jQuery(this).attr("hspace");
		jQuery(this).css("margin-left", hspace + "px");
		jQuery(this).css("margin-right", hspace + "px");
	});

	jQuery("img[hspace]").each(function() {
		var vspace = jQuery(this).attr("vspace");
		jQuery(this).css("margin-top", vspace + "px");
		jQuery(this).css("margin-bottom", vspace + "px");
	});
});

jQuery(document).ready(function() {
	jQuery("#destination").scrollTo(0);

	if (!jQuery.browser.msie) {
		jQuery("#destination").mouseleave(function() {
			jQuery("#destination").scrollTo(0);
		});
	}
});

jQuery(document).ready(function() {
	jQuery("#destination>li>a").attr("href", function() {
		return this + window.location.search;
	});
});

function openDivAsFacebox(faceboxDiv) {
	jQuery.facebox({ div: "#"+faceboxDiv });
}

jQuery(document).ready(function() {
	var counter = 0;
	jQuery("a[rel='gigasetMovieLink']").each(function() {
		counter++;
		
		var href = jQuery(this).attr("href");
		var parts = href.split("|");

		var movie = escape(parts[0]);
		var width = escape(parts[1]);
		var height = escape(parts[2]);
		var link = escape(parts[3]);
		

		
		
		buildOverlayForFlash(movie, width, height, link, counter, this );
		
	});
	
	
	

	if (jQuery("a[rel='gigasetMovieLink']").size() > 0) {
		jQuery(document).bind('close.facebox', function() {
			jQuery.unblockUI();
		});
		jQuery(document).bind('loading.facebox', function() {
			jQuery.blockUI({ message: null });
		});
	}
});

jQuery(document).ready(function() {
	var counter = 0;
	jQuery("a[rel='gigasetLotteryLink']").each(function() {
		counter++;
		
		var href = jQuery(this).attr("href");
		var parts = href.split("=");

		var lottery = escape(parts[1]);

		jQuery(this).removeAttr("href");
		jQuery(this).attr("rev", "lottery" + counter);
		jQuery(this).attr("id", "lotterylink" + counter);

		var iframeLink = lotteryLink + "?";
		iframeLink = iframeLink + "lottery=" + lottery;

		jQuery("#lotteryPlaceholder").append(
				'<div id="lotteryPopup' + counter + '" style="display:none;">'
				+ '<iframe id="lotteryIframe' + counter + '" name="lotteryIframe' + 
						counter + '" scrolling="no" height="871" width="553" frameborder="0" marginwidth="0" marginheight="0" src="' + iframeLink + '">'
				+ '</iframe>'
				+ '</div>'
			);

		jQuery("#lotterylink" + counter).click(function() {
			var lotteryId = jQuery(this).attr("rev").substring("lottery".length);
			openDivAsFacebox('lotteryPopup' + lotteryId);
			jQuery(document).bind('close.facebox', function() {
				window.frames["lotteryIframe" + lotteryId].removeFlash();
			});
		});
	});

	if (jQuery("a[rel='gigasetLotteryLink']").size() > 0) {
		jQuery(document).bind('close.facebox', function() {
			jQuery.unblockUI();
		});
		jQuery(document).bind('loading.facebox', function() {
			jQuery.blockUI({ message: null });
		});
	}
});


jQuery(".blockUI").live('click', function() {
	jQuery(document).trigger('close.facebox');
});


// checks if flash is enabled
function checkFlashPlugin() {
	if (jQuery.browser.flash) {
		return true;
	}
	else { 
		return false;
	}
}

// checks for the H264 codec
function checkH264Plugin() {
	if (Modernizr.video) {
	  if (Modernizr.video.h264) {
	    return true
	  } 
	  else {
	    return false;
	  }
	}
	else {
	 return false;
	}
}

function getPageWidth(){
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    // Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    // IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    // IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

// Arques Charts
function gsAgChartsNewWindow(par) {
	MeinFenster =window.open(par,"Zweitfenster","width=350,height=214,left=320,top=0");
	MeinFenster.focus();
}


function buildOverlayForFlash(movie, width, height, link, counter, object ){
		
	jQuery(object).removeAttr("href");
	jQuery(object).attr("rev", "movie" + counter);
	jQuery(object).attr("id", "movieLink" + counter);

	if (swfobject.hasFlashPlayerVersion(flashVersion) || jQuery("#flashAlternativeContent").length == 0) {
		var iframeLink = flashLink + "?";
		iframeLink = iframeLink + "file=" + movie + "&width=" + width + "&height=" + height;
		
		if (link.length > 0) {
			iframeLink = iframeLink	+ "&link=" + link;
			};
		
		jQuery("#flashPlaceholder").append(
				'<div id="flashPopup' + counter + '" style="display:none;">'
				+ '<iframe id="flashIframe' + counter + '" name="flashIframe' + counter + '" scrolling="no" height="' + height + '" width="' + width + '" frameborder="0" marginwidth="0" marginheight="0" src="' + iframeLink + '">'
				+ '</iframe>'
				+ '</div>'
			);

		jQuery("#movieLink" + counter).click(function() {
			var movieId = jQuery(object).attr("rev").substring("movie".length);
			openDivAsFacebox('flashPopup' + movieId);
			jQuery(document).bind('close.facebox', function() {
				window.frames["flashIframe" + movieId].removeFlash();
			});
		});
	}
	else {
		jQuery("#movieLink" + counter).click(function() {
			openDivAsFacebox('flashAlternativeContent');
		});
	}
	
	
	
}





