/*
 * 
 * skrypt obsługujący stronę przejściową dla linków zakupowych(red buttonów)
 * 
 */

function showHideLayer(id, display){
	var obj = document.getElementById(id);
	if(display=='block')
		obj.style.display='block';
	else
		obj.style.display='none';
}



function toggleLayer(whichLayer){
    if (document.getElementById){
        // this is the way the standards work
        var style = document.getElementById(whichLayer).style;
        style.display = (style2.display=="none")? "block":"none";
    }else if (document.all){
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style.display = (style2.display=="none")? "block":"none";
    }else if (document.layers){
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style.display = (style2.display=="none")? "block":"none";
    }
} 

function hideLayer(whichLayer){
    if (document.getElementById){
        // this is the way the standards work
        var style = document.getElementById(whichLayer).style;
        style.display = "none";
    }else if (document.all){
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style.display = "none";
    }else if (document.layers){
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style.display = "none";
    }
}     

function showLayer(whichLayer){
    if (document.getElementById){
        // this is the way the standards work
        var style = document.getElementById(whichLayer).style;
        style.display = "block";
    }else if (document.all){
        // this is the way old msie versions work
        var style2 = document.all[whichLayer].style;
        style.display = "block";
    }else if (document.layers){
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style.display = "block";
    }
}     

function show_product_desc(element_id,divs) {
	var select = document.getElementById(element_id);
	var option = select.options[select.selectedIndex];
		if(option.value==0){
		showLayer('desc_'+element_id.replace('select_',''));
	}
	for(var i =0; i<divs.length;i++){
		if(option.value==divs[i].replace('product_desc_'+element_id.replace('select_','')+'_','')){
			showLayer(divs[i]);
			hideLayer('desc_'+element_id.replace('select_',''));
		}else{
			hideLayer(divs[i]);
		}	
	}
	
	
	//select.selectedIndex = 0;
	//form.target = option.getAttribute('name');
	//form.action = option.value;
	//form.submit();
}



// ********** START skrypty do obslugi zakladek ***********
function ultabsInit() {
	var list = $('ultabs').getElements('li');
		list.each(function(element) {
			var fx = new Fx.Styles(element, {duration:200, wait:false});
		
		element.addEvent('mouseenter', function(){
		  if (element.hasClass('selected')) return;
		  fx.start({ 'background-color': '#e6e6e6', 'color': '#0b1c5c' });
		});
		
		element.addEvent('mouseleave', function(){
		  if (element.hasClass('selected')) return;
		  fx.start({ 'background-color': '#e6e6e6', 'color': '#0b1c5c' });
		});
		
		element.addEvent('click', function(){
		  if (element.hasClass('selected')) return;		//jesli klikniecie w aktywna zakladke, wychodzimy
		
		  var now = $('ultabs').getElement('.selected');		//zakladka aktualnie aktywna
		  var fxnow = new Fx.Styles(now, {duration:200, wait:false});
		  now.removeClass("selected");		//podmiana css class dla zakladek
		  element.addClass("selected");
		  fx.start({ 'background-color': '#fff', 'color': '#000' });		//niezbedna zmiana kolorow
		  fxnow.start({ 'background-color': '#e6e6e6', 'color': '#0b1c5c' });
		
		  var tabnow = $('divtabs').getElement('div.selected');		//tresci odpowiadajace zakladkom
		  var tabme = $(element.id + "txt");
		
		  //przelaczenie zakladek
		  tabnow.removeClass("selected");
		  (function(){tabme.addClass("selected")}).delay(50);
		
		  //manipulowanie zawartoscia prawej kolumny
		  var list2hide = $$('div.tabcolright .tab1only');
		  var dispmode = (element.id == "tab1" ? "block" : "none");
		  list2hide.each(function(el2hide) {
		    el2hide.setStyle('display', dispmode);
		  });
		});
	});
} // end of ultabsInit()



function showHide(showTab, hideTab) {
	var element = $(showTab)
	var now = $('ultabs').getElement('.selected');		//zakladka aktualnie aktywna

 var fx = new Fx.Styles(element, {duration:200, wait:false});

 var fxnow = new Fx.Styles(now, {duration:200, wait:false});
	 now.removeClass("selected");		//podmiana css class dla zakladek
  element.addClass("selected");
  fx.start({ 'background-color': '#fff', 'color': '#000' });		//niezbedna zmiana kolorow
  fxnow.start({ 'background-color': '#e6e6e6', 'color': '#0b1c5c' });

  var tabnow = $('divtabs').getElement('div.selected');		//tresci odpowiadajace zakladkom
  var tabme = $(element.id + "txt");

  //przelaczenie zakladek
  tabnow.removeClass("selected");
  (function(){tabme.addClass("selected")}).delay(50);

}

function showHide2(showElement, hideElement) {
	document.getElementById(hideElement).style.display = 'none';
	document.getElementById(showElement).style.display = 'block';
}
// ********** KONIEC skrypt do obslugi zakladek **********


/*
function  showToolTip() {
	if (window.event && window.event.srcElement) {
		var currentNode = window.event.srcElement;
	} else {
		var currentNode = this;
	}
	var toolTipy = getElementsByClass('tooltip', currentNode, 'div');
	var currentToolTip = toolTipy[0]
	currentToolTip.style.display = 'block';
} // end of showToolTip()



function hideToolTip() {
		if (window.event && window.event.srcElement) {
		var currentNode = window.event.srcElement;
	} else {
		var currentNode = this;
	}
	var toolTipy = getElementsByClass('tooltip', currentNode, 'div');
	var currentToolTip = toolTipy[0]
	currentToolTip.style.display = 'none';
} // end of hideToolTip()


function initToolTips() {
	var divTabs = document.getElementById('divtabs');
	var stepLayers = getElementsByClass('item', divTabs, 'div');
	
	for (var i=0; i<stepLayers.length; i++) {
		
		stepLayers[i].style.cursor = 'pointer';		
		stepLayers[i].addEvent('mouseover', showToolTip);
		stepLayers[i].addEvent('mouseout', hideToolTip);	
	}

} // end of initToolTips()
*/

$(window).addEvent('load', ultabsInit);

//$(window).addEvent('load', initToolTips);
