function MM_jumpMenu(targ,selObj,restore){
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore){ selObj.selectedIndex=0; }
}

function superchallenge_pass(form) {
	var pass = form.pass.value;
	if (pass) {
		var enc_pass = MD5(pass);
		var str = form.user.value+":"+enc_pass+":"+form.challenge.value;
		form.pass.value = MD5(str);
		return true;
	}
	else {
		return false;
	}
}
var version = "n3";

// decrypt helper function
function decryptCharcode(n,start,end,offset) {
	n = n + offset;
	if (offset > 0 && n > end)	{
		n = start + (n - end - 1);
	}
	else if (offset < 0 && n < start)	{
		n = end - (start - n - 1);
	}
	return String.fromCharCode(n);
}

// decrypt string
function decryptString(enc,offset) {
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		}
		else if (n >= 0x40 && n <= 0x5A)	{
			dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		}
		else if (n >= 0x61 && n <= 0x7A)	{
			dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
		}
		else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}

// decrypt spam-protected emails
function linkTo_UnCryptMailto(s) { location.href = decryptString(s,-2); }
function switchLayerOn(id){ jQuery('#'+id).style.display = 'block'; return 1; }
function switchLayerOff(id){ jQuery('#'+id).style.display = 'none'; return 1; }

function LayerOff(id, elements) {
	for(i=1; i<=elements; i++) {
		if(id != i) {
			jQuery('#layer-'+i).style.display = 'none';
			jQuery('#tab-'+i).className = 'tab';
		}
		else {
			jQuery('#layer-'+id).style.display = 'block';
			jQuery('#tab-'+id).className = 'tab-active';
		}
	}
}

function loginHover(id, status){
	var loginElement = document.getElementById(id).getElementsByTagName("LI");
	for (i=0; i<loginElement.length; i++) {
		if(loginElement[i].className!=id+' over' && status=='over') {
			loginElement[i].className+=" over";
		}
		else if(status != 'over') {
			loginElement[i].className = id;
			//loginElement[i].className=loginElement[i].className.replace(new RegExp(" over\\b"), "");
		}
	}
}




/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
/***************************/

//0 means disabled; 1 means enabled;
var jpopupStatus = 0;

//loading popup
function jpopupLoad(jpopupTitle, noIeBackground, altClass, altWidth) {
	var jpopupTitle;
	var noIeBackground;
	var altClass;

	if(jpopupStatus==0) {
		jQuery(".jpopup-header-title").html(jpopupTitle);
		if(noIeBackground == 1) {
			jQuery.each(jQuery.browser, function(i) {
				if(!jQuery.browser.msie){
					jQuery(".jpopup-background").fadeIn(1100);
				}
			});
		}
		else { jQuery(".jpopup-background").fadeIn(1100); }
		jQuery(".jpopup").fadeIn(1100);

		if(altClass != '') { jQuery(".jpopup").addClass(altClass); }

		// 20100420 mb: neu fÃ¼r nfcvideo
		var altWidth;
		if(altWidth != '') { jQuery(".jpopup").css('width',altWidth); }

		jpopupStatus = 1;
	}
}

//disabling popup
function jpopupDisable() {
	// 20100420 mb: neu fÃ¼r nfcvideo
	jQuery(".jpopup video").remove();
	jQuery(".jpopup audio").remove();

	if(jpopupStatus==1) {
		jQuery(".jpopup-background").fadeOut(400);
		jQuery(".jpopup").fadeOut(400);
		jpopupStatus = 0;
	}
}

//centering popup
function jpopupCenter() {
	//request data for centering
	var windowWidth = jQuery(window).width();
	var windowHeight = jQuery(window).height();
	var popupHeight = jQuery(".jpopup").height();
	var popupWidth = jQuery(".jpopup").width();
	var scrollTop = jQuery(window).scrollTop();

	//centering
	jQuery(".jpopup").css({
			"position": "absolute",
			"top": (scrollTop+50),
			"left": windowWidth/2-popupWidth/2
		});
	//only need force for IE
	jQuery.each(jQuery.browser, function(i,val){
		if( i == 'msie' && val == true && jQuery.browser.version.substr(0,1) <= 8){
			jQuery(".jpopup-background").css({
				"height": windowHeight + scrollTop,
				"display": "none"
			});
		}
	});
}

/*** selectVariations ***/
/**
* simulate a dropdown select box
*/
function selectVariations(){
	jQuery('.product-view-variations-list li').click(function(){
		jQuery("[input[name='products_variations_id']").val(jQuery(this).attr("class"));
		jQuery('.product-view-variations .newListSelected').html(jQuery(this).html());
		jQuery(this).parent().hide();
		return false;
	});
}

