 $(document).ready(function(){
	$("#nav li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
 	if (document.all) {
		$("#nav li").hoverClass ("sfHover");
	}
 });
 

 
 
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover(
			function() { $(this).addClass(c);},
			function() { $(this).removeClass(c); }
		);
	});
};	  
	


function showMenu(sel){
    for(i=1;i<=6;i++){
        $("#submenu"+i).slideUp("fast");
    }
    $("#submenu"+sel).slideDown("normal");
    
    if(sel==3) //galeria
    {
    	showArt(3,0,0);
    }
    
}
var activemain = 0;
var activesub = 0;

function loadArt(main,sub){
	document.getElementById("box").innerHTML = '';
	$("#kreciol").css({'display':'block'});
	if(activemain!=0 && activesub!=0)
	$("#submenua"+activemain+"_"+activesub).css({'border-bottom': '0px'});
	$("#submenua"+main+"_"+sub).css({'border-bottom':'solid 2px', 'border-color':'#3196fe','padding':'0px'});
	activemain = main;
	activesub=sub;
	$.ajax({
	     type: "POST",
	     url: "list.php",
	     data: "d="+main+"&s="+sub,
	     cache: false,
	     success: function(html){
	     	$("#kreciol").css({'display':'none'});
			document.getElementById("box").innerHTML = html;
			document.getElementById('box').innerHTML = html;
			document.getElementById('box').style.padding="";
			document.getElementById('box').style.overflow="";
			document.getElementById('box').style.height="";
			document.getElementById('box').style.width="";
			document.getElementById('box').style.position="";	
			document.getElementById('mapImg').style.display = 'none';
			switch(main){
				case 1:
					switch(sub){
						case 1:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/m0552.jpg" />';
							break;
						case 2:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/m0552.jpg" />';
							break;
					}			
				break;
				case 2:
					switch(sub){
						case 1:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/twarz.jpg" />';
							break;
						case 2:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/cialo.jpg" />';
							break;
						case 3:
							document.getElementById('miniImg').innerHTML = '<img style="margin-left:70px;" src="i/oferta/masaze.jpg" />';
							break;
						case 4:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/pakiety_zabiegowe.jpg" />';
							break;
						case 5:
							document.getElementById('miniImg').innerHTML = '<img style="margin-left:70px;" src="i/oferta/m0658.jpg" />';
							break;
						case 6:
							//document.getElementById('miniImg').innerHTML = '<img src="i/oferta/default.jpg" />';
							document.getElementById('miniImg').innerHTML = '';
							break;					
						case 7:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/oferta_dla_firm.jpg" />';
							break;					
						case 8:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/promocje.jpg" />';
							break;		
						case 9:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/ciaza.jpg" />';
							break;													
					}
				break;
			}
			      
			if(main!=2)
				document.getElementById('miniImg').innerHTML = ' ';
				document.getElementById('mapImg').style.display = 'none';
				
				
			$(function(){
					$('a[@rel*=lightbox]').lightBox({txtImage:"Zdjęcie", txtOf:"z"});
		        	$('#box').jScrollPane();
				    $("#u_date").datepicker($.extend({}, 
						$.datepicker.regional["pl"], { 
						    buttonImage: "s/images/calendar.gif"
					})); 
		    });
	     }
	});
}

