
/**
 * GCO jQuery $(document).ready configuration for the frontend
 */

$(document).ready(function() {


	/**
	* main dropdown menu
	*/
	
	// bind menu click for toggling 3rd level items
	$("#menu ul.level2 > li:has(ul) > a").toggle(
		function(event) {
			$(this).parent().children('ul').show();
			$(this).parent('.navi_level2_haschild').addClass('navi_level2_haschild-active');
			return false;
		},
		function(event) {
			$(this).parent().children('ul').hide();
			$(this).parent('.navi_level2_haschild-active').removeClass('navi_level2_haschild-active');
			return false;
		}
	);


	// reset 3rd level items when user leaves menu
	$("#menu ul.level1 > li").bind(
		"mouseleave",
		function(event) {
			$("#menu ul.level3").hide();
			$("#menu ul.level2").children().removeClass('navi_level2_haschild-active');
			return false;
		}
	);


	/**
	* quickmenu
	*/

	//show 2nd level items on hover
	$("#quickmenu ul.level1 > li").bind(
		'mouseover',
		function(event) {
			$("#quickmenu ul.level2").show();
			$("#quickmenu ul.level3").hide();
			$(this).children('a.navi_level1').addClass('navi_level1_act').removeClass('navi_level1');
			return false;
		}
	);
	$("#quickmenu ul.level1 > li").bind(
		'mouseleave',
		function(event) {
			$("#quickmenu ul.level2").hide();
			$("#quickmenu ul.level3").hide();
			$(this).children('a.navi_level1_act').addClass('navi_level1').removeClass('navi_level1_act');
			return false;
		}
	);
	
	//bind close button click to main button click
	//$("#quickmenu a.close").bind("click",function(event) {$("#quickmenu ul.level1 > li > a").click();});

	/* disabled
	//show 3rd level items on click of 2nd level items
	$("#quickmenu ul.level2 > li > a").bind(
		"click",
		function(event) {
			var state = 0;
			if ($(this).parent().children('ul.level3').is(':visible')) { state = 1; }
			
			$("#quickmenu ul.level3").hide();
			
			if (state == 0) $(this).parent().children('ul.level3').show();
			return false;
		}
	);
	*/
	
	
	// bind generic accordeon show/hide
	$("#content h2.accordeon_head").toggle(
		function(event) {
			$(this).parent().removeClass('accordeon-inactive').addClass('accordeon-active');
			return false;
		},
		function(event) {
			$(this).parent().removeClass('accordeon-active').addClass('accordeon-inactive');
			return false;
		}
	);

	/**
	* news / blogs
	*/
	
	//within single news view: generate image subline from image title
	$('#content .entrytext img, p.bodytext img, div.csc-textpic img').each(
		function(index) {
			var title = $(this).attr('title');
			if (title) $(this).after('<span class="image_subline">' + title + '</span><div class="clear"></div>');
		}
	);


	/**
	* game teaser
	*/
	if (typeof(gameteaser_data) != 'undefined') $('#partners .tx-gcoteaserevents-pi1').gcoTeaserEvents(gameteaser_data);

	/**
	* image gallery
	*/
	if (typeof(gallery_data) != 'undefined') $('#partners .tx-gcogallery-pi1').gcoGallery(gallery_data);


	/* frühbucher rabatt */
	$('.flashmedia_booking').media( { 
		width: 280, 
		height: 390, 
		autoplay: true,
		flashvars: {targetURL: 'http://www.gamesconvention.com/business/aussteller/konditionen/'}
	}); 


	/* generic lightbox */
	$('div.csc-textpic-imagewrap a.lightbox').lightBox({
		imageLoading: '/fileadmin/templates/img/de/lightbox-ico-loading.gif',
		imageBtnClose: '/fileadmin/templates/img/de/lightbox-btn-close.gif',
		imageBtnPrev: '/fileadmin/templates/img/de/lightbox-btn-prev.gif',
		imageBtnNext: '/fileadmin/templates/img/de/lightbox-btn-next.gif',
		imageBlank: '/fileadmin/templates/img/de/lightbox-blank.gif',
		containerResizeSpeed: 0
	});
	


}); //eof document ready


/* non-jquery tools: */


/* custom tix4gigs */
function loadintoIframe(iframeid, url){
	if (document.getElementById) document.getElementById(iframeid).src=url
}


/* typo3 default */
var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){if(msie4){theObject.blur();}}
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);}
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);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}
return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-2);}
/* eof typo3 default */


/* tx_comments */
function tx_comments_pi1_readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for (var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') {
			c = c.substring(1, c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			return unescape(c.substring(nameEQ.length,c.length)).replace(/\+/, ' ');
		}
	}
	return false;
}

function tx_comments_pi1_setUserDataField(name) {
	var	field = document.getElementById('tx_comments_pi1_' + name);
	try {
		if (field && field.value == '') {
			var	value = tx_comments_pi1_readCookie('tx_comments_pi1_' + name);
			if (typeof value == 'string') {
				field.value = value;
			}
		}
	}
	catch (e) {
	}
}

function tx_comments_pi1_setUserData() {
	tx_comments_pi1_setUserDataField('firstname');
	tx_comments_pi1_setUserDataField('email');
	tx_comments_pi1_setUserDataField('homepage');
}
/* eof tx_comments */

