/* LOGIN-BAR - START ********************************************************/
// language fallback auf DE
cL = 'at';
I18n = Array();

I18n['at'] = Array();
I18n['at']['welcome'] 		= 'Willkommen'; 
I18n['at']['product'] 		= 'Produkt'; 
I18n['at']['products'] 		= 'Produkte'; 
I18n['at']['no_products']	= 'Keine Produkte ...';
I18n['at']['newsletter'] 	= 'Newsletter';
I18n['at']['order_now'] 	= 'Jetzt bestellen';
I18n['at']['login'] 		= 'Anmelden';
I18n['at']['register'] 		= 'Jetzt registrieren';
I18n['at']['currency'] 		= '&euro;';

I18n['cz'] = Array();
I18n['cz']['welcome'] 		= 'Vítejte'; 
I18n['cz']['product'] 		= 'Produkt'; 
I18n['cz']['products'] 		= 'Produkty'; 
I18n['cz']['no_products']	= 'Žádné produkty ...';
I18n['cz']['newsletter'] 	= 'Newsletter';
I18n['cz']['order_now'] 	= 'MÁM ZÁJEM';
I18n['cz']['login'] 		= 'Přihlásit';
I18n['cz']['register'] 		= 'Zaregistrujte se nyní';
I18n['cz']['currency'] 		= 'Kč';

I18n['sk'] = Array();
I18n['sk']['welcome'] 		= 'Vitajte'; 
I18n['sk']['product'] 		= 'Produkt'; 
I18n['sk']['products'] 		= 'Produkty';
I18n['sk']['no_products']	= 'Žiadne produkty ...';
I18n['sk']['newsletter'] 	= 'Möbelix Novinky';
I18n['sk']['order_now'] 	= 'Mám záujem';
I18n['sk']['login'] 		= 'Prihlásiť';
I18n['sk']['register'] 		= 'Zaregistrujte sa teraz';
I18n['sk']['currency'] 		= '&euro;';

I18n['hu'] = Array();
I18n['hu']['welcome'] 		= 'Üdvözlöm'; 
I18n['hu']['product'] 		= 'Termékre'; 
I18n['hu']['products'] 		= 'Termékeket';
I18n['hu']['no_products']	= 'Szám termékeket ...';
I18n['hu']['newsletter'] 	= 'Hírlevél';
I18n['hu']['order_now'] 	= 'Feliratkozás';   
I18n['hu']['login'] 		= 'Bejelentkezés';
I18n['hu']['register'] 		= 'Feliratkozás';
I18n['hu']['currency'] 		= 'Ft';


jQuery(document).ready(function() {

 	//jQuery.lazy({
	//	src: '/fileadmin/templates/scripts/jquery/jquery.colorbox-min.js',
	//	name: 'colorbox',
		// dependencies: {css: ['/fileadmin/templates/scripts/jquery/colorbox/skin5/colorbox.css']},
       // cache: true		
	//	});	

	jQuery.lazy({
		src: '/fileadmin/templates/scripts/jquery/jquery.hybrismap.js',
		name: 'hybrisMap',
		dependencies: {
			css: ['/fileadmin/templates/css/hybrismap.css']
		},
		cache: true		
		});        	
	

	
	//jQuery("#fac_categories").linkselect();
	
	jQuery('div.scrollable_h div.b_banner a').bind('click',function(e){
		pageTracker._trackEvent('banner', 'click', jQuery(this).attr('title'));
		});	
	

	/* Newsletter-BAR - START ********************************************************/	
	nl_bar_html = '<form id="nl_bar_form" name="nl_bar_form" action="/fileadmin/specials/newsletter/' + cL + '/" method="post"><label>' + I18n[cL]['newsletter'] + ':</label><div class="textInputBG"><input id="nl_bar_email" name="email" type="text" class="clearingInput" value="E-Mail"/></div><a href="javascript:document.nl_bar_form.submit();" class="button2"><span>' + I18n[cL]['order_now'] + '</span></a></form>';
	jQuery('#nlbar').html(nl_bar_html)
	/* Newsletter-BAR - STOP ********************************************************/	

    jQuery('.clearingInput').clearingInput();

	//SfNcLogin 			BASE64 				Login (E-Mail)
	//SfNcUsername		BASE64				Vor- und Nachname
	//SfNcCartQuantity	Integer (zB: 3)		Anzahl der Waren im Warenkorb
	//SfNcCartTotal		Decimalzahl (zB: 129.0)	Wert des Warenkorbes

	// login
	if(jQuery.cookie('SfNcUsername') != null){
		jQuery("div.warenkorb_bar_left").html(I18n[cL]['welcome'] + ' <a href="/sortiment/c/account/home">' + Base64.decode(jQuery.cookie('SfNcUsername')) + '</a>&nbsp!<br/><a href="/sortiment/c/account/logoff">Logout</a>');
		}
	else {
		jQuery("div.warenkorb_bar_left").html(I18n[cL]['welcome'] + '!<br/><a href="/sortiment/c/account/login">' + I18n[cL]['login'] + '</a>&nbsp;/&nbsp;<a href="/sortiment/c/account/register">' + I18n[cL]['register'] + '</a>');	
		}
	
	// basket
	if(jQuery.cookie('SfNcCartQuantity') >= 1) {
		total = parseFloat(jQuery.cookie('SfNcCartTotal'));
		total = (total).formatMoney(2, ',', '.');
		if(jQuery.cookie('SfNcCartQuantity') >= 1) {//jQuery('div.warenkorb_bar_right span.inhalt').html('Keine Produkte ...');
			if(jQuery.cookie('SfNcCartQuantity') == 1)	{ text_produkte = I18n[cL]['product'] }
			else										{ text_produkte = I18n[cL]['products'] }
			jQuery('div.warenkorb_bar_right span.inhalt').html(jQuery.cookie('SfNcCartQuantity') + '&nbsp;' + text_produkte + '&nbsp;&nbsp;' + I18n[cL]['currency'] + '&nbsp;' + total);
			}
		}
	else {
		jQuery('div.warenkorb_bar_right span.inhalt').html(I18n[cL]['no_products']);
		}
	});
/* LOGIN-BAR - STOP ********************************************************/	




	

Number.prototype.formatMoney = function(c, d, t){
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};


// get URL-parameter 
function getGetParameter(name){
   var i=1  //Suchposition in der URL
   var suche = name+"="
   while (i<location.search.length){
      if (location.search.substring(i, i+suche.length)==suche){
         var ende = location.search.indexOf("&", i+suche.length)
         ende = (ende>-1) ? ende : location.search.length
         var loca = location.search.substring(i+suche.length, ende)
         return unescape(loca)
      }
      i++
   }
   return false;
}



// ENCODING-DECODING +
		
function urlDecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}
function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}

/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

// ENCODING-DECODING -