var activemain=1;
var activesub=1;
function otherArt(main,sub){
	if(activemain!=0 && activesub!=0)
	$("#submenua"+activemain+"_"+activesub).css({'border-bottom': '0px'});
	$("#submenua"+main+"_"+sub).css({'border-bottom':'solid 2px', 'border-color':'#3196fe','padding':'0px'});
	activemain = main;
	activesub=sub;
	document.getElementById("box").innerHTML = '';
	$("#kreciol").css({'display':'block'});
	$.ajax({
	     type: "POST",
	     url: "other.php",
	     data: "d="+main+"&s="+sub,
	     cache: false,
	     success: function(html){
	     	$("#kreciol").css({'display':'none'});
			document.getElementById("box").innerHTML = html;
			document.getElementById('box').innerHTML = html;
			document.getElementById('box').style.padding="";
			document.getElementById('box').style.overflow="";
			document.getElementById('box').style.height="";
			document.getElementById('box').style.width="";
			document.getElementById('box').style.position="";	       
			$(function(){
					$('a[@rel*=lightbox]').lightBox({txtImage:"Zdjęcie", txtOf:"z"});
		        	$('#box').jScrollPane();
		        	
		        	$('#u_date').DatePicker({
						format:'d.m.Y',
						date: $('#u_date').val(),
						current: $('#u_date').val(),
						starts: 1,
						position: 'right',
						onBeforeShow: function(){
							$('#u_date').DatePickerSetDate($('#u_date').val(), true);
						},
						onChange: function(formated, dates){
							$('#u_date').val(formated);
						}
					});
		    });
		    
		    if(main!=2)
				document.getElementById('miniImg').innerHTML = ' ';
				document.getElementById('mapImg').style.display = 'none';



		if(main!=2)
			document.getElementById('miniImg').innerHTML = ' ';
			
			document.getElementById('mapImg').style.display = 'none';
			
		switch(main){
				case 1:
					switch(sub){
						case 1:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/m0552.jpg" />';
							break;
						case 2:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/m0552.jpg" />';
							break;
					}			
				break;
				case 2:
					switch(sub){
						case 1:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/twarz.jpg" />';
							break;
						case 2:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/cialo.jpg" />';
							break;
						case 3:
							document.getElementById('miniImg').innerHTML = '<img style="margin-left:70px;" src="i/oferta/masaze.jpg" />';
							break;
						case 4:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/pakiety_zabiegowe.jpg" />';
							break;
						case 5:
							document.getElementById('miniImg').innerHTML = '<img style="margin-left:70px;" src="i/oferta/m0658.jpg" />';
							break;
						case 6:
							//document.getElementById('miniImg').innerHTML = '<img src="i/oferta/default.jpg" />';
							document.getElementById('miniImg').innerHTML = '';
							break;					
						case 7:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/oferta_dla_firm.jpg" />';
							break;					
						case 8:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/promocje.jpg" />';
							break;		
						case 9:
							document.getElementById('miniImg').innerHTML = '<img src="i/oferta/ciaza.jpg" />';
							break;																	
					}
				break;
				case 6:
					document.getElementById('mapImg').style.display = '';
					GoogleMapinitialize();
				break;
			}
			      
				
	     }
	});
}


function showArt(main,sub,chapter){
	
	document.getElementById("box").innerHTML = '';
	//document.getElementById("boxP").innerHTML = '<div style="position: absolute; left: 375px; display: none;" id="kreciol"><img src="i/ajax-loader.gif"/></div><div id="box" style="padding:0px; width:600px;"> sss</div>';
	//alert(document.getElementById("box").style.width);
	
	//alert(document.getElementById("box").style.width);
	$("#kreciol").css({'display':'block'});
	$.ajax({
	     type: "POST",
	     url: "article.php",
	     data: "d="+main+"&s="+sub+"&c="+chapter,
	     cache: false,
	     success: function(html){
	     	$('#box').jScrollPane();
	     	$("#kreciol").css({'display':'none'});
			document.getElementById("box").innerHTML = html;
			document.getElementById('box').innerHTML = html;
			document.getElementById('box').style.padding="";
			document.getElementById('box').style.overflow="";
			document.getElementById('box').style.height="";
			document.getElementById('box').style.width="";
			document.getElementById('box').style.position="";	     
			if(main==3){
				document.getElementById('box').style.padding="0 0 0 42px";
				document.getElementById('box').style.width="770px";
			}  
			$(function(){
		        	
		        	
		        	$('a[@rel*=lightbox]').lightBox({txtImage:"Zdjęcie", txtOf:"z"});
		        	
				    $('#u_date').DatePicker({
						format:'d.m.Y',
						date: $('#u_date').val(),
						current: $('#u_date').val(),
						starts: 1,
						position: 'right',
						onBeforeShow: function(){
							$('#u_date').DatePickerSetDate($('#u_date').val(), true);
						},
						onChange: function(formated, dates){
							$('#u_date').val(formated);
						}
					});
					if(main!=2)
						{
							document.getElementById('miniImg').innerHTML = ' ';
							document.getElementById('mapImg').style.display = 'none';
						}
						
					if(main!=3)
					{	
						$('#box').jScrollPane();
					}
			
		    });
	     },
	     complete: function(){
	     	if(main==3){
		        		$('a[@rel*=lightbox]').lightBox({txtImage:"Zdjęcie", txtOf:"z"});
		        
			}
			else
				$('#box').jScrollPane();
					
			        	
	     }
	});
}

