/**
 * Podpinanie parametru target dla link�w
 * rel = blank | top | self | parent
 */
function externalLinks() 
{
	if (!document.getElementsByTagName) 
	{
		return;
	}
	
	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++) 
	{
		var anchor = anchors[i];
		
		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "blank" || anchor.getAttribute("rel") == "top" || anchor.getAttribute("rel") == "self" || anchor.getAttribute("rel") == "parent"))
		{
			anchor.target = "_" + anchor.getAttribute("rel");
		}
	}
}
window.onload = externalLinks;


/**
 * Detekcja przegladarki
 */
function loadBrowserStyle()
{
	
	if($.browser.name == 'msie' && ($.browser.versionNumber == 6 || $.browser.versionNumber == 7))
	{
		document.write(unescape('%3Clink href="theme/css/style-' + $.browser.name + $.browser.versionNumber + '.css"  type="text/css" rel="stylesheet" /%3E'));
	}
	else if($.browser.name == 'firefox' || $.browser.name == 'opera' || $.browser.name == 'chrome')
	{
		document.write(unescape('%3Clink href="theme/css/style-' + $.browser.name + '.css"  type="text/css" rel="stylesheet" /%3E'));
	}
}
loadBrowserStyle();

function otworz(adres, width, height) 
{
	noweOkno = window.open(adres, 'okienko', 'menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no, width=' + width + ', height=' + height + ', left=30, top=30')
	noweOkno.focus()
}

/**
 * Obsluga elementow podczas ladowania sie strony
 */
$(document).ready(function() 
{
	/** Obsługa FAQ */
	var openLi = -1;
	
	$("ol.faq li").click(function() 
	{
		e = $("ol.faq li").index(this);
		
		if(openLi != e)
		{
			if (openLi >= 0) 
			{
				$("ol.faq li:eq(" + openLi + ") div.faqContent").hide(200);
			}
			
			$("ol.faq li:eq(" + e + ") div.faqContent").show(200);
			
			openLi = e;
		}
		else
		{
			$("ol.faq li:eq(" + openLi + ") div.faqContent").hide(200);
			openLi = -1;
		}
	});
	
	/** Zamówienie OKAY CRM - adres wysyłki */
	$("#wsylkawrite").click(function() 
	{
		stan = $(".wysylkaadres").css("display");
		
		if(stan == 'block')
		{
			$(".wysylkaadres").hide(200);
			$(".wysylkaadres").css("display", "none");
		}
		else
		{
			$(".wysylkaadres").show(200);
			$(".wysylkaadres").css("display", "block");
		}
	});
	
	/** Flash 3 kroki rozwinięcie */
	var FlasStan = 0
	$("#3kroki2").click(function() 
	{
		if(FlasStan == 1)
		{
			$("div#3kroki2flash").hide(200);
			FlasStan = 0;
		}
		else
		{
			$("div#3kroki2flash").show(200);
			FlasStan = 1;
		}
	});
	
	
});

function newwindowopenOKAYCRM(plik,wysokosc,szerokosc,ruchome)
{
	window.open(plik, plik.substr(0,plik.search(".")-1), "height=" + wysokosc + ", width=" + szerokosc + ", location=0, menubar=0, resizable=" + ruchome + ", scrollbars=" + ruchome + ", status=0, titlebar=0, toolbar=0, top=150, left=120");
}