﻿function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_preload() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function swapPixGif(el,what,mode)
{
  el.src = "http://fresh.com.pl/agencja_reklamowa/pub/uploadimages/"+what+"_"+mode+".gif";
}
function swapPixFullNameImage(el,what)
{
  el.src = what;
}

function swapPixJpg(el,what,mode)
{
  el.src = "http://fresh.com.pl/agencja_reklamowa/pub/uploadimages/"+what+"_"+mode+".jpg";
}

function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}
 
function alterNate(elm){
   if (!elm.base) elm.base = elm.value
   if (elm.value == elm.base) elm.value = "";
   else if (elm.value == "") elm.value = elm.base;
}


function ZapytanieZmien(){ 
       if (document.lista_form.wyborStrony.options[document.lista_form.wyborStrony.selectedIndex].value != "none") { 
               location = document.lista_form.wyborStrony.options[document.lista_form.wyborStrony.selectedIndex].value 
       } 
} 


function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){
return (true)
}
alert("Prosimy podać prawidłowy adres e-mail.")
return (false)
}
function checkEmail2(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailx.value)){
return (true)
}
alert("Prosimy podać prawidłowy adres e-mail.")
return (false)
}
function MakeArray(n) {
	this.length = n
	return this
}

if (window.jQuery) {
	$(document).ready(function(){
		/*
			Portfolio nav
		*/
		if($('.portfolio-clients-nav-container').size()) {
			var index = $('.portfolio-clients-nav ul li').index($('.portfolio-clients-nav ul li.active'));
			$('.portfolio-clients-nav-container').jCarouselLite({
				btnNext: ".next",
				btnPrev: ".prev",
				visible: 4,
				start: index-1
			});
		}
		/*
			HOME PROMO IMG rotator
		*/
		if($('.promo-img').size()) {
			$('#slider').nivoSlider({
				effect: 'fade',
				directionNav: false,
				controlNav: false,
				keyboardNav: false,
				pauseOnHover: false,
				animSpeed: 1000,
				pauseTime: 4500
			});
		}
	
		/*
			GOOGLE MAPS
		*/
		if ($('#map').size()) {
			if (GBrowserIsCompatible()) {
				infoText = $('#map-content').html();
				$('#map-content').remove();
				var map = new GMap2(document.getElementById("map"));
				map.addControl(new GSmallMapControl());
				map.setCenter(new GLatLng(52.405063, 16.935897), 15);
				var latlng = new GLatLng(52.405063, 16.935897);
				marker = new GMarker(latlng);
				GEvent.addListener(marker, "click", function(){
					map.openInfoWindowHtml(latlng, infoText);
				});
				map.openInfoWindowHtml(latlng, infoText);
				map.addOverlay(marker);
			}
		}
	});
}