function verifyMail(id){
	adres=document.getElementById(id).value;
	var malpa=adres.indexOf('@');
	var kropka=adres.lastIndexOf('.');
	if (malpa<2 || malpa>kropka)
	{
		document.getElementById(id).style.backgroundColor="#ffff00";
		return 0;
	}
	else
	{
		document.getElementById(id).style.backgroundColor="#ffffff";
		return 1;
	}
}


function changeBg(sub){
	
	var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	
	var naw2=navigator.userAgent;
	
	var endorfinaObj = isInternetExplorer ? document.all.endorfina  : document.endorfina ;
	
	//if (naw2.indexOf("Safari")!=-1) endorfinaObj =document.all.endorfina;
	
	endorfinaObj.GotoFrame(sub);
	
}


function registerValidForm(){
	document.getElementById('r_loginError').innerHTML='';
	document.getElementById('r_mailError').innerHTML='';
	var isOk=1;
	name=document.getElementById('r_name').value;
	sname=document.getElementById('r_sname').value;
	login=document.getElementById('r_login').value;
	nameV = name.replace(/\s/g,'');
	document.getElementById('r_name').value = nameV;
	snameV = sname.replace(/\s/g,'');
	document.getElementById('r_sname').value = snameV;
	loginV = login.replace(/\s/g,'');
	document.getElementById('r_login').value = loginV;
	if(nameV=='') {
		document.getElementById('r_name').style.backgroundColor="#ffff00";
		isOk=0;
	}	
	else {
		document.getElementById('r_name').style.backgroundColor="#ffffff";
	}
	if(snameV=='')
	{
		document.getElementById('r_sname').style.backgroundColor="#ffff00";
		isOk=0;
	}	
	else
	{
		document.getElementById('r_sname').style.backgroundColor="#ffffff";
	}
	adres=document.getElementById('r_mail').value;
	var malpa=adres.indexOf('@');
	var kropka=adres.lastIndexOf('.');
	if (malpa<2 || malpa>kropka)
	{
		document.getElementById('r_mail').style.backgroundColor="#ffff00";
		document.getElementById('r_mailError').innerHTML = "niepoprawny adres email";
		isOk=0;
	}
	else
	{
		document.getElementById('r_mailError').innerHTML = "";
		document.getElementById('r_mail').style.backgroundColor="#ffffff";
	}
	if(loginV=='')
	{
		document.getElementById('r_login').style.backgroundColor="#ffff00";
		isOk=0;
	}	
	else
	{
		document.getElementById('r_login').style.backgroundColor="#ffffff";
	}
	if(document.getElementById('r_p1').value!=document.getElementById('r_p2').value || document.getElementById('r_p1').value=='' || document.getElementById('r_p2').value=='')
	{
		document.getElementById('r_p1').style.backgroundColor="#ffff00";
		document.getElementById('r_p2').style.backgroundColor="#ffff00";
		document.getElementById('r_pError').innerHTML="podane hasła nie zgadzają się";
		isOk=0;
	}
	else
	{
		document.getElementById('r_pError').innerHTML="";
		document.getElementById('r_p1').style.backgroundColor="#ffffff";
		document.getElementById('r_p2').style.backgroundColor="#ffffff";
	}
		
	return isOk;
}
function registerNewsletter(){
		
		var pars = $('#newsletterForm').serialize();
		$.ajax({
		    type: "POST",
		    url: "newsletter.php",
		    data: pars,
		    cache: false,
		     success: function(val){
		     	document.getElementById("newsletterInputText").value="OK";
		     }
		});
}



