jQuery(function($){

	var host = window.location.host;
	var basePath = "http://" + host + "/";
	var actualPage = window.location.href;
	var browserVersion  = jQuery.browser.version;
	var questionmark = actualPage.match(/\?/);
	if(questionmark == "?"){
		var qAnd = "&";
	} else {
		var qAnd = "?";
	}
	var languageLx = actualPage.match(/L=.?/g);
	if(languageLx){
		var languageLx = languageLx.reverse();
	} else {
		var languageLx = "";
	}
	// Remove dotted box when link is clicked:
	$('a').focus(function() {
		$('a').blur();
	});

	$("#header .logo").click(function(){
		window.location.href = basePath + "?" + languageLx;
	});

//	valueSearch = $("#page-100 .px_label_header").is(".value_search");
	valueSearch = $("#page-100 .px_label_header .value_search, #page-142 .px_label_header .value_search").text();
	if(valueSearch){
		$("#leftnav li.page100").attr("class","page100");
		$("#leftnav li.page142").attr("class","page142");
	}
//alert(valueSearch);
//alert(browserVersion);

	//for png-images in ie6
//	$('#content').supersleight();
//	$('#content').supersleight({shim: 'x.gif'});


	$("#page-100 .mediaList>li:odd, #page-142 .mediaList>li:odd").css({"float":"right"});
	$("#page-100 .mediaList>li:even, #page-142 .mediaList>li:even").css({"clear":"both"});

/*
	if(browserVersion == "7.0"){
		$("#page-100 .mediaList>li:even").css({"float":"right"});
		$("#page-100 .mediaList>li:odd").css({"float":"left"});

	}
*/

//	$(".pxSingleView .tx-proxsysext-pi3-right").append($(".pxSingleView .button_back"));


	//Blu-base
	$("#page-105 li.current:has(a.page105a)").css({"background":"none"});
	$("#page-100 li.current:has(a.page127a)").css({"background":"none"});

	//Casting base
	$("#page-136 li.current:has(a.page136a)").css({"background":"none"});
	$("#page-142 li.current:has(a.page137a)").css({"background":"none"});
	//Castingbase: Change position of item titles
	$("#page-142 .tx-proxsysext-pi3-item").each(function(){
		$(this).find(".mediafiles_filename").insertAfter($(this).find("#firstInfos"));
	});

	var isProxsysLanguage = $("*").is("meta[name=PROXSYS_LANGUAGE]");
//	var isProxsysLanguage = $("head meta[name=PROXSYS_LANGUAGE]").is();
	if(isProxsysLanguage){
		var proxsysLanguage = document.getElementsByName('PROXSYS_LANGUAGE')[0].content;
		if (proxsysLanguage == 'de') {
			var text_create_new_folder = 'Neuen Ordner anlegen';
			var text_enter_search_phrase = 'Suchbegriff eingeben';
		}
		else {
			var text_create_new_folder = 'Create new folder';
			var text_enter_search_phrase = 'Enter search term';
		}
		// Search + Create Folder: Insert introduction message into input fields:
		$("input.px_newFolder_inputName").attr("value",text_create_new_folder);
		$(".px_pi2_searchForm input.searchPhrase").attr("value",text_enter_search_phrase);
		// Search + Create Folder: Remove introduction message from input fields:
		$("input.px_newFolder_inputName, .px_pi2_searchForm input.searchPhrase").click(function(){
			$(this).attr("value","");
		});
	}


	// Product tabs in the start page.
	$("#page-49 #col3_content .tabs3 .top .tab1").click(function(){
		$("#page-49 #col3_content .tabs3 .top").css({
			"background-position": "0% 0%"
		});
		$("#page-49 #col3_content .tabs3 .text1, #page-49 #col3_content .tabs3 .bottom2").css({
			"display": "block"
		});
		$("#page-49 #col3_content .tabs3 .text2, #page-49 #col3_content .tabs3 .text3").css({
			"display": "none"
		});
		$("#page-49 #col3_content .tabs3 .bottom1 a").attr("href", basePath + "index.php?id=86&" + languageLx);
	});
	$("#page-49 #col3_content .tabs3 .top .tab2").click(function(){
		$("#page-49 #col3_content .tabs3 .top").css({
			"background-position": "0% 50%"
		});
		$("#page-49 #col3_content .tabs3 .text2").css({
			"display": "block"
		});
		$("#page-49 #col3_content .tabs3 .text1, #page-49 #col3_content .tabs3 .text3, #page-49 #col3_content .tabs3 .bottom2").css({
			"display": "none"
		});
		$("#page-49 #col3_content .tabs3 .bottom1 a").attr("href", basePath + "index.php?id=87&" + languageLx);
	});
	$("#page-49 #col3_content .tabs3 .top .tab3").click(function(){
		$("#page-49 #col3_content .tabs3 .top").css({
			"background-position": "0% 100%"
		});
		$("#page-49 #col3_content .tabs3 .text3").css({
			"display": "block"
		});
		$("#page-49 #col3_content .tabs3 .text1, #page-49 #col3_content .tabs3 .text2, #page-49 #col3_content .tabs3 .bottom2").css({
			"display": "none"
		});
		$("#page-49 #col3_content .tabs3 .bottom1 a").attr("href", basePath + "index.php?id=85&" + languageLx);
	});



//alert(languageLx[0]);

	$('.tx-proxsysext-pi3 li.tx-proxsysext-pi3-item').add('.tx-proxsysext-pi1 .newsList').add('.tx-proxsysext-pi2 li.tx-proxsysext-pi3-item').add('.tx-proxsysext-pi5 .newsList').each(function(){
		var itemForPicturePiX = this;
		$(this).find('#smallPic').append('<img class="button_player_px" src="fileadmin/templates/images/button_player_px.png" />')
		$(this).find('.detailInfo').css('display', 'none');
//		$(this).find('.button_player_px').click(function(){
//		$(this).find('#smallPic').click(pxSearchFormat());

//		$(this).find('#smallPic').click(function(){
//			pxSearchFormat(pxSearchFormat);
//		});

//		$(this).find('#smallPic').bind("click",pxSearchFormat2);
/*
		$(this).find('#smallPic').click(function(){
			$(itemForPicturePiX).find('.detailInfo').trigger('click');
		});
*/
	})

// dienächste Code-Linie muss noch gelöscht werden:
//	$('#col3_content_top').append($('.tx-proxsysext-pi5 form'));

/*
	$('#col3_content_top').append("<div class='line2'></div>");
	$('.px_pi2_searchForm').appendTo($('#col3_content_top .line2'));

	$('#col3_content_top .line2').after($(".px_pi2_projectForm"));
*/






/*
	// Disk ID / Blu-ray ID, Quick Select, Folder, Container
//	$(".px_containerView").prependTo("#col1_content .submenu");
	$(".px_folder_header").prependTo("#col1_content .submenu");
	$(".px_folder_header").after($(".px_folderList"));
	$(".px_diskIdOutput").prependTo("#col1_content .submenu");
	$(".px_quickselect").prependTo("#col1_content .submenu");

	var px_quickselect_header = $(".px_quickselect .qsHeader").text();
	var px_diskIdOutput_header = $(".px_diskIdOutput .header").text();
	var px_folder_header = $(".px_folder_header").text();
	$(".px_quickselect .qsHeader, .px_diskIdOutput .header, .px_folder_header").text("");

	var pxDiskIdList = $(".px_diskIdOutput .diskIdList");
	if ($(".px_diskIdOutput .diskIdList").css("display") != "none") {
//	if ((pxDiskIdList != false) && (pxDiskIdList.css("display") != "none")) {
//		$("#col3_content_top").append($(".px_label_ActualDiskId"));
		$("#col3_content_top .line2").prepend($(".px_label_ActualDiskId"));
		var px_diskIdOutput_header_activity = "-active";
	}
	else {
		var px_diskIdOutput_header_activity = "";
	}
	$(".px_diskIdOutput .header").html("<img src='fileadmin/templates/images/blu-ray-id" + px_diskIdOutput_header_activity + ".gif' alt='" + px_diskIdOutput_header + "'>");
		
	if($(".px_quickselect .quickselectList").css("display") != "none"){
//		$("#col3_content_top").append($(".px_label_QuickSearchItem"));
		$("#col3_content_top .line2").prepend($(".px_label_QuickSearchItem"));
		var px_quickselect_header_activity = "-active";
	}else{
		var px_quickselect_header_activity = "";
	}

	if(languageLx){
		if(languageLx[0] == 'L=0'){
			$(".px_quickselect .qsHeader").html("<img src='fileadmin/templates/images/schnellauswahl" + px_quickselect_header_activity + ".gif' alt='" + px_quickselect_header + "'>");
		} else if(languageLx[0] == 'L=1'){
			$(".px_quickselect .qsHeader").html("<img src='fileadmin/templates/images/quick-select" + px_quickselect_header_activity + ".gif' alt='" + px_quickselect_header + "'>");
		} else {
			$(".px_quickselect .qsHeader").html("<img src='fileadmin/templates/images/schnellauswahl" + px_quickselect_header_activity + ".gif' alt='" + px_quickselect_header + "'>");
		}
	} else {
		$(".px_quickselect .qsHeader").html("<img src='fileadmin/templates/images/schnellauswahl" + px_quickselect_header_activity + ".gif' alt='" + px_quickselect_header + "'>");
	}

	if($(".px_folderList").css("display") != "none"){
//		$("#col3_content_top").append($(".px_label_actualFolder"));
//		$("#col3_content_top .proxsysext-searchform").prepend($(".px_label_actualFolder"));
		$("#col3_content_top .line2").prepend($(".px_label_actualFolder"));
		var px_folder_header_activity = "-active";
	}else{
		var px_folder_header_activity = "";
	}

	if(languageLx){
		if(languageLx[0] == 'L=0'){
			$(".px_folder_header").html("<img src='fileadmin/templates/images/ordner" + px_folder_header_activity + ".gif' alt='" + px_folder_header + "'>");
		} else if(languageLx[0] == 'L=1'){
			$(".px_folder_header").html("<img src='fileadmin/templates/images/folders" + px_folder_header_activity + ".gif' alt='" + px_folder_header + "'>");
		} else {
			$(".px_folder_header").html("<img src='fileadmin/templates/images/ordner" + px_folder_header_activity + ".gif' alt='" + px_folder_header + "'>");
		}
	} else {
		$(".px_folder_header").html("<img src='fileadmin/templates/images/ordner" + px_folder_header_activity + ".gif' alt='" + px_folder_header + "'>");
	}

	// Blu-ray ID / Disk ID: open directly first subpage
	$("#submenu a.page126").click(function(){
		var newPageBasic = $("#submenu a.page100").attr("href");
		if(newPageBasic.match(/\?/) == "?"){
			window.location.href = basePath + newPageBasic + "&pxDiskID=pxStandard";
		} else{
			window.location.href = basePath + newPageBasic + "?pxDiskID=pxStandard";
		}
		return false;
	});
	// Quick select: open directly first subpage
	$("#submenu a.page125").click(function(){
		var newPageBasic = $("#submenu a.page100").attr("href");
		if(newPageBasic.match(/\?/) == "?"){
			window.location.href = basePath + newPageBasic + "&pxQuickSearchYear=pxStandard";
		} else{
			window.location.href = basePath + newPageBasic + "?pxQuickSearchYear=pxStandard";
		}
		return false;
	});

	// Folders: open directly first subpage
	$("#submenu a.page100").click(function(){
		var newPageBasic = $("#submenu a.page100").attr("href");
		window.location.href = basePath + newPageBasic + "?fId=pxStandard";
		return false;
	});

	// Container: open it
	$("#submenu a.page127").click(function(){
		var newPageBasic = $("#submenu a.page100").attr("href");
	//	window.location.href = newPageBasic + "?modus=container";
	//	window.location.href = newPageBasic + "&modus=container";
		window.location.href = basePath + newPageBasic + "&modus=container";
		return false;
	});

	// move the headline/title of a video item
	$(".tx-proxsysext-pi3-item").each(function(){
		var firstInfos = $(this).find("#firstInfos");
		$(this).find("h5").prependTo(firstInfos);
	})

	if (actualPage.match(/modus=container/) == "modus=container") {
		if((actualPage.match(/L=0/) == 'L=0') || (actualPage.match(/L=1/) == false)){
			$("#submenu a.page127 img").attr("src","fileadmin/templates/images/merkliste-active.gif");
		} else if(actualPage.match(/L=1/) == 'L=1'){
			$("#submenu a.page127 img").attr("src","fileadmin/templates/images/container-active.gif");
		}
		$("#col3_content_top .line2").prepend($(".px_label_actualFolder"));
	}

	if (actualPage.match(/search=/) == "search=") {
		$("#col3_content_top .line2").prepend($(".px_label_actualFolder"));
	}
*/




})

jQuery.fn.supersleight = function(settings) {

	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};



