$(function(){
	$('.lightbox, .zoom').each(function()
	{
		$(this).lightBox(
		{
			imageLoading: '/themes/gsmsupport.eu/images/lightbox-ico-loading.gif',
			imageBtnClose: '/themes/gsmsupport.eu/images/lightbox-btn-close.gif'
		});
	});
	
	$('#left .expandable > p, #left .expanded > p, #left .expandable > p a, #left .expanded > p a').click(function()
	{
		var li = (this.nodeName == 'A') ? this.parentNode.parentNode : this.parentNode;
		
		if (this.nodeName == 'A' && $(li).hasClass('with-products')) {
			// ta kategoria zawiera produkty, wiec idz od razu pod link bez rozwijania
			document.location.href = this.href;
			return false;
		}
		
		if ($(li).hasClass('expandable'))
	{
		$(li).removeClass('expandable');
		$(li).addClass('expanded');
	}
	else
	{
		$(li).removeClass('expanded');
		$(li).addClass('expandable');
	}
		return false;
	});
	
	window.open_Window = function (language, id)
	{
		var win = window.open('/delivery_calc.php?lang=' + language + '&id=' + id, 'calculator', 'resizable,width=450,height=450,scrollbars');
		win.focus();
	}

	window.open_new_win = function (link, title, params) {
		win = window.open(link, title, params);
		win.focus();
	}

	$('#center.custom li').css({'margin':'0 20px'});

	if(window.location.pathname.match(/(register|rejestracja)\.php$/))
	{
		$('#center.custom').addClass('register');
		$('#center.custom table tr td:odd').css({
			'text-align': 'right'
		});
		$('#center.custom table tr b').css({
			'font-weight': 'normal'
		});
		$('#center.custom table tr td:even').addClass('left');
	}

	if (window.location.pathname.match(/remind_passwd/))
	{
		$('#center.custom').addClass('remind_passwd')
	}
	
	/* $('#also table tr').each(function(){
		var text = '<h3>' + this.childNodes[1].innerHTML + '</h3>' + this.childNodes[0].innerHTML + '<span class="price">' + this.childNodes[2].innerHTML + '</span>';

		if(window.navigator.userAgent.match(/IE/))
			$('#also ul.table').append('<li style="position:relative; margin: 7px">'+text+'</li>');
		else
			$('#also ul.table').append('<li>'+text+'</li>');
	});

	$('#also ul li img').attr('width', 110);
	$('#also ul li img').attr('height', 110);
	$('#also ul li a').each(function(){
		this.innerHTML = this.innerHTML.substr(0,33) + '...';
	});
	
	//$('#also ul li').css({cursor:'hand'});
	$('#also ul li').css({cursor:'pointer'});
	
	$('#also ul li').click(function(){
		window.location.href = this.childNodes[0].childNodes[0].href;
	});

	$('#also table').remove();  */

	if(document.all)
	$('.buy button').css({
		marginTop: '-4px'
	});

	$('input.button').each(function(){
		if(this.value == 'Change')
		$(this).addClass('button-change');
		
		if(this.value == 'Zmień')
		$(this).addClass('button-zmien');
	});
	
	if (window.location.pathname.match(/(gsm_software_list|lista_softu)/))
	{
		$('#center.custom').css({
			textAlign: 'left'
		});
	}

	if (window.location.pathname.match(/(kontakt|contact)/))
	{
		$('#center.custom').addClass('contact');
	}

	if( window.location.search.match(/&log_act=/) )
	{
		$('input[type=text], select').css({
			'width': '160px'
		});
	}
	
	if(window.location.pathname.match(/cennik/))
	{
		$('#center.custom').addClass('cennik');
		$('#center.custom table').attr('border', 0);
	}
	
	if(window.location.pathname.match(/remind_passwd_/))
	{
		$('#center.custom').addClass('passwd');
		$('#center.custom table').attr('border', 0);
		$('#center.custom table td:empty').remove();
	}
	
	$('#center.cart .tooltipcontrol').tooltip();

});

function expandMenuEu() {
	if (typeof cat_path_ids != 'undefined') {
		for (var i=0; i<cat_path_ids.length; i++) {
			var id = '#c'+cat_path_ids[i];
			if ($(id).hasClass('expandable')) {
				$(id).removeClass('expandable');
				$(id).addClass('expanded');					
			}
			$(id).addClass('active');
		}
	}

	if (typeof filter_cat_path_ids != 'undefined') {
		for (var i=0; i<filter_cat_path_ids.length; i++) {
			var id = '#fc'+filter_cat_path_ids[i];
			if ($(id).hasClass('expandable')) {
				$(id).removeClass('expandable');
				$(id).addClass('expanded');					
			}
			$(id).addClass('active');
		}
	}
}