function registerMe(){
	if(registerValidForm())
	{
		document.getElementById('r_p1').style.backgroundColor="#ffffff";
		document.getElementById('r_p2').style.backgroundColor="#ffffff";
		document.getElementById('r_login').style.backgroundColor="#ffffff";
		document.getElementById('r_name').style.backgroundColor="#ffffff";
		document.getElementById('r_sname').style.backgroundColor="#ffffff";
		document.getElementById('r_mail').style.backgroundColor="#ffffff";
		var pars = $('#register').serialize();
		$.ajax({
		    type: "POST",
		    url: "register.php",
		    data: pars,
		    cache: false,
		     success: function(val){
			     if(val== 1) 
			     {
			     	document.getElementById('box').innerHTML = "Na podany przez Ciebie adres e-mail został wysłany mail z instrukcjami dotyczącymi aktywacji konta"; 
			     }
			     if(val=='-1')
			     {
			     	document.getElementById('r_login').style.backgroundColor="#ffff00";
			     	document.getElementById('r_loginError').innerHTML = 'wybrany login jest już zarejestrowany w systemie';
			     }
			     if(val=='-2')
			     {
			     	document.getElementById('r_mail').style.backgroundColor="#ffff00";
			     	document.getElementById('r_mailError').innerHTML = 'podany mail jest już zarejstrowany w systemie';
			     }
					       
				$(function(){
			        	$('#box').jScrollPane();
			    });
		     }
		});
	}	
}

function logMe(){
	var pars = $('#login').serialize();
	$.ajax({
		    type: "POST",
		    url: "login.php",
		    data: pars,
		    cache: false,
		     success: function(val){
			     if(val!=0) 
			     {
			     	document.getElementById('submenu4').innerHTML = val; 
			     	otherArt(4,3);
			     }
			     if(val=='0')
			     {
			     	alert("zle");
			     	document.getElementById('r_login').style.backgroundColor="#ffff00";
			     	document.getElementById('r_loginError').innerHTML = 'wybrany login jest już zarejestrowany w systemie';
			     }
				$(function(){
			        	$('#box').jScrollPane();
			    });
		     }
		});
}



function sendMessage(){
		var pars = $('#sendmsg').serialize();
		$.ajax({
		    type: "POST",
		    url: "sendMsg.php",
		    data: pars,
		    cache: false,
		     success: function(val){
			     if(val== '1') 
			     {
			     	document.getElementById('box').innerHTML = "<span style=\"font-size:12px;\">Dziękujemy za wiadomość. Rezerwację proszę uważać za dokonaną dopiero po naszym jej potwierdzeniu!</span>"; 
			     }
			     if(val=='2')
			     {
			     	document.getElementById('box').innerHTML = "<span style=\"font-size:12px;\">Dziękujemy za wiadomość.</span>";
			     }
			     	       
				$(function(){
			        	$('#box').jScrollPane();
			    });
		     }
		});
}	






/*
 * JS by Gedi
 * @author Gedi <gedi@freedots.com.pl>
 *
 * Comment modyfication:
 * Krzysztof Piwowar <kontakt@kpiwowar.com>
 *
 *	plik   = path to swf file
 *	wdth   = width in px
 *	hght   = height in px
 *	bgdn   = background color in hex: #RRGGBB, default #000000
 *	wmode  = render mode, default "window"
 *	qlty   = quality, default "high"
 *	idName = flash ID
 *	target = destination target (where we put swf file)
 *	fVars  = variables: FlashVars
 *	altImg = alternative image file, default it contain name of destination target ID and interation number of swf file :)  
 */
