/**
 *
 * @access private
 * @return void
 * ©Kilos.pl
 *
 **/

 $(document).ready(function(){
	$(".promotabs").tabs(".promos > div", {
	effect: 'fade',
	fadeInSpeed: 600,
	fadeOutSpeed: 600,
	rotate: true
	}).slideshow({
	clickable: false,
	autoplay: true,
	autopause: true,
	interval: 7000
	});
	$("#promo-box").mouseover(function() {
		$("#rotator").hide();
	}).mouseout(function() { $("#rotator").show(); });
	$(function () {
		var tabContainers = $('div.tabs > div');
		$('div.tabs-menu ul.tabNavigation a').click(function () {
			tabContainers.hide().filter(this.hash).fadeIn();
			$('div.tabs-menu ul.tabNavigation a').removeClass('selected');
			$(this).addClass('selected');return false;
		}).filter(':first').click();
	});
     $("#wydarzenia").load("pliki_zrodlowe/wydarzenia.php", function (){
     	$("#nad-wydarzenia").load("pliki_zrodlowe/wydarzenia_nad.php", function (){
     		$("#workers").load("pliki_zrodlowe/workers_nad.php").hide().fadeIn('slow');
     	}).hide().fadeIn('slow');
     }).hide().fadeIn('slow');
    $("#n-sub").click(function() {
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailaddressVal = $("#nemail").val();

		if(emailaddressVal == '') {
			$("#nform-error").text('Wpisz adres email');
			hasError = true;
		} else
			if(!emailReg.test(emailaddressVal)) {
				$("#nform-error").text('email jest nieprawidłowy');
				hasError = true;
			}
			if(hasError == true) {
				return false;
			}
		$("#n-form").submit();
	});
	$("#s-sub").click(function() {
		var sError = false;
		var szukajVal = $("#sszukaj").val();
		if(szukajVal == '') {
			$("#sform-error").text('wpisz szukaną frazę');
			sError = true;
		} else
			if(szukajVal.length <= 3) {
				$("#sform-error").text('wpisz minimum 4 znaki');
				sError = true;
			}
			if(sError == true) {
				return false;
			}
		$("#mini-szuk").submit();
	});
 });
 /////////////////////////////////////////////////////////
function social(url){
	document.write('<fb:like href="'+ url +'" layout="button_count" show_faces="false" width="350" action="like" font="tahoma"></fb:like>');
}
function change_view(id){
	document.getElementById('view_mode').value = id;
	document.getElementById('k_view').submit();
}
function popup(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable) {
	var theTop=(screen.height/2)-(height/2);
	var theLeft=(screen.width/2)-(width/2);
	toolbar_str = toolbar ? 'yes' : 'no';
	menubar_str = menubar ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
	window.open(url, name, 'left='+theLeft+',top='+theTop+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}
function add(data) {
	document.getElementById('ksiega').tresc.value =
	document.getElementById('ksiega').tresc.value + data + "";
}
function emot(data) {
	document.ksiega.tresc.value =
	document.ksiega.tresc.value + data + "";
}
function szyjFlash(movie, wdth, hght, bgnd, idName, cel, fVars) {
		//0.9b 02.04.2009
       obj_setFlash = document.getElementById(cel);
       objTag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+wdth+'" height="'+hght+'" id="'+idName+'">';
       paramTag = '<param name="movie" value="'+movie+'" />'+(bgnd != ''?'<param name="bgcolor" value="'+bgnd+'" />':'')+'<param name="quality" value="best" /><param name="menu" value="false" /><param name="flashvars" value="'+fVars+'" />'+(bgnd == ''?'<param name="wmode" value="transparent" />':'')+'</object>';
       if (typeof HTMLElement != "undefined") {
              obj = document.createElement("object");
              obj.setAttribute("data", movie);
              obj.setAttribute("type", "application/x-shockwave-flash");
              obj.setAttribute("width", wdth);
              obj.setAttribute("height", hght);
              obj.setAttribute("id", idName);
              par = document.createElement("param");
              par.setAttribute("name", "quality");
              par.setAttribute("value", "best");
              obj.appendChild(par);
              if (bgnd != '') {
	              par = document.createElement("param");
	              par.setAttribute("name", "bgcolor");
	              par.setAttribute("value", bgnd);
	              obj.appendChild(par);
              }
              par = document.createElement("param");
              par.setAttribute("name", "menu");
              par.setAttribute("value", "false");
              obj.appendChild(par);
              if (fVars != "") {
	              par = document.createElement("param");
	              par.setAttribute("name", "FlashVars");
	              par.setAttribute("value", fVars);
				  obj.appendChild(par);
              }
              if (bgnd == '') {
	              par = document.createElement("param");
	              par.setAttribute("name", "WMode");
	              par.setAttribute("value", "Transparent");
	              obj.appendChild(par);
              }
              par = document.createElement("param");
              par.setAttribute("name", "scale");
              par.setAttribute("value", "noborder");
              obj.appendChild(par);
              par = document.createElement("param");
              par.setAttribute("name", "allowscriptaccess");
              par.setAttribute("value", "samedomain");
              obj.appendChild(par);
              par = document.createElement("param");
              par.setAttribute("name", "pluginspage");
              par.setAttribute("value", "http://www.macromedia.com/go/getflashplayer");
              obj.appendChild(par);
              obj_setFlash.appendChild(obj);
       } else {
              obj_setFlash.insertAdjacentHTML('beforeEnd',objTag+paramTag);
       }
}
function mapka() {

	var map;
	var myLatlng = new google.maps.LatLng(52.42608, 20.72033);
	var myOptions =
	{
		zoom: 17,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.HYBRID
	}

	map = new google.maps.Map(document.getElementById("mapa"), myOptions);

	var infowindow = new google.maps.InfoWindow();
	var marker = new google.maps.Marker
	(
	{
		position: new google.maps.LatLng(52.42608, 20.72033),
		map: map,
		title:"ul. Paderewskiego 1A",
	}
	)
	;
	google.maps.event.addListener
	(
	marker,
	'click',
	function()
	{
		infowindow.setContent('<img src="./pliki_graficzne/nok-nowy-dwor-mazowiecki.jpg" alt="" />');
		infowindow.open(map,marker);
	}
	);

}
function get(obj) {
	document.body.style.cursor = 'wait';
	var poststr =  "kontakt_do=" + encodeURI( document.getElementById("kontakt_do").value ) + "&imie=" + encodeURI( document.getElementById("imie").value ) + "&email=" + encodeURI( document.getElementById("email").value ) + "&mesadz=" + encodeURI( document.getElementById("mesadz").value );
	makePOSTRequest('./pliki_zrodlowe/kontakt.php', poststr);
}
