
var isNew = 0;
var isNS4 = 0;
var isIE4 = 0;  
var isIE=(document.all) ? true : false; 
var okno=null;

var brow = ((navigator.appName) + (parseInt(navigator.appVersion)));
if (parseInt(navigator.appVersion) >= 5) { isNew = 1; }
else if (brow == "Netscape4") { isNS4 = 1; }
  else if (brow=="Microsoft Internet Explorer4"){isIE4=1;}
if (isNS4 || isIE4 || isNew) {
  var docObj = (isNS4) ? 'document' : 'document.all';
  var styleObj = (isNS4) ? '' : '.style';
}


function select_miasto(m) {
	document.forms['select_miasto_form'].sklep_miasto.value=m;
	document.forms['select_miasto_form'].submit();
}




function okienko(w,h,nazwa) {
	if (okno) { 
 	  if (isIE4) okno.close(); 
 	  else if (isNS4) okno.closed; 
 	  okno=null 
 	}; 
	  okno=window.open(nazwa,'okno',"status=no,menubar=no,scrollbars=no,resizable=no, width="+w+", height="+h+", top=50,left=100");
}


function my_replace(str, find, rep)
{
    var res = str;
    var i = 0;
    while(true)
    {
        i = res.indexOf(find, i);
        if (i == -1) break;
        res = res.substr(0, i) + rep + res.substr(i + find.length);
        i += rep.length;
    }
    return res;
}


function zdjecie(w,h,nazwa,tytul,scrolling) {
	if (okno) { 
 	  if (isIE4) okno.close(); 
 	  else if (isNS4) okno.closed; 
 	  okno=null 
 	}; 
	  okno=window.open("",'okno',"status=no,menubar=no,scrollbars="+scrolling+",resizable=no, width="+w+", height="+h+", top=50,left=100");
	  okno.document.write("<html><head><meta http-equiv'=Content-type' charset='iso-8859-2' 'content=text/html; charset=iso-8859-2'><meta http-equiv='Pragma' content='no-cache'><title>"+tytul+"</title></head><body bgcolor='#FFFFFF' bottommargin='0' leftmargin='0' marginheight='0' marginwidth='0' rightmargin='0' topmargin='0'><img src='"+nazwa+"' width='"+w+"' height='"+h+"' alt='"+tytul+"'></body></html>");
	
}


function drukuj_kontakt(l1,l2,l3,print_mailto) {
	//alert(l1);
	//alert(l2);
	//alert(l3);
	
	if (l1==1) {l1='<a href="';}
	
	l2=my_replace(l2,'|||','@');
	l2=my_replace(l2,'###','.');
	l2=my_replace(l2,' ','');

	
	
	document.write(l1);
	if (print_mailto=='yes') {
   	document.write("ma");
   	document.write("i");
   	document.write("");
   	document.write("lt");
   	document.write("");
   	document.write("o");
   	document.write(":");
	}
	
	for (i=0;i<l2.length;i++) {
		document.write(l2.substr(i,1));
	}
	
	document.write(l3);
}


function wyczysc_pola_logowania(txt) {
	email_field=document.getElementById("newsletter_input");
	if (email_field.value==txt) {
		email_field.value="";
	}
}

function ustaw_pola_logowania(txt) {
	email_field=document.getElementById("newsletter_input");
	if (email_field.value=="") {
		email_field.value=txt;
	}
}


function loadGMap(i,n,x,y) {
	if (GBrowserIsCompatible()) {
		//podmień nazwy
		GMap_names();
		
		div=document.getElementById("gmaps_sklep_"+i);
		if (div.style.display=="block") {
			div.style.display="none";
			GUnload();
		}
		else {
			div.style.display="block";
	   	var map = new GMap2(div);
			
			//kontrolki
			map.addControl(new GSmallMapControl());
			map.addControl(new GScaleControl());
			map.addControl(new GMapTypeControl());
			
			//centruj
	   	map.setCenter(new GLatLng(x,y),15);
			
			
			var pos_icon = new GIcon();
			pos_icon.image = location.protocol+"//"+location.hostname+"/img/gmap_marker.png";
			pos_icon.shadow = location.protocol+"//"+location.hostname+"/img/gmap_marker_shadow.png";
			
			pos_icon.iconSize = new GSize(77, 54);
			pos_icon.shadowSize = new GSize(77, 54);
			pos_icon.iconAnchor = new GPoint(0, 54);
			
			load_gps(map,pos_icon);
			
			
		}
	}
}




function GMap_names () {
	G_NORMAL_MAP.getName = function(short) { 
       	if(short) {return "MAP"} 
       	return "Mapa"; 
     	}
	G_SATELLITE_MAP.getName = function(short) { 
       	if(short) {return "SAT"} 
       	return "Zdj. Sat."; 
     	} 
	G_HYBRID_MAP.getName = function(short) { 
       	if(short) {return "HYB"} 
       	return "Hybryda"; 
     	}
}



function load_gps(map,pos_icon) {
var http = getHTTPObject();
var pos,pos_x,pos_y;

	url=location.protocol+"//"+location.hostname+"/out/gps.php";
	http.open("GET",url,true);
	http.onreadystatechange = function() {
		if (http.readyState == 4) {
			var out_txt=new String(http.responseText);
			var gpss = out_txt.split('\n');
			var last=gpss[gpss.length-1];
			
			if (last=="OK") {
				for (var i=0;i<gpss.length-1;i++) {
					gps=gpss[i];
					pos=gps.split('|');
					pos_x=pos[0];
					pos_y=pos[1];
					
					var pos_point=new GLatLng(pos_x,pos_y);
					var marker = new GMarker(pos_point,pos_icon);
					map.addOverlay(marker);
				}
			}
			
			
			
			//alert(strResponseArray[0]);
			
			//alert(out_txt);
			/*
			var pos_point=new GLatLng(x,y);
			var marker = new GMarker(pos_point,pos_icon);
			map.addOverlay(marker);
			*/
		}
	}
	http.send(null);
}


function openSendToFriendWindow(lang, name, url){
  url = '/send_to_friend.php?lang=' + lang + '&name=' + name + '&link=' + url;
  return window.open(url, 'window', 'menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no,width=460, height=320');
}

