window.onload=function(){
	pg_relations(); 
	phraseObject = document.getElementById('s')
	if(phraseObject){
		blurLabel('phraseLbl',phraseObject);
	}
}
$(function(){
	//alert("ok");					
	var _curr = $("#menu-productrange").find(".current_page_item");
	var _currAnc = $("#menu-productrange").find(".current_page_ancestor");
	var _currPar = $("#menu-productrange").find(".current_page_parent");
	//alert(window.location);
	//_curr.children("ul:first").css("display", "block") ? _currAnc.children("a:first").css("background-image", "url(http://www.quart-media.home.pl/private/avia2/wp-content/themes/twentyten/images/arrowUp.gif);") : _currAnc.children("a:first").css("background-image", "url(http://www.quart-media.home.pl/private/avia2/wp-content/themes/twentyten/images/arrowDown.gif);");
	//_currPar.children("a").css("background", "transparent url(images/adobeReaderIco.gif) left center no-repeat;");
	//alert(_curr.length);
	
	//var navElem = $("#menu-productrange").find(".sub-menu");
	//var depth = navElem.parents().length;
	//while(depth > 0){navElem.children("a:first").css("background", "#f00");}
	
	_currPar.children("ul:first").css("display", "block");
	//_currPar.parents(".sub-menu").parent().children("a:first").css("background", "#f00");
	_curr.children("ul:first").css("display", "block");
	//_curr.parents(".sub-menu").parent().children("a:first").css("background", "#f00");
	_currAnc.children("ul:first").css("display", "block");
	/*if(_currAnc.children("ul:first").css("display") == "block"){
		_currAnc.children("a:first").css("background", "#f00"); 
		_curr.children(".sub-menu") ? _curr.children("a:first").css("background", "#f00") : "";
	}
	else{
		_currAnc.children("a:first").css("background", "#ccc");
	}*/
	
	_currPar.children("ul:first").css("display", "block");
	//_currPar.children("ul:first").children("li:first").children("a:first").css("background", "#f00");
		/*for(var i = 0; i < $("#productRange").children("li").length; i++){
			$("#productRange").children("li").eq(i).children("ul").addClass("subNav");
			if($("#productRange").children("li").eq(i).hasClass("current_page_item") || $("#productRange").children("li").eq(i).hasClass("current_page_parent") || $("#productRange").children("li").eq(i).hasClass("current_page_ancestor")){
				alert("has!");
				$("#productRange").children("li").eq(i).children("ul").removeClass("subNav");
			}	
		}*/
		/*if($(this).hasClass("current_page_ancestor") && $(this).children("ul") != 0){
			$(this).children("li").children(".subNav").css("display", "block");
		}*/
		//alert($(this).className);
	});	
jQuery(document).ready(function($){	
	$("tr").each(function(){
		$(this).children("td:not(:last)").css("border-right", "1px solid #dfdfdf");
	});	 
	$("td, th").css("border-bottom", "1px solid #dfdfdf"); 						
	//$('.zoom').lightBox({fixedNavigation:true});

});
function pg_relations(){   
    var linkdb = document.getElementsByTagName('a');
    for(var anch=1; anch<linkdb.length; anch++){ 
        if(linkdb[anch].href.indexOf('.pdf') !== -1){ 
            linkdb[anch].onclick=function(){window.open(this.href,'_blank',params); return false;};
        }
        else if(linkdb[anch].getAttribute('rel')=='external'){ 
            linkdb[anch].onclick=function(){window.open(this.href,'_blank',''); return false;};
        }
    }
	if($("#newsBox").length > 0){
		$('#newsBox ul')
		.before('<div id="nav">')
		.cycle({
			fx: 'blindX',
			speed: 1000,
			timeout: 7000,
			next: '#rightArrow', 
			prev: '#leftArrow',
			pager:  '#nav' 
		});
	}
}
function focusLabel(id,obj){
	var lbl = document.getElementById(id);
	if(obj.value == ''){lbl.style.visibility = 'hidden';}
}
function blurLabel(id,obj){
	var lbl = document.getElementById(id);
	if(obj.value != ''){lbl.style.visibility = 'hidden';}
	else{lbl.style.visibility = 'visible';	};
}
