//compressed
//eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('e $j=17.18();$j(N).19(u(){e O=$j(\'#5\');e P=$j(\'.x-Q-R\');g(O.p==0){P.S(\'x-Q-R-1a\')}e T=$j(\'#5 #U\');e V=$j(\'#5 .x-W\');g(T.p>0){V.3(0).S(\'x-W-U\')}e X=$j(\'#5 .1b\');g(X.p>=1){$j(\'<Y /><Y /><y H="n"><f 7="8/9/a/2/b/c/k.d" /><h>s v</h></y>\').1c(\'#1d\');$j(\'<y H="r"><f 7="8/9/a/2/b/c/k.d" /></y>\').1e(\'.I .1f\')}e Z=$j(\'#5 .10\');g(Z.p==0){$j(\'#5 .1g\').3(0).l(\'H\',\'10\')}$j(\'#5 .n\').J("K",u(){e 4=$j(\'.L\');1h($j(\'#5 .n h\').11());g($j(\'#5 .n h\').11()==\'s v\'){z(i=0;i<4.p;i++){g(4.3(i).A(\'B\')==\'C\'){4.3(i).D("q")}}$j(\'#5 .n f\').l(\'7\',\'8/9/a/2/b/c/w.d\');$j(\'#5 .r f\').l(\'7\',\'8/9/a/2/b/c/w.d\');$j(\'.n\').E(\'<f 7="8/9/a/2/b/c/w.d" /><h>s 1i</h>\')}G{z(i=0;i<4.p;i++){g(4.3(i).A(\'B\')!=\'C\'){4.3(i).t("q")}}$j(\'#5 .r f\').l(\'7\',\'8/9/a/2/b/c/k.d\');$j(\'.n\').E(\'<f 7="8/9/a/2/b/c/k.d" /><h>s v</h>\')}});$j(\'#5 .r f\').J("K",u(){e 6=$j(\'#5 .r f\').6(12);e 4=$j(\'.L\');e 2=$j(\'#5 .r f\');g(4.3(6).A(\'B\')==\'C\'){4.3(6).D("q");2.3(6).l(\'7\',\'8/9/a/2/b/c/w.d\')}G{4.3(6).t("q");2.3(6).l(\'7\',\'8/9/a/2/b/c/k.d\');$j(\'.n\').E(\'<f 7="8/9/a/2/b/c/k.d" /><h>s v</h>\')}z(i=0;i<4.p;i++){g(i!=6){4.3(i).t("q");2.3(i).l(\'7\',\'8/9/a/2/b/c/k.d\')}}});$j(\'.I 13\').J("K",u(){e 6=$j(\'.I 13\').6(12);e 4=$j(\'.L\');e 2=$j(\'#5 .r f\');g(4.3(6).A(\'B\')==\'C\'){4.3(6).D("q");2.3(6).l(\'7\',\'8/9/a/2/b/c/w.d\')}G{4.3(6).t("q");2.3(6).l(\'7\',\'8/9/a/2/b/c/k.d\');$j(\'.n\').E(\'<f 7="8/9/a/2/b/c/k.d" /><h>s v</h>\')}z(i=0;i<4.p;i++){g(i!=6){4.3(i).t("q");2.3(i).l(\'7\',\'8/9/a/2/b/c/k.d\')}}});1j(1k(N.1l)){o\'1m%M%1n\':m;o\'1o\':m;o\'1p\':m;o\'1q\':m;o\'1r\':m;o\'1s%14%1t%1u\':m;o\'%M%1v\':m;o\'1w\':m;o\'F%M%1x%1y%1z%14(1A%1B)\':m;1C:m}});u 1D(15){g(15){$j(\'#16\').D()}G{$j(\'#16\').t()}}',62,102,'||images|eq|list|tabsmenu|index|src|typo3conf|ext|vtm_hogrefe|layout|allgemein|gif|var|img|if|span|||ic_closed_pluszeich|attr|break|accordion_all|case|length|fast|accordion|Alle|hide|function|ausklappen|ic_open_minuszeich|csc|div|for|css|display|none|show|html||else|class|plp_content_visible|bind|click|plp_content_hidden|C3|document|no_border|csc_header_n1|header|n1|addClass|isPagebrowser|pagebrowser|csc_frame|frame|show_accordion|br|active_links|item2|text|this|h3|20|arg|changePassword|jQuery|noConflict|ready|border|plp_container|appendTo|tabsmenu_level2|prependTo|plp_content_visible_header|item|alert|einklappen|switch|encodeURIComponent|title|Inhalts|BCbersicht|Kapitel|Autor|Glossar|Feedback|Fragen|26|20Antworten|9Cbungen|Zusatzmaterial|BCr|20die|20Lehre|login|20notwendig|default|setPasswordForm'.split('|'),0,{}))