function jpopupAddProduct(pageId, productsId, variations_id)
{
	var pageId;
	var productsId;
	var bol_productVariation;
	var productsVariationsId = 0;

	if(variations_id >= 0){
		productsVariationsId = variations_id;
	}


	jpopupCenter();
	jpopupLoad('', 1);
	jpopupLoading();
	if(productsId > 0)
	{
		var productsIdGet = "&tx_nfcshop_pi1[products_id]="+productsId;
		var productsVariationsIdGet = productsVariationsId > 0 ? "&tx_nfcshop_pi1[products_variations_id]="+productsVariationsId : "";
		$j.ajax
		(
			{
				type: "POST",
				//timeout: 7000,
				data: {},
				url: "index.php?id="+pageId+"&type=576&tx_nfcshop_pi1[action]=AJAX_ADD_CART"+productsIdGet+productsVariationsIdGet,
				success: function(result)
				{
					$j(".jpopup-content").html(result);
					selectVariations();
				},
				error:function (xhr, ajaxOptions, thrownError)
				{
					console.log(xhr.status);
					console.log(ajaxOptions);
					console.log(thrownError);
				}
			}
		);
	}
	return false;
}


/**
 * Comment
 */
function jpopupRecommendationForm(pageId, area, shopId, productsId, productName, productImage){
	var pageId;
	var area;
	var shopId;
	var productsId;
	var productImage;
	var productName;
	var action = 'AJAX_MAIL_RECOMMENDATION';
	var type = '576';

	jpopupCenter();
	jpopupLoad('', 1);
	jpopupLoading();

	jpopupStatus = 1;

	jQuery.ajax({
		type: 'POST',
		url: "index.php?id="+pageId,
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		data: {
			productsId: productsId,
			shopId: shopId,
			area: area,
			productImage: productImage,
			productName: productName,
			'tx_nfcshop_pi1[action]': action,
			type: type
		},
		success:function (outputText, textStatus){
			if(outputText){	jQuery(".jpopup-content").html(outputText); }
		}
	});
}

/**
 * Comment
 */
function sendRecommendation(shopId, area, productId, obj){
	var shopId;
	var area;
	var productId;
	var inputFields;
	var formValues = new Array();
	var obj_php = "";
	var total = 0;

	jQuery('.error').remove();

	for(i=0; i <obj.childNodes.length; i++)	{
		if(obj.childNodes[i].tagName == "INPUT"){
			if(obj.childNodes[i].type == "text"){
				++ total;
				obj_php = obj_php + "s:" +
                String(obj.childNodes[i].name).length + ":\"" + String(obj.childNodes[i].name) + "\";s:" +
                String(obj.childNodes[i].value).length + ":\"" + String(obj.childNodes[i].value) + "\";";
			}
		}
	}
	obj_php = "a:" + total + ":{" + obj_php + "}";

	jQuery.ajax({
		type: 'POST',
		url: 'index.php?eID=tx_nfcshop_recommendation_send',
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		data:
		{
			shopId: shopId,
			area: area,
			productId: productId,
			obj_php: obj_php
		},
		success:function (outputText, textStatus){
			if(outputText){
				var output = outputText.split('|');
				var counter = 0;
				for(var i = 0; i < output.length; i++){
					var failure_pos = output[i].search(/_failure/);
					if(failure_pos >= 0){
						var formtag = output[i].substr(0, failure_pos);
						jQuery('.recommendation_'+formtag+'_input').after('<span class="error">X</span>');
						++ counter;
					}
				}

				if(counter == 0){
					//console.log(outputText);
					jQuery(".jpopup-content").html('<div class="recommendation_success">'+outputText+'</div>');
					setTimeout("jpopupDisable()", 2000);
				}
				else{ console.log('ERROR'); }
			}
		}
	});
}


function jpopupLoading() {
	jQuery(".jpopup-content").html('<div style="text-align: center"><img src="fileadmin/_global/graphics/icons/loading.gif" /></div>');
}

function jpopupLoadingText(text)
{
	$j(".jpopup-content").html('<div style="text-align: center"><img src="fileadmin/_global/graphics/icons/loading.gif" /></div><div style="text-align: center">'+text+'</div>');
}



/*** TOOLTIP ***/
//0 means disabled; 1 means enabled;
var jtooltipStatus = 0;
function jtooltipLoad(jtooltipTitle){
	var jtooltipTitle;

	if(jtooltipStatus==0){
		jQuery("#jtooltip-content").html(jtooltipTitle);
		jQuery("#jtooltip").show();
		jtooltipStatus = 1;
	}
}


function jtooltipPosition(relativeX, relativeY){
	jQuery("#jtooltip").css({
		"position": "absolute",
		"top": (relativeY),
		"left": relativeX,
		"z-index": 9999
	});
}

//disabling tooltip
function jtooltipDisable(){
	if(jtooltipStatus==1){
		jQuery("#jtooltip").hide();
		jtooltipStatus = 0;
	}
}


var openLinkStatus = 0;
function openLink(domPath, addParams){
	var addParams = addParams ? addParams : '';
	var url = jQuery(domPath).attr("href") + addParams;

	if(openLinkStatus == 0){
		openLinkStatus = 1;
		//console.log(url);
		window.location = url;
	}
}

