$(document).ready(function(){
	$('#main_flash').flash({
		src: 'swf/main.swf',
		wmode: 'transparent',
		width: 969,
		height: 284 },
        { version: 8 }
    );
    
    $('#sub_flash').flash({
		src: 'swf/sub.swf',
		wmode: 'transparent',
		width: 969,
		height: 105 },
        { version: 8 }
    );
    
    if ($("ul#lista_produktow").length)
		$("ul#lista_produktow li:odd").addClass("right_element");
		
	if ($("table.main").length)
		$("table.main tr:even").css("background-color","#F5F5F5");
        
    if ($("form#contactForm").length)
        $("form#contactForm").validate();
        
    if ($("form#orderForm").length)
        $("form#orderForm").validate();
        
    $(".zwin_rozwin").next('ul').hide();
	$(".zwin_rozwin").toggle(function(){
		$(this).next("ul").slideDown(1000);
		$(this).toggleClass("active");
	}, function(){
		$(this).next("ul").slideUp(800);
		$(this).toggleClass("active");
	});

});

function getposOffset(overlay, offsettype){
    var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
    var parentEl=overlay.offsetParent;

    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }

    return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
    if (document.getElementById){
        var subobj=document.getElementById(subobjstr)
        subobj.style.display=(subobj.style.display!="block")? "block" : "none"
        var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
        var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
        //subobj.style.left=xpos+"px"
        subobj.style.left="310px"
        ypos = ypos + 20;
        subobj.style.top=ypos+"px"
        return false
    }
    else
    return true
}

function overlayclose(subobj){
    document.getElementById(subobj).style.display="none"
}