var $j = jQuery.noConflict();

$j(document).ready(function() {
    
        BrowserDetect.init();
	
	var no_border = $j('#tabsmenu');
	var csc_header_n1 = $j('.csc-header-n1');
	
	if (no_border.length == 0) {
		csc_header_n1.addClass('csc-header-n1-border');
	}
	
	var isPagebrowser = $j('#tabsmenu #pagebrowser');
	var csc_frame = $j('#tabsmenu .csc-frame');
	
	if ( isPagebrowser.length > 0 ){
		csc_frame.eq(0).addClass('csc-frame-pagebrowser');
	}
		
	var show_accordion = $j('#tabsmenu .plp_container');
	
	if (show_accordion.length >= 1) {
		$j('<br /><br /><div class="accordion_all"><img src="typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif" /><span>Alle ausklappen</span></div>').appendTo('#tabsmenu_level2');
		$j('<div class="accordion"><img src="typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif" /></div>').prependTo('.plp_content_visible .plp_content_visible_header');
	}
	
	var active_links = $j('#tabsmenu .item2');
	
	if (active_links.length == 0) {
		$j('#tabsmenu .item').eq(0).attr('class', 'item2');
	}
	
	$j('#tabsmenu .accordion_all').bind("click", function(){
		
		var list = $j('.plp_content_hidden');
		
		if ($j('#tabsmenu .accordion_all span').text() == 'Alle ausklappen') {
			for (i=0; i<list.length; i++) {
				if (list.eq(i).css('display') == 'none'){
					list.eq(i).show("fast");
				}
			}
			
			$j('#tabsmenu .accordion_all img').attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_open_minuszeich.gif');
			$j('#tabsmenu .accordion img').attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_open_minuszeich.gif');
			$j('.accordion_all').html('<img src="typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_open_minuszeich.gif" /><span>Alle einklappen</span>');
		}
		else {
			for (i=0; i<list.length; i++) {
				if (list.eq(i).css('display') != 'none'){
					list.eq(i).hide("fast");
				}
			}

			$j('#tabsmenu .accordion img').attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif');
			$j('.accordion_all').html('<img src="typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif" /><span>Alle ausklappen</span>');
		}
	});
	
	$j('#tabsmenu .accordion img').bind("click", function(){
		
		var index = $j('#tabsmenu .accordion img').index(this);
		var list = $j('.plp_content_hidden');
		var images = $j('#tabsmenu .accordion img');

		if (list.eq(index).css('display') == 'none') {
			list.eq(index).show("fast");
			images.eq(index).attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_open_minuszeich.gif');
		}
		else {
			list.eq(index).hide("fast");
			images.eq(index).attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif');
			$j('.accordion_all').html('<img src="typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif" /><span>Alle ausklappen</span>');
		}

		for (i=0; i<list.length; i++) {
	
			if (i != index) {
				list.eq(i).hide("fast");
				images.eq(i).attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif');

			}
		}
	});

	$j('.plp_content_visible h3').bind("click", function(){
		
		var index = $j('.plp_content_visible h3').index(this);
		var list = $j('.plp_content_hidden');
		var images = $j('#tabsmenu .accordion img');

		if (list.eq(index).css('display') == 'none') {
			list.eq(index).show("fast");
			images.eq(index).attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_open_minuszeich.gif');
		}
		else {
			list.eq(index).hide("fast");
			images.eq(index).attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif');
			$j('.accordion_all').html('<img src="typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif" /><span>Alle ausklappen</span>');
		}

		for (i=0; i<list.length; i++) {
	
			if (i != index) {
				list.eq(i).hide("fast");
				images.eq(i).attr('src', 'typo3conf/ext/vtm_hogrefe/images/layout/allgemein/ic_closed_pluszeich.gif');

			}
		}
	});

	switch(encodeURIComponent(document.title)) {

		case 'Inhalts%C3%BCbersicht' :	
			
			break;

		case 'Kapitel' :
			
			break;

		case 'Autor' :	
				
			break;

		case 'Glossar' :	
			
			break;
			
		case 'Feedback' :	
			
			break;

		case 'Fragen%20%26%20Antworten' :	
			
			break;

		case '%C3%9Cbungen' :	

			break;
		
		case 'Zusatzmaterial' :	
			
			break;

		case 'F%C3%BCr%20die%20Lehre%20(login%20notwendig)' :	
			
			break;

		default :	

			break;

		}

	/*
	 * jQuery for registration
	 */
	
	var isRegistration = $j('.tx-srfeuserregister-pi1 #input-box-customer-relation input');

	if(isRegistration.length > 0) {
		$j('#tx-srfeuserregister-pi1-tx_vtmhgfextendsfeuser_customer_relationship-0').click(function() {
			showCustomerRelationInStep1(this);
		});
		
		$j('#tx-srfeuserregister-pi1-tx_vtmhgfextendsfeuser_customer_relationship-1').click(function() {
			showCustomerRelationInStep1(this);
		});

		$('.tx-srfeuserregister-pi1 #tx-srfeuserregister-pi1-email').blur(function() {
			checkEmail(this);
		});

		$('.tx-srfeuserregister-pi1 #tx-srfeuserregister-pi1-email').keyup(function() { 
			checkEmail(this);
		});
		
		if($j('.tx-srfeuserregister-pi1 #input-box-customer-relation-active').val() == '0') {
			$j('.tx-srfeuserregister-pi1 #tx-srfeuserregister-pi1-tx_vtmhgfextendsfeuser_customer_relationship-0').attr('checked', false);
			$j('.tx-srfeuserregister-pi1 #tx-srfeuserregister-pi1-tx_vtmhgfextendsfeuser_customer_relationship-1').attr('checked', false);	
		}
		else {
			//es erfolgte bereits eine Auswahl
			$j('.tx-srfeuserregister-pi1 #form_visibility_activated_by_customer_relationship').show();
			$j('.tx-srfeuserregister-pi1 #button-set-create').show();
		}
	}
	else {
		//Do nothing
	}
	
	$j('#change_password').click(function() {
		setPasswordForm(this.checked);
	});

	/*
	 * jQuery for update_user_account
	 */
	
	if ( $j('.Tx-Formhandler #formhandler_contact_form #user_account_update_form').length > 0 ) {

		if ( document.getElementById('customer_relationship_private').checked) {
			$j('.Tx-Formhandler #input-box-customer-relation-private').show();
		}
		$j('.Tx-Formhandler #input-box-customer-relation #customer_relationship_business').click(function() {
			$j('.Tx-Formhandler #input-box-customer-relation-private').hide();
		});

		$j('.Tx-Formhandler #input-box-customer-relation #customer_relationship_private').click(function() {
			$j('.Tx-Formhandler #input-box-customer-relation-private').show();
		});

		$('.Tx-Formhandler #user_account_update_form').submit(function() {
  			//Customer relationship is controlled by formhandler 
		
			if ( document.getElementById('customer_relationship_private').checked ) {
				return validateDateOfBirthUpdateUserAccount();
			} else {
				return true;
			}
		});
	}
	
	/* Show Sidebar-Banner if BrowserView > 1200 */
	if( $j(window).width() > 1200 ) {
	    $j('#sidebar-banner').show();
	}
	
	$j(window).resize(function() {
	    if( $j(window).width() > 1200 ) {
		$j('#sidebar-banner').show();
	    } else {
		$j('#sidebar-banner').hide();
	    }
	})
     
        $j('#magento-shopping-cart').mouseleave(function(event) {            
            if(BrowserDetect.browser == 'Explorer' && BrowserDetect.version <= 8) {
                $j('#magento-shopping-cart').hide();
                $j('#magento-shopping-cart-layer-parent').hide();
            } else {
                $j('#magento-shopping-cart').fadeOut('slow');
                $j('#magento-shopping-cart-layer-parent').hide();

            }
            $j('.basketLink').css('border-right', '1px solid #FFFFFF');
            $j('.basketLink').css('z-index', '5');
            
        })
        
        $j('#magento-shopping-cart-layer').click(function() {
            $j('#magento-shopping-cart').hide();
            $j('#magento-shopping-cart-layer-parent').hide();
        })
        
});
	