function openLinkUrl(linkUrl){
	if(openLinkStatus == 0)	{
		openLinkStatus = 1;
		//console.log(linkUrl);
		window.location = linkUrl;
	}
}

//function jSwitchLayerVariations(value){
//	if (jQuery(value).is(':hidden') ){ jQuery(value).show(); }
//	else { jQuery(value).hide(); }
//}
//
//function jSwitchLayer(value){
//	if (jQuery(value).is(':hidden')) { jQuery(value).show(); }
//	else { jQuery(value).hide(); }
//}
//
//
/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            }
			else { date = options.expires; }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    }
	else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


/**
 * @comment			changed 20100312 by Markus Brunner -> extension access for new classes
 * @param int id 		layer id number
 * @param int elements	number of elements
 * @param string extension	extension css-class prefix e.g. 'nfc-shippingpages-'
 */
function LayerOff(id, elements, extension){
	for(i=1; i<=elements; i++)	{
		if(id != i)		{
			if(document.getElementById(extension+'layer-'+i))			{
				document.getElementById(extension+'layer-'+i).style.display = 'none';
				document.getElementById(extension+'tab-'+i).className = extension+'tab';
			}
		}
		else {
			document.getElementById(extension+'layer-'+id).style.display = 'block';
			document.getElementById(extension+'tab-'+id).className = extension+'tab-active';
		}
	}
}


function array_key_exists ( key, search ){
	// Checks if the given key or index exists in the array
	// version: 909.322
	// discuss at: http://phpjs.org/functions/array_key_exists
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Felix Geisendoerfer (http://www.debuggable.com/felix)
	if (!search || (search.constructor !== Array && search.constructor !== Object)) { return false; }
	return key in search;
}
//
//// mb: flyouttree-additional-columns BEGIN
//var flyoutTreeAdditionalColumns = jQuery.extend({
//	appName:'flyoutTreeAdditionalColumns',
//	elements: null,
//	options: {
//		leftDistance: 236,
//		colWidth: 193
//	},
//	init: function(elements, options) {
//		var options = jQuery.extend(true,this.options,options);
//		this.options = options;
//		var nextLevelElements = jQuery(elements).find('ul.flyouttree-additional-columns');
//		var nextLevelElementsCount = nextLevelElements.length;
//		if(nextLevelElementsCount > 0) {
//			var maximumColHeight = 0;
//			nextLevelElements.each(jQuery.shove(function(index,elem){
//				var newLeftPosition = this.options.leftDistance + (parseInt(index) * this.options.colWidth);
//				jQuery(elem).css({'left':newLeftPosition+'px','width':this.options.colWidth+'px'});
//				var currentColHeight = jQuery(elem).outerHeight();
//				if(currentColHeight > maximumColHeight) maximumColHeight = currentColHeight;
//			}, this));
//			if (maximumColHeight > 0) {nextLevelElements.css('height',maximumColHeight);}
//		}
//	}
//});
// mb: flyouttree-additional-columns END

/**
 * function to toggel the product-features
 * @date 		20100422
 * @author 	Yves Poersch
 */
function toggelFeatures(int_number, str_openButtonPath, str_closeButtonPath) {
	if (jQuery("#features_values_" + int_number).css('display') != 'none'){
		jQuery("#features_values_" + int_number).slideUp();
		jQuery("#features_headline_" + int_number).css('background', 'url("' + str_closeButtonPath + '") no-repeat scroll left center transparent');
	}
	if (jQuery("#features_values_" + int_number).css('display') == 'none') {
		jQuery("#features_values_" + int_number).slideDown();
		jQuery("#features_headline_" + int_number).css('background', 'url("' + str_openButtonPath + '") no-repeat scroll left center transparent');
	}
}

function displayFeatures(int_number, str_openButtonPath) {
	if (jQuery("#features_values_" + int_number).css('display') == 'none') {
		jQuery("#features_values_" + int_number).slideDown();
		jQuery("#features_headline_" + int_number).css('background', 'url("' + str_openButtonPath + '") no-repeat scroll left center transparent');
	}
}

function openUsedFeatureLists(str_openButtonPath) {
	var url = window.location.search;
	if (url != "") {
		var liste = url.split("&");
		/* auch hier splitten am "&" */
		for (i=0;i<=liste.length-1;i++) {
			var temp = liste[i].split("=");
			//var x = temp[0].replace('/^[0-9](.*)/g','');
			var x = temp[0].replace('[]','');
			x =  x.replace('f','');
			x =  x.replace('?','');
			displayFeatures(x, str_openButtonPath);
		 }
	 }
}


function changeProductsPerPage(int_productsPerPage) {
	var int_productsPerPage;
	if(window.location.href.indexOf('?') == -1) {
		self.location.href = window.location.href + '?ppp=' + int_productsPerPage;
	}
	else {
		self.location.href = window.location.href + '&ppp=' + int_productsPerPage;
	}
}


var $j = jQuery.noConflict();
