
function p(o) {
	window.open(o.href);
	return true;
}


function jumpMenu(id) {
	
	var optionItemValue = null;
	var optionItem = document.getElementById(id);
	if (optionItem) {
		var optionItemSelected = optionItem.options[optionItem.selectedIndex];
		if (optionItemSelected) optionItemValue = optionItemSelected.value;
		if (optionItemValue != 0) {
			window.location.href = optionItemValue;
		}
	}
	return false;
 }

function homeHolder(idClose, idOpen) {
	if ((idClose != null) && (idOpen != null)) {
		var closeEl = document.getElementById('home_holder_'+idClose);
		var openEl = document.getElementById('home_holder_'+idOpen);
		if (closeEl) closeEl.className = 'holder hidden';
		if (openEl) openEl.className = 'holder';
	}
}
	
function ConstructMailLink(name, domain, image) {
	return document.write('<a href="mailto:' + name + '@' + domain + '" onmouseover="changeImage(\'mail\',\'/dsg/ico/separator_a.gif\')" onmouseout="changeImage(\'mail\',\'/dsg/ico/separator.gif\')">' + name + '<img src="' + image + '" alt="sep" id="mail" class="sep" />' + domain + '</a>');
}

function changeImage(id, imagePath) {
	var email = document.getElementById(id);
	if (email != null) {
		email.src = imagePath;
	}
}

function showImage(imageIndex, imagePath, totalCount) {
	var bigImg = document.getElementById('bigImage');
	if (bigImg != null) {
		bigImg.src = imagePath;
	}
	
	for (var i = 0; i < totalCount; i++) {
		var imageClassName = 'hidden';
		if (i == imageIndex) imageClassName = '';
		
		var imageTitle = document.getElementById('image_title_'+i);
		if (imageTitle != null) {
			imageTitle.className = imageClassName;
		}
		
	}
}


var tsel = 0;


$(document).ready(function(){
	//	Menu
	$('.nav_primary li').hover(
		function() {
			if(!$(this).hasClass("sel")) $(this).animate({marginTop:'12px'},{duration:150,queue:false});
		},
		function() {
			if(!$(this).hasClass("sel")) $(this).animate({marginTop:'43px'},{duration:150, queue:false});
		}
	);
	//	Products
	$('.plist>li').find('h3').hover(
		function() {
			if(!$(this).hasClass("sel")) $(this).animate({marginTop:'0'},{duration:150,queue:false}).addClass('over');
		},
		function() {
			if(!$(this).hasClass("sel")) $(this).animate({marginTop:'10px'},{duration:150, queue:false}).removeClass('over');
		}
	);
	//select arrows
	$('.plist>li').find('h3').each(
		function() {
			if($(this).hasClass("sel")) {
				tsel = $(this).parent().attr('class');
				tsel = tsel.substring(tsel.search('no')+2);
			}
		}
	);
	$('.mooving').find('a').each(
		function() {
			if (tsel > 4) {
				if($(this).hasClass('prev')) $(this).removeClass('disabled');
				if($(this).hasClass('next')) $(this).addClass('disabled2');
			}
		}
	);
	$('.mooving').find('a').mouseover(
		function() {
			if($(this).hasClass('prev')) $(this).next().removeClass('disabled2');
		}
	);
	//	Accordionk
	var config = {sensitivity:1,interval:500,over:accOpen,timeout:500,out:accClose};
	maxHeight = 0;
	dlHeight = 0;
	$('.company').find('dd').each(function(elHeight){maxHeight = ($(this).height() > maxHeight) ? $(this).height() : maxHeight;});
	$('.company>dd').hide();
	$('.company>dd').css({height:maxHeight+'px'});
	$('.company').css({height:maxHeight+($('.company>dt').height() * $('.company').find('dt').length + 10)+'px',overflow:'hidden'});
	$('.company>dd:first').show();
	$('.company>dt').hoverIntent(accOpen,accClose);
/*
	//	Tabs
	$("#adv2").idTabs(function(id,list,set){
		$("a",set).removeClass("selected").filter("[@href='"+id+"']",set).addClass("selected");
		for(i in list)
			$(list[i]).hide();
		$(id).fadeIn();
		return false;
	});
*/
});
function accOpen () {if ($(this).next('dd').is(':visible') == false) $(this).next('dd').slideToggle('fast').siblings('dd:visible').slideUp('fast');}
function accClose () {}


if ($('.increaseFont') || $('.decreaseFont')) {
	$(document).ready(function(){
  // Reset Font Size
  var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
    var newFontSize = 19;
    
    var increaseElement = document.getElementById('fontSizeIncrease');
    var decreaseElement = document.getElementById('fontSizeDecrease');
	if (increaseElement && decreaseElement) {
		increaseElement.style.display = 'none';
		decreaseElement.style.display = 'block';
	}

    
    $('html').css('font-size', newFontSize);
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var newFontSize = 16;
    
    var increaseElement = document.getElementById('fontSizeIncrease');
    var decreaseElement = document.getElementById('fontSizeDecrease');
	if (increaseElement && decreaseElement) {
		increaseElement.style.display = 'block';
		decreaseElement.style.display = 'none';
	}
    
    $('html').css('font-size', newFontSize);
    return false;
  });
});

}

//$(document).ready(function(){
//	$.datepicker.setDefaults({showOn: 'both', buttonImageOnly: true, buttonImage: '/dsg/ico/calendar.gif', buttonText: 'Koledar', dateFormat: 'dd.mm.yy'});
//	//$('#calendarDatePicker').attachDatepicker({minDate: '-10y', maxDate: '-100y', showWeeks: true, firstDay: 1, changeFirstDay: false, showOtherMonths: true});
//	//$('#calendarDatePicker').attachDatepicker({minDate: -36500, maxDate: -3650, changeFirstDay: false, showOtherMonths: true});
//	$('#calendarDatePicker').attachDatepicker({minDate: -36500, maxDate: -3650, changeFirstDay: false, showOtherMonths: true});
//
//
//});


function updateCityByPostNum(postNumList, postNumElem, cityElemID) {
    // binary search
    var cityElem = document.getElementById(cityElemID);
    if (cityElem == null) return;
    var selPostNumber = postNumElem.value;
    
	var low = 0, high = postNumList.length - 1;
	while (low <= high) {
		var mid = (low + high) >> 1;
		var id = postNumList[mid].id;
		if (id == selPostNumber) {
		    cityElem.value = postNumList[mid].n;
		    return;
		}
		if (id < selPostNumber) low = mid + 1;
		else high = mid - 1;
	}
}


function showHideElement(elemID, show /* -1 = toggle, 0 = hide, 1 = show */) {
    var elem = document.getElementById(elemID);
    if (elem == null) return false;
    var isHidden = (show == 0);
    if (show == -1) isHidden = (elem.style.display != 'none');
    elem.style.display = isHidden ? 'none' : 'block';
    return false;
}


function showHideElements(elemList) {
    for (var i in elemList) {
        showHideElement(elemList[i].id, elemList[i].show);
    }
    return false;
}


function enableDisableElement(elemID, enable /* -1 = toggle, 0 = hide, 1 = show */) {
    var elem = document.getElementById(elemID);
    if (elem == null) return false;
    var isDisabled = (enable == 0);
    if (enable == -1) isDisabled = !elem.disabled;
    elem.disabled = isDisabled;
    return false;
}


function enableDisableElements(elemList) {
    for (var i in elemList) {
        enableDisableElement(elemList[i].id, elemList[i].enable);
    }
    return false;
}