function setPasswordForm(arg){
    if(arg){
        $j('#changePassword').show();
        //$j('current_password').addClassName('required-entry');
        //$j('password').addClassName('required-entry');
        //$j('confirmation').addClassName('required-entry');

    }else{
        $j('#changePassword').hide();
        //$j('current_password').removeClassName('required-entry');
        //$j('password').removeClassName('required-entry');
        //$j('confirmation').removeClassName('required-entry');
    }
}

function checkEmail(arg) {

	var emailaddress_to_check = $j('.tx-srfeuserregister-pi1 #tx-srfeuserregister-pi1-email').val();

	$j.get("index.php?eID=sr_feuser_register&email="+emailaddress_to_check ,function(data) {

		//0 --> no email found
		if (data == '0') {
			$j('.tx-srfeuserregister-pi1 #emailcheckresult').val('1');
		}
		else {
			$j('.tx-srfeuserregister-pi1 #emailcheckresult').val('0');
		}
	});
	
	return false;
}

function validateDateOfBirthUpdateUserAccount() {
	
	//Pruefung: Geburtsdatum
	var errors = false;
	var fieldsWithError = new Array();
		
	var daysPerMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

	var day = $j('#day_of_birth').val();
	var month = $j('#month_of_birth').val();
	var year = $j('#year_of_birth').val();

	if((day != '') &&
		(!isNaN(parseInt(day,10))) &&
		(month != '') &&
		(!isNaN(parseInt(month,10))) &&
		(year != '') &&
		(!isNaN(parseInt(year,10)))) {

		if(year.length == 2) {
			year = '19'+year;
			$j('#year_of_birth').val(year);
		}

		//Gueltigkeit des Datums pruefen
		tempDay = parseInt(day,10);
		tempMonth = parseInt(month,10);
		tempYear = parseInt(year,10);

		if ((tempYear%4) == 0 && ((tempMonth-1) == 1)) {
			//Schaltjahrregel
			daysPerMonth[tempMonth-1] = 29;

			if (tempMonth > daysPerMonth.length || (tempMonth) < 1) {
				errors = true;
				fieldsWithError.push('date_of_birth_invalid');
				$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_required').hide();
			}
			else {
				if (tempDay > daysPerMonth[tempMonth-1]) {
					errors = true;
					fieldsWithError.push('date_of_birth_invalid');
					$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_required').hide();
				}
				else {
					$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_required').hide();
					$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_invalid').hide();
					$j('.Tx-Formhandler #date_of_birth_timestamp').val(new Date(tempYear,(tempMonth-1),tempDay,0,0,0).getTime()/1000);
				}
			}	
		}
		else {
			if (tempMonth > daysPerMonth.length || (tempMonth) < 1) {
				errors = true;
				fieldsWithError.push('date_of_birth_invalid');
				$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_required').hide();
			}
			else {
				if (tempDay > daysPerMonth[tempMonth-1]) {
					errors = true;
					fieldsWithError.push('date_of_birth_invalid');
					$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_required').hide();
				}
				else {
					var date = new Date(tempYear,(tempMonth-1),tempDay,0,0,0);
					// adding timezone offset + 12hrs
					date = date - date.getTimezoneOffset()*60000 + 43200000;
					$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_required').hide();
					$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-date_of_birth_invalid').hide();
					$j('.Tx-Formhandler #date_of_birth_timestamp').val(date/1000);
				}
			}
		}
	}
	else {
		errors = true;
		fieldsWithError.push('date_of_birth_required');
		fieldsWithError.push('date_of_birth_invalid');
	}

	var returnCheckVal = false;
	
	if(!errors) {
		returnCheckVal = true;
	}
	else {
		for(k = 0; k < fieldsWithError.length; k++) {
			$j('.Tx-Formhandler #input-box-customer-relation-private .validation-advice-'+fieldsWithError[k]).show();
		}
		
		returnCheckVal = false;
	}

	return returnCheckVal;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function refreshHgfMageCart(lang) {
    setTimeout(function() { $j.ajax({
       url: 'index.php?eID=hgfmagecart&lang=' + lang,
       success: function(data) {
            $j('#magento-shopping-cart').html(data);
       } 
    })}, 500);
}

function hgfMageCart(lang, opt, num) {
    $j('#product_' + num + '_ctrl').html('<img style="margin: 0px auto 0px auto;" src="/programm/skin/frontend/default/hogrefe/images/opc-ajax-loader.gif" alt="ajax-loader" />');
    $j.ajax({
       url: 'index.php?eID=hgfmagecart&a=' + opt,
       success: function(data) {
           refreshHgfMageCart(lang);
       }
    });
}