var nr = 0;
function createFlash(movie, wdth, hght, bgnd, wmode, qlty, idName, target, fVars, altImg)
{
	if (obj_setFlash = document.getElementById(target))
	{
		fVars = fVars.replace(/amp;/, '');
		idName = idName ? idName : target+"_flash"+(nr++);
		objTag = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+wdth+"' height='"+hght+"' id='"+idName+"'>";
		objTag2 = "<object data='"+movie+"' type='application/x-shockwave-flash' width='"+wdth+"' height='"+hght+"' id='"+idName+"'>";

		paramTag = "<param name='movie' value='"+movie+"'>"
		+"<param name='bgcolor' value='"+(bgnd ? bgnd : "#000000")+"'>"
		+"<param name='wmode' value='"+(wmode ? wmode : "window")+"'>"
		+"<param name='quality' value='"+(qlty ? qlty : "high")+"'>"
		+"<param name='scale' value='noscale'>"
		+"<param name='menu' value='false'>"
		+"<param name='allowScriptAccess' value='always'>"
		+"<param name='swliveconnect' value='true'>"
		+(fVars ? "<param name='FlashVars' value='"+fVars+(altImg ? "&altImg="+altImg : "")+"'>" : "")
		+(altImg ? "<img src='"+altImg+"' alt='"+idName+"' title=''>" : idName)
		+"</object>";

		if (typeof HTMLElement != "undefined")
		{
			if (topImage = document.getElementById('signImage')) obj_setFlash.removeChild(topImage);
			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", "bgcolor");
			par.setAttribute("value", bgnd ? bgnd : "#000000");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "wmode");
			par.setAttribute("value", wmode ? wmode : "window");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "quality");
			par.setAttribute("value", qlty ? qlty : "high");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "scale");
			par.setAttribute("value", "noscale");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "menu");
			par.setAttribute("value", "false");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "allowScriptAccess");
			par.setAttribute("value", "always");
			obj.appendChild(par);
			par = document.createElement("param");
			par.setAttribute("name", "swliveconnect");
			par.setAttribute("value", "true");
			obj.appendChild(par);
			if (fVars)
			{
				par = document.createElement("param");
				par.setAttribute("name", "FlashVars");
				par.setAttribute("value", fVars+(altImg ? "&altImg="+altImg : ""));
				obj.appendChild(par);
			}
			if (altImg)
			{
				par = document.createElement("img");
				par.setAttribute("src", altImg);
				par.setAttribute("alt", idName);
				par.setAttribute("title", "");
				obj.appendChild(par);
			}
			else
			{
				par = document.createTextNode(idName);
				obj.appendChild(par);
			}
			return obj_setFlash.appendChild(obj);
		}
		else if (document.all && !window.opera)
		{
			obj_setFlash.insertAdjacentHTML('beforeEnd',objTag+paramTag);
		}
		else
		{
			obj_setFlash.write(objTag+paramTag2);
		}
	}
}


var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function endorfina_DoFSCommand(command, args) {
	var endorfinaObj = isInternetExplorer ? document.all.endorfina  : document.endorfina ;
	
	endorfinaObj.SetVariable(command, arg);
}

var movieName = "endorfina";

function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName]
  } else {
    return document[movieName]
  }
}



// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub endorfina_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call endorfina_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

 function GoogleMapinitialize() 
 {
     var map = new GMap2(document.getElementById("mapImg"));
 	 var point = new GLatLng(50.06631,19.927199);
     map.setCenter(point, 16); 
     map.enableDragging();
     map.addControl(new GSmallMapControl);


function createMarker(point, number) {  
var marker = new GMarker(point);  
GEvent.addListener(marker, "click", function() {  
 marker.openInfoWindowHtml(number);});  
return marker;  
}  

	map.addOverlay(createMarker(point, 'Endorfina City SPA'));
//     GEvent.addListener(map, "click", getAddress);
//     geocoder = new GClientGeocoder();  
 }

