function nadaj() {
	el("wait","");
	var flip_flag=0;
	new_mirror_obj = new Array();
	img_obj = document.getElementsByTagName('IMG');
	for(a=0;a<img_obj.length;a++) {
		if ($(img_obj[a]).hasClass('no_mirror') || $(img_obj[a]).hasClass('reflect')) 	{
			new_mirror_obj.push(img_obj[a]);
		}	
	}
	//piotrek zbieranie obiektow
	if(!parent.top.old_img)	{
		parent.top.old_img = new Array();
	}
	for (a=0;a<new_mirror_obj.length;a++) {
		if($(new_mirror_obj[a]).hasClass('reflect'))	{
			new_mirror_obj[a].className =  'no_mirror';
		}	else	{	
			new_mirror_obj[a].className = 'reflect';
			flip_flag=1;
			parent.top.old_img.push(new_mirror_obj[a].src);
		}
	}
	var calosc = 0;
	if(flip_flag)
	{
		$('#wersja_pro').html('- wersja lustrzana -');
		$('.lustro').html('Wersja<br/>podstawowa');
		$('.lustro2').html('Wersja podstawowa tego projektu');

		
		for(a=0;a<img_obj.length;a++) {
			if ($(img_obj[a]).hasClass('no_mirror') || $(img_obj[a]).hasClass('reflect'))
			{
				if(rew_tab[$(img_obj[a]).parent().attr('id')])
				{
					var lustro = rew_tab[$(img_obj[a]).parent().attr('id')];
					$(img_obj[a]).attr('src',lustro);
					$(img_obj[a]).attr('original',lustro);
					$(img_obj[a]).addClass("thumb4");
					lustro = str_replace("_tmb1","",lustro);
					$(img_obj[a]).parent().attr('href',lustro);
					calosc = calosc + 1;
				}else{
					calosc = 0;
				}
			}
		}
		if(calosc == 0){
			$(".reflect").reflect({height: 1, opacity: 1});
		}

		
	}
	else
	{
		$('#wersja_pro').html('- wersja podstawowa -');
		$('.lustro').html('Wersja<br/>lustrzana');
		$('.lustro2').html('Odbicie lustrzane tego projektu');

		for(a=0;a<img_obj.length;a++) {
			if ($(img_obj[a]).hasClass('no_mirror') || $(img_obj[a]).hasClass('reflect'))
			{
				if(org_tab[$(img_obj[a]).parent().attr('id')])
				{
					var lustro = org_tab[$(img_obj[a]).parent().attr('id')];
					$(img_obj[a]).attr('src',lustro);
					$(img_obj[a]).attr('original',lustro);
					$(img_obj[a]).addClass("thumb4");
					lustro = str_replace("_tmb1","",lustro);
					$(img_obj[a]).parent().attr('href',lustro);
					calosc = calosc +1;
				}else{
					calosc = 0;
				}
			}
		}
		if(calosc==0){
			$(".reflected").unreflect();
		}
	}
	el("wait","none");
}
var Exp_Height=0;

var kategoria=0;

function str_replace(search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/str_replace    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   input by: Oleg Eremeev
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Oleg Eremeev
    // %          note 1: The count parameter must be passed as a string in order    // %          note 1:  to find a global variable in which the result will be given
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }
     for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}        }
    }
    return sa ? s : s[0];
}

function gtsp(id){get=document.getElementById(id); return get==null?false:get}
function el(id,dis){
    if(gtsp(id)) gtsp(id).style.display=dis
}
function el4(id) {el(id,(gtsp(id).style.display?'':'none'))}

function param(id) {if(gtsp(id)) {return (gtsp(id).innerHTML.indexOf('<param')!=-1 || gtsp(id).innerHTML.indexOf('<PARAM')!=-1 || gtsp(id).innerHTML.indexOf('<A')!=-1 || gtsp(id).innerHTML.indexOf('<a')!=-1);}}

function D22D(id){D2D('t'+id,'r'+id)}
function D2D(d1id,d2id){if(gtsp(d2id)){vtmp=gtsp(d1id).innerHTML;gtsp(d1id).innerHTML='';el(d2id,'none');gtsp(d2id).innerHTML=vtmp;ObjReplace(d2id);el(d2id,'');}}

function ObjReplace(id){var objs = document.getElementById(id).getElementsByTagName('object');
    for(i=0;i<objs.length;i++) objs[i].outerHTML=objs[i].outerHTML;
}    

function createCookie(name,value,days,domain) {
    if (days) {var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString()} else var expires = "";
    if(domain) var dom = "; domain="+domain; else var dom="";
    document.cookie = name+"="+value+expires+"; path=/"+dom;
}
function readCookie(name) {
    var nameEQ = name + "=";var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
	while (c.charAt(0)==' ') c = c.substring(1,c.length);
	    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name,domain) {if (domain) createCookie(name,"",-1,domain); else createCookie(name,"",-1);}
function zapal(id)        {
	gtsp(id).className="menu_gif_r on";
}
function zgas(id)        {
	gtsp(id).className="menu_gif_r off";
}
function movie_play() { 
	gtsp("movie").innerHTML=movie_html;
}

var klient = null;

searchBuffer = new Array()
wynik=1;

function zaawansowane(obj1,obj2) {
	$("#wysz_pr_bor").hide();
	zmien_zakladki("zak_2","zak_1");
	el('skype_cont','none');
	obj1.innerHTML="wyszukiwanie proste&raquo;";
	obj1.onclick=new Function("proste(this,gtsp('zaw2'))");
	
	//obj2.innerHTML="Wyszukiwanie proste";
	obj2.onclick=new Function("proste(gtsp('zaw1'),this)");
	gtsp('kontener_opis2_h').style.height='188px';
	el('project_box','none');
	el('kons_rek','none');
	el('szukaj_s','none');
	el('belkaTop','none');
	el('belkaBreak','none');
	//el('searchword_form','none');
	
	el('big_search_box','');
	el('mini_search_box','');
	el('mini_search_box2','');
	el('mini_search_box3','');
	gtsp('trafienia2').style.visibility='visible';
	
	
	//opacity('project_box', 100, 0, 300);
	//opacity('big_search_box', 0, 100, 300);
	//opacity('mini_search_box', 0, 100, 300);
	//opacity('mini_search_box2', 0, 100, 300);
	//opacity('mini_search_box3', 0, 100, 300);
	
	//wybrane_kryt();
	//el('info2','');
	//el('info1','none');
	
	if(typeof searchName=='undefined')
		realTimeSearch('bigFormZ','trafienia2','Pokaż projekty - znalezionych: ',1);
}
function proste(obj1,obj2) {
	$("#wysz_pr_bor").show();
	zmien_zakladki("zak_1","zak_2");
	obj1.innerHTML="wyszukiwanie zaawansowane&raquo;";
	obj1.onclick=new Function("zaawansowane(this,gtsp('zaw2'))");

	//obj2.innerHTML="Wyszukiwanie zaawansowane";
	obj2.onclick=new Function("zaawansowane(gtsp('zaw1'),this)");	
	gtsp('kontener_opis2_h').style.height='218px';
	el('big_search_box','none');
	el('mini_search_box','none');
	el('mini_search_box2','none');
	el('mini_search_box3','none');	
	gtsp('trafienia2').style.visibility='hidden';
	
	//gtsp('rog_lg_top').className="bgrog_lg";
	el('kons_rek','');
	el('szukaj_s','');
	el('belkaTop','');
	el('belkaBreak','');
	el('project_box','');
	//el('searchword_form','');	
	//opacity('project_box', 0, 100, 300);
	//opacity('big_search_box', 100, 0, 300);
	//opacity('mini_search_box', 100, 0, 300);
	//opacity('mini_search_box2', 100, 0, 300);
	//opacity('mini_search_box3', 100, 0, 300);
	//el('info2','none');
	
	//el('info1','');
}

function ajaxFunction(url,params,met,akcja,ret){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
		if (ajaxRequest.overrideMimeType) { 
            ajaxRequest.overrideMimeType('text/xml; charset=iso-8859-2'); 
		} 
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Twoja przeglďż˝darka zawiodďż˝a!");
				return false;
			}
		}
	}
	if(met=='post')	{
		ajaxRequest.open("POST", url, true);
	
		//Send the proper header information along with the request
		ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
		ajaxRequest.setRequestHeader("Content-length", params.length);
		ajaxRequest.setRequestHeader("Connection", "close"); 
	
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(ret)	{
				wynik=ajaxRequest.responseXML;
				eval(akcja);	
			}	else	{
				wynik=ajaxRequest.responseText;
				setTimeout('eval("'+akcja+'")',800);
			}
		}
	}
	if(met=='get')	{
		ajaxRequest.open("GET", url+'?'+params, true);
		ajaxRequest.send(null);
	}
	if(met=='post')	{
		ajaxRequest.send(params); 
	}
}
function file_exists (url) {
    // http://kevin.vanzonneveld.net
    // +   original by: Enrique Gonzalez
    // +      input by: Jani Hartikainen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %        note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain.
    // %        note 1: Synchronous so may lock up browser, mainly here for study purposes. 
    // *     example 1: file_exists('http://kevin.vanzonneveld.net/pj_test_supportfile_1.htm');
    // *     returns 1: '123'
    
    var req = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    if (!req) throw new Error('XMLHttpRequest not supported');
      
    // HEAD Results are usually shorter (faster) than GET
    req.open('HEAD', url, false);
    req.send(null);
    if (req.status == 200){
        return true;
    }
    
    return false;
}
function wybrane_kryt() {
	//gtsp('wybrane_kryteria_new').innerHTML='';
	var inp_tab=gtsp('bigFormZ').getElementsByTagName('INPUT');
	for(i=0;i<inp_tab.length;i++)	{
		if(inp_tab[i].type=='radio')	{
			if(inp_tab[i].checked==true) {
				gtsp('wybrane_kryteria_new').innerHTML=gtsp('wybrane_kryteria_new').innerHTML+'- '+inp_tab[i].title+'<br/>';
				inp_count++;
			}
		}	
		if(inp_tab[i].type=='checkbox')	{
			if(inp_tab[i].checked==true) {
				gtsp('wybrane_kryteria_new').innerHTML=gtsp('wybrane_kryteria_new').innerHTML+'- '+inp_tab[i].title+'<br/>';
				inp_count++;
			}
		}
	}
}

var wynik0tresc="\
Zwracamy uwagę na liczbę projektów.\n\
Ich liczba pokazuje się na przysiku\n\
>> Pokaż projekty <<, zawsze po kolejnym wyborze. \n\
Obecnie jest ich 0. \n";

/* NOWE LINKI*/
function initrealTimeSearch(obj_form,target_place,upstring)	{
	if(typeof tab_slg != 'undefined')	{
		var slogan=tab_slg[losuj(tab_slg.length-1)];
	}	else	{
		var slogan="Każdy projekt może być dostosowany do Twoich potrzeb!";
	}
	if(gtsp(obj_form))	{
// dopisek RL
		if(!real_query)
			var surl=document.location.search.substr(1,256).split('&');
		else	
			var surl=real_query.split('&');
		if (surl[0].length) {
			for(i=0;i<surl.length;i++) {
				var surl2=surl[i].split('=');
				a=gtsp(surl2[0]);
				if(a) {
					//if (a.type=='text') a.value=unescape(surl2[1]);
					if (a.type=='checkbox') a.checked=true;
					if (a.type=='radio') gtsp('cc_'+surl2[1]).checked=true;
				}
				//if(surl2[0]=='e_150') gtsp('cc_'+surl2[1]+'B').checked=true; // wyj?tek dla e_150
			}
		}
		var custom_cat_user=readCookie('custom_cat_user');
		var cat_string="";
		var inp_count = 0;
		if(custom_cat_user)	{	
			var full_cat_string="";
			custom_cat_user=custom_cat_user.split(",");
			for(var i in custom_cat_user)	{
				if(gtsp("cc_"+custom_cat_user[i]))	{
					full_cat_string+=","+gtsp('nazwa_'+custom_cat_user[i]).value;
					cat_string+="<a style='padding-left:33px;' href='"+location.protocol+"//"+location.host+"/"+gtsp('nazwa_'+custom_cat_user[i]).value+".html'>- "+gtsp('cc_'+custom_cat_user[i]).title+"</a><br />";
					inp_count++;
				}
			}
			cat_string="<a class='kulZ1' style='margin-left:10px' href='"+location.protocol+"//"+location.host+"/"+full_cat_string.substr(1)+".html'><strong>Ostatnio wybrane kryteria wyszukiwania</strong></a>"+cat_string;
		}
		//szukane słowo
		var save_word_user=decodeURIComponent(readCookie('save_word_user'));
		
		if(save_word_user!='null')	{
			var zm=encodeURI(save_word_user);
			zm=urlencode(zm);
			cat_string+="<a class='kulZ1' style='margin-left:10px;' href='"+location.protocol+"//"+location.host+"/wyszukiwanie,searchword_"+zm+".html'>Ostatnie szukane słowo: <strong>"+save_word_user+"</strong></a>";
			inp_count++;
		}
		if(cat_string && gtsp('wybrane_kryteria_new'))	{
			//cat_string+="<div style='height:7px;font-size:1px;line-height:1px;'>&nbsp;</div>";
			if(custom_cat_user)	{
				if(save_word_user!='null')	{
					//if(custom_cat_user.length<8)	{
					//	gtsp('info1').style.height="167px";
					//}
					if(custom_cat_user.length<3)	{
						cat_string+="<div id='info3'></div><div id='info2' style='margin-top:0px;'>"+slogan+"</div>";
					}
				}	else	{
					//if(custom_cat_user.length<9)	{
					//	gtsp('info1').style.height="167px";
					//}
					if(custom_cat_user.length<4)	{
						cat_string+="<div id='info3'></div><div id='info2' style='margin-top:0px;'>"+slogan+"</div>";
					}
				}
			}	else	{
				//gtsp('wybrane_kryteria_new').style.height="167px";
				cat_string+="<div id='info3'></div><div id='info2'>"+slogan+"</div>";
				
			}
			gtsp('wybrane_kryteria_new').innerHTML=cat_string
		}	else	{
			gtsp('kontener_opis2_h').innerHTML+="<div id='info3'></div><div id='info2' style='margin-top:25px;'>"+slogan+"</div>";
		}
		$("#info_loader").hide();
		$("#wybrane_kryteria_new").show();
		gtsp('info1').className="";
		
		
// \RL
		var f=gtsp(obj_form);
		var inp_tab=f.getElementsByTagName('INPUT');
		var sel_tab=f.getElementsByTagName('SELECT');
		if(upstring)	{
			for(i=0;i<inp_tab.length;i++)	{
				if(inp_tab[i].type=='text')	{
					inp_tab[i].onkeyup=new Function("realTimeSearchWithDelay('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}
				if(inp_tab[i].type=='checkbox')	{
					inp_tab[i].onmouseup=new Function("if(wynik==0&&!this.checked&&wynik0tresc)wynik0tresc=alert(wynik0tresc)");
					inp_tab[i].onclick=new Function("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}	
				if(inp_tab[i].type=='radio')	{
					inp_tab[i].onmouseup=new Function("if(wynik==0&&!this.checked&&wynik0tresc)wynik0tresc=alert(wynik0tresc);this.className=this.checked?'rdo_on':''");
					inp_tab[i].onclick=new Function("this.checked=(this.className=='rdo_on')?false:true; realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}	
			}	
			for(i=0;i<sel_tab.length;i++)	{
				sel_tab[i].onchange=new Function("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
			}
		}	else	{
			for(i=0;i<inp_tab.length;i++)	{
				if(inp_tab[i].type=='text')	{
					inp_tab[i].onkeyup=new Function("realTimeSearchWithDelay('"+obj_form+"','"+target_place+"')");
				}
				if(inp_tab[i].type=='checkbox')	{
					inp_tab[i].onclick=new Function("realTimeSearch('"+obj_form+"','"+target_place+"')");
				}	
				if(inp_tab[i].type=='radio')	{
					inp_tab[i].onclick=new Function("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}	
			}	
			for(i=0;i<sel_tab.length;i++)	{
				sel_tab[i].onchange=new Function("realTimeSearch('"+obj_form+"','"+target_place+"')");
			}
		}	
	}
	if(window.location.pathname.substr(0,11)=='/search.php')
		zmien_zakladki("zak_2","zak_1");
}
/*KONIEC NOWYCH LINKÓW*/

/* STARE
function initrealTimeSearch(obj_form,target_place,upstring)	{
	if(typeof tab_slg != 'undefined')	{
		var slogan=tab_slg[losuj(tab_slg.length-1)];
	}	else	{
		var slogan="Każdy projekt może być dostosowany do Twoich potrzeb!";
	}
	if(gtsp(obj_form))	{
// dopisek RL
		if(!real_query)
			var surl=document.location.search.substr(1,256).split('&');
		else	
			var surl=real_query.split('&');
		if (surl[0].length) {
			for(i=0;i<surl.length;i++) {
				var surl2=surl[i].split('=');
				a=gtsp(surl2[0]);
				if(a) {
					//if (a.type=='text') a.value=unescape(surl2[1]);
					if (a.type=='checkbox') a.checked=true;
					if (a.type=='radio') gtsp('cc_'+surl2[1]).checked=true;
				}
				//if(surl2[0]=='e_150') gtsp('cc_'+surl2[1]+'B').checked=true; // wyj?tek dla e_150
			}
		}
		var custom_cat_user=readCookie('custom_cat_user');
		var cat_string="";
		var inp_count = 0;
		if(custom_cat_user)	{	
			var full_cat_string="";
			custom_cat_user=custom_cat_user.split(",");
			for(var i in custom_cat_user)	{
				if(gtsp("cc_"+custom_cat_user[i]))	{
					full_cat_string+="&cc_"+custom_cat_user[i]+"="+custom_cat_user[i];
					cat_string+="<a style='padding-left:33px;' href='"+location.protocol+"//"+location.host+"/search.php?do_search=Search&cc_"+custom_cat_user[i]+"="+custom_cat_user[i]+"'>- "+gtsp('cc_'+custom_cat_user[i]).title+"</a><br />";
					inp_count++;
				}
			}
			cat_string="<a class='kulZ1' style='margin-left:10px' href='"+location.protocol+"//"+location.host+"/search.php?do_search=Search"+full_cat_string+"'><strong>Ostatnio wybrane kryteria wyszukiwania</strong></a>"+cat_string;
		}
		//szukane słowo
		var save_word_user=decodeURIComponent(readCookie('save_word_user'));
		
		if(save_word_user!='null')	{
			cat_string+="<a class='kulZ1' style='margin-left:10px;' href='"+location.protocol+"//"+location.host+"/search.php?do_search=Search&searchword="+save_word_user+"'>Ostatnie szukane słowo: <strong>"+save_word_user+"</strong></a>";
			inp_count++;
		}
		if(cat_string && gtsp('wybrane_kryteria_new'))	{
			//cat_string+="<div style='height:7px;font-size:1px;line-height:1px;'>&nbsp;</div>";
			if(custom_cat_user)	{
				if(save_word_user!='null')	{
					//if(custom_cat_user.length<8)	{
					//	gtsp('info1').style.height="167px";
					//}
					if(custom_cat_user.length<3)	{
						cat_string+="<div id='info3'></div><div id='info2' style='margin-top:0px;'>"+slogan+"</div>";
					}
				}	else	{
					//if(custom_cat_user.length<9)	{
					//	gtsp('info1').style.height="167px";
					//}
					if(custom_cat_user.length<4)	{
						cat_string+="<div id='info3'></div><div id='info2' style='margin-top:0px;'>"+slogan+"</div>";
					}
				}
			}	else	{
				//gtsp('wybrane_kryteria_new').style.height="167px";
				cat_string+="<div id='info3'></div><div id='info2'>"+slogan+"</div>";
				
			}

			gtsp('wybrane_kryteria_new').innerHTML=cat_string
		}	else	{
			gtsp('kontener_opis2_h').innerHTML+="<div id='info3'></div><div id='info2' style='margin-top:25px;'>"+slogan+"</div>";
		}
		$("#info_loader").hide();
		$("#wybrane_kryteria_new").show();
		//gtsp('info1').className="";
		
		
// \RL
		var f=gtsp(obj_form);
		var inp_tab=f.getElementsByTagName('INPUT');
		var sel_tab=f.getElementsByTagName('SELECT');
		if(upstring)	{
			for(i=0;i<inp_tab.length;i++)	{
				if(inp_tab[i].type=='text')	{
					inp_tab[i].onkeyup=new Function("realTimeSearchWithDelay('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}
				if(inp_tab[i].type=='checkbox')	{
					inp_tab[i].onmouseup=new Function("if(wynik==0&&!this.checked&&wynik0tresc)wynik0tresc=alert(wynik0tresc)");
					inp_tab[i].onclick=new Function("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}	
				if(inp_tab[i].type=='radio')	{
					inp_tab[i].onmouseup=new Function("if(wynik==0&&!this.checked&&wynik0tresc)wynik0tresc=alert(wynik0tresc);this.className=this.checked?'rdo_on':''");
					inp_tab[i].onclick=new Function("this.checked=(this.className=='rdo_on')?false:true; realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}	
			}	
			for(i=0;i<sel_tab.length;i++)	{
				sel_tab[i].onchange=new Function("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
			}
		}	else	{
			for(i=0;i<inp_tab.length;i++)	{
				if(inp_tab[i].type=='text')	{
					inp_tab[i].onkeyup=new Function("realTimeSearchWithDelay('"+obj_form+"','"+target_place+"')");
				}
				if(inp_tab[i].type=='checkbox')	{
					inp_tab[i].onclick=new Function("realTimeSearch('"+obj_form+"','"+target_place+"')");
				}	
				if(inp_tab[i].type=='radio')	{
					inp_tab[i].onclick=new Function("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')");
				}	
			}	
			for(i=0;i<sel_tab.length;i++)	{
				sel_tab[i].onchange=new Function("realTimeSearch('"+obj_form+"','"+target_place+"')");
			}
		}	
	}
	if(window.location.pathname.substr(0,11)=='/search.php')
		zmien_zakladki("zak_2","zak_1");
}

*/
function save_category(form_id)	{
	var inp_tab=gtsp(form_id).getElementsByTagName('INPUT');
	var cat_string="";
	var search_word="";
	for(var j in inp_tab)	{
		if((inp_tab[j].type=='radio'||inp_tab[j].type=='checkbox')&&inp_tab[j].checked==true)	{
			cat_string+=","+inp_tab[j].id.substr(3);
		}
	}
	cat_string=cat_string.substr(1);
	if(cat_string)
		createCookie('custom_cat_user',cat_string,30);
}
function save_word()	{
	var word=encodeURIComponent(gtsp('szukane_slowo_wyszuk_glowna').value);
	if(word)	{
		createCookie('save_word_user',word,30);	
	}
}
function realTimeSearch(obj_form,target_place,upstring,init)	{

	searchName = new Array();
	if(gtsp(target_place))
		gtsp(target_place).value="";
	if(gtsp(target_place+'2'))
		gtsp(target_place+'2').value="";
	if(!init)	{
		wk=gtsp('wybrane_kryteria_new');
		wk.innerHTML='';
		el('wybrane_kryteria_new','');
		//alert(gtsp('info1').offsetHeight);
		//gtsp('info1').style.height=(gtsp('info1').offsetHeight-2)+'px';
		
		//gtsp('info1').innerHTML='';
		el('load_progress','');
		el('load_progress2','');
		el('fix','');
	}	else	{
		wk=false;
	}
	var f=gtsp(obj_form);
	
	var inp_tab=f.getElementsByTagName('INPUT');
	var sel_tab=f.getElementsByTagName('SELECT');
	var search_string='';
	var empty_string='';
	full_cat_string="";
	cat_string="";
	var inp_count = 0;
	for(i=0;i<inp_tab.length;i++)	{
		if(inp_tab[i].type=='text' && inp_tab[i].value!='')	{
			search_string+='&'+inp_tab[i].name+'='+inp_tab[i].value;
		}
		if(inp_tab[i].type=='radio')	{
			if(inp_tab[i].checked==true) {
				search_string+='&'+inp_tab[i].name+'='+inp_tab[i].value;
				full_cat_string+="&cc_"+inp_tab[i].value+"="+inp_tab[i].value;
				cat_string+="<a style='padding-left:33px;' href='"+location.protocol+"//"+location.host+"/search.php?do_search=Search&cc_"+inp_tab[i].value+"="+inp_tab[i].value+"'>- "+gtsp('cc_'+inp_tab[i].value).title+"</a><br />";
				//wk.innerHTML=wk.innerHTML+'- '+inp_tab[i].title+'<br/>';
				searchName.push(inp_tab[i].name);
				inp_count++;
			}	else	{
				empty_string+='&ec_'+inp_tab[i].value+'='+inp_tab[i].value;
			}
		}	
		if(inp_tab[i].type=='checkbox')	{
			if(inp_tab[i].checked==true) {
				search_string+='&'+inp_tab[i].name+'='+inp_tab[i].value;
				full_cat_string+="&cc_"+inp_tab[i].value+"="+inp_tab[i].value;
				cat_string+="<a style='padding-left:33px;' href='"+location.protocol+"//"+location.host+"/search.php?do_search=Search&cc_"+inp_tab[i].value+"="+inp_tab[i].value+"'>- "+gtsp('cc_'+inp_tab[i].value).title+"</a><br />";
				//wk.innerHTML=wk.innerHTML+'- '+inp_tab[i].title+'<br/>';
				searchName.push(inp_tab[i].name);
				inp_count++;
			}	else	{
				empty_string+='&ec_'+inp_tab[i].value+'='+inp_tab[i].value;
			}
		}

//		if(inp_count == 3 && $("#kontener_opis2_h").hasClass("h91"))	{
//		$("#kategorie_more_link").html("ukryj wiďż˝cej&raquo;");		
//			$("#kontener_opis2_h").removeClass("h91");
//			$("#kontener_opis2_h").addClass("h197");
//			$("#search_help_content").css("top","460px");
//			$("#load_progress").css("top","219px");
//			$("#kategorie_more").slideToggle("slow");
//		}
	}	
	if(cat_string)	{
		$("#info2").remove();
		$("#info3").remove();
		cat_string="<a class='kulZ1' style='margin-left:10px' href='"+location.protocol+"//"+location.host+"/search.php?do_search=Search"+full_cat_string+"'><strong>Ostatnio wybrane kryteria wyszukiwania</strong></a>"+cat_string;
		wk.innerHTML=cat_string;
	}	
	for(i=0;i<sel_tab.length;i++)	{
		search_string+='&'+sel_tab[i].name+'='+sel_tab[i].options[sel_tab[i].selectedIndex].value;
	}
	search_string=search_string.substr(1);
	search_string+=empty_string;
	var search_url=location.protocol+'//'+location.host+'/realTimeSearch.php';
	if(init) {
		var akcja="do_result('"+target_place+"','"+upstring+"',wynik,1,'"+search_string+"')";
	} else	{
		var akcja="do_result('"+target_place+"','"+upstring+"',wynik,0,'"+search_string+"')";
	}	
	for(i=0;i<searchBuffer.length;i=i+2) {
		if(searchBuffer[i]==search_string) {
			wynik=searchBuffer[i+1];
			setTimeout('eval("'+akcja+'")',800);
			return true;
		}
	}
	//alert(search_url+'?'+search_string);
	ajaxFunction(search_url,search_string,'get',akcja);
}
var lastSearch=new Array();
function do_result(target_place,upstring,wynik,init,params)	{
	searchBuffer.push(params,wynik);
	if(wynik.length<=4 && wynik.indexOf(';')==-1) {
		gtsp(target_place).value=upstring+wynik;
		if(gtsp(target_place+'2')) 
			gtsp(target_place+'2').value=upstring+wynik;
	}	else if(wynik.indexOf(';')!=-1)	{ 
		wynik=wynik.split(';'); 
		empty_cat=wynik[1].split(','); 
		wynik=wynik[0]; 
		var tab_span=gtsp('bigFormZ').getElementsByTagName('SPAN');
		for(var k in tab_span)	{ 
			if(tab_span[k].id&&tab_span[k].id.substr(0,2)=='sp') 
				tab_span[k].style.color='black';
			if(tab_span[k].id&&tab_span[k].id.substr(0,2)=='sc')
				tab_span[k].innerHTML='';
		}
		var tab_inp_c=gtsp('bigFormZ').getElementsByTagName('INPUT');
		for(var k in tab_inp_c)	{
			tab_inp_c[k].disabled=false;
		} 
		if(!init)	{
			var actHistory=lastSearch;
			lastSearch=new Array();
		}
		for(i=0;i<empty_cat.length;i++)	{ 
			var tmp_cat=empty_cat[i].split('='); 
			var act_obj=gtsp('cc_'+tmp_cat[0].substr(3)); 
			var act_sum=gtsp('sc_'+tmp_cat[0].substr(3)); 
			var act_tit=gtsp('sp_'+tmp_cat[0].substr(3));  
			lastSearch[tmp_cat[0].substr(3)]=tmp_cat[1];
			if(act_sum) {
				if(tmp_cat[1]!='0')	{ 
					if(act_obj)	{ 
						if(act_obj.type=='radio')	{
							if(act_obj.checked==false)	{
								if(!init)	{
									var flag_name=1;
									for(var j in searchName)	{
										if(searchName[j]==act_obj.name)	{
											flag_name=0;
										}
									}
									
									if(flag_name)	{
										if(act_sum)
											act_sum.innerHTML='['+tmp_cat[1]+']';
									}	else	{
										if(searchName.length==1)	{
											if(act_obj.name==searchName[0])	{ 
												if(!actHistory[tmp_cat[0].substr(3)]||actHistory[tmp_cat[0].substr(3)]==0)	{
													act_obj.disabled=true;
													if(act_tit)
														act_tit.style.color='gray';
												}
											}										
										}	else if(searchName.length>1)	{
											if(act_obj.name==searchName[searchName.length-1])	{ 
												if(!actHistory[tmp_cat[0].substr(3)]||actHistory[tmp_cat[0].substr(3)]==0)	{
													act_obj.disabled=true;
													if(act_tit)
														act_tit.style.color='gray';
												}
											}		
										}	else	{
											act_obj.disabled=true;
											if(act_tit)
												act_tit.style.color='gray';
										}
									}		

								}	else	{
									if(act_sum)
										act_sum.innerHTML='['+tmp_cat[1]+']';
								}		
							}	
						}	else	{
							if(act_obj.checked==false)	{
								if(act_sum)
									act_sum.innerHTML='['+tmp_cat[1]+']';
							}
						}
					
					} 
				}	else	{  
					if(act_obj)	{ 
						if(act_obj.type=='radio')	{
							if(!init)	{
								if(searchName.length==1)	{
									if(act_obj.name!=searchName[0])	{ 
										act_obj.disabled=true;
										if(act_tit)
											act_tit.style.color='gray';
									}										
								}	else if(searchName.length>1)	{
									
									if(act_obj.name==searchName[searchName.length-1])	{ 
										if(!actHistory[tmp_cat[0].substr(3)]||actHistory[tmp_cat[0].substr(3)]==0)	{
											act_obj.disabled=true;
											if(act_tit)
												act_tit.style.color='gray';
										}
									}	else	{
										act_obj.disabled=true;
										if(act_tit)
											act_tit.style.color='gray';
									}		
								}	else	{
									act_obj.disabled=true;
									if(act_tit)
										act_tit.style.color='gray';
								}
							}		
						}	else	{
							if(act_obj.checked==false)	{
								act_obj.disabled=true;
								if(act_tit)
									act_tit.style.color='gray';	
							}	
						}
					
					}
				}	
			}
		} 
		gtsp(target_place).value=upstring+wynik;
		if(gtsp(target_place+'2')) 
			gtsp(target_place+'2').value=upstring+wynik;
	} 
	if(wynik=='0') 
		gtsp(target_place).disabled=true; 
	else 
		gtsp(target_place).disabled=false;
	if(wynik=='0' && gtsp(target_place+'2')) 
		gtsp(target_place+'2').disabled=true; 
	else 
		gtsp(target_place+'2').disabled=false;
		el('load_progress','none');
		el('load_progress2','none');
		el('fix','none');
}
function realTimeSearchWithDelay(obj_form,target_place,upstring)	{
	clearTimeout(parent.delayS);
	parent.delayS=setTimeout("realTimeSearch('"+obj_form+"','"+target_place+"','"+upstring+"')",1000);
}
window.onload=function()	{
	if(parent.top.ts && parent.top.token)	{
		gtsp('__elgg_ts').value=parent.top.ts;
		gtsp('__elgg_token').value=parent.top.token;	
		
		gtsp('username').disabled=false;
		gtsp('password').disabled=false;
	}
//	initrealTimeSearch('itemFormZ','trafienia');	
	initrealTimeSearch('bigFormZ','trafienia2','Pokaż projekty - znalezionych: ');
	//gtsp('wait_body').style.display="block";
//  wybrane_kryt();	
//zmiana wielkosci diva ulubione
	if(gtsp('div_ulubione_lista'))	{
		window.onresize=function()	{
			if(gtsp('legenda').style.display=="")	{
				if(navigator.appVersion.indexOf('MSIE')==-1)	{
					gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0])-284)+'px';
					gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0])-284)+'px';
				}	else	{
					gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0])-264)+'px';
					gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0])-264)+'px';
				}
				
			}	else	{
				if(navigator.appVersion.indexOf('MSIE')==-1)	{
					gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0])-20)+'px';
					gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0])-20)+'px';
				}	else	{
					gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0]))+'px';
					gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0]))+'px';
				}
			}
		}
	}
	//dla admina przeniesione 
	var admin_tab=gtsp("tabela_ramka");
	if(admin_tab)	{
		var tab_tabela=admin_tab.getElementsByTagName('TABLE');
		if(tab_tabela.length)	{
			blend_init(tab_tabela[0]);
		}	else	{
			blend_init(admin_tab);
		}
	}
}
function initCssCheck()	{
	var wynik=document.getElementsByTagName('STYLE')[0].innerHTML;
	preload_css(wynik);
}
function preload_css(css_t)	{
	css_t=css_t.replace(/\)/gi,'\n');
	reg=/tpl.*\.(gif|jpg)/gi;
	found=css_t.match(reg);
	parent.tmp_img = new Array();
	for(i=0;i<found.length;i++)	{
		if(found[i].length>3)	{
			parent.tmp_img[i]=new Image();
			parent.tmp_img[i].src=location.protocol+"//"+location.host+"/"+found[i];
		}
	}
	timer_out=10;
	check_css();
	
}
function check_css()	{
	timer_out--;
	if(!timer_out)	{
		gtsp('wait_body').style.display="block";
		return false;
	}	
	var flag_ok=1;
	for(i=0;i<parent.tmp_img.length;i++)	{
		if(!parent.tmp_img[i].complete)	{
			flag_ok=0;	break;	
		}	else	{
		}	
	}
	if(flag_ok)	{
		if(gtsp('wait_body'))
			gtsp('wait_body').style.display="block";
	}	else	{
		setTimeout('check_css()',200);
	}
}

var flag_grafiki=1;

function wysokosc()	{
	d=document;
	if (typeof window.innerWidth!='undefined') {
		var winWidth = window.innerWidth;
		var winHeight = window.innerHeight;
	} else {
		if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
			var winWidth = d.documentElement.clientWidth;
			var winHeight = d.documentElement.clientHeight;
		} else {
			if (d.body && typeof d.body.clientWidth!='undefined') {
				var winWidth = d.body.clientWidth;
				var winHeight = d.body.clientHeight;
			}
		}
	}
	return new Array(winWidth,winHeight);
}
parent.top.blend_array = new Array();
function init_ulubione() {
	$("#id_ulubione_cont").append("<iframe style='display:none' id='id_ulubione' name='na_ulubione' src='about:blank'></iframe>");
	if(navigator.appVersion.indexOf('MSIE')==-1)	{
		gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0])-20)+'px';
		gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0])-20)+'px';
	}	else	{
		gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0]))+'px';
		gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0]))+'px';
	}
	moje_ulubione=readCookie('ulubione');
	if(moje_ulubione!=null) {
		//dopis piotrka
		var tab_ulubione=moje_ulubione.split(",").length;	
		gtsp('slider').style.width=(tab_ulubione*132)+'px';
		gtsp('slider_contener').style.width=(tab_ulubione*132)+'px';
		//\piotrek
		styl4ie6();
		el("div_ulubione3","");el("div_ulubione",""); el("div_ulubione2",""); el("div_ulubione4","");
		gtsp('id_ulubione').src = "ulubione.php?id="+moje_ulubione;
	} else {
		 moje_ulubione="";
//			 el("zapamietaj_projekt","");
	}		
	if (readCookie('ulubione2')!=null && readCookie('ulubione')!=null) {
	pokaz_projekty()	
	}
}
function przepisz_ulubione(vtmp) {
//			gtsp('wait').style.height=document.body.offsetHeight+"px";
//			gtsp('progres').style.height=wysokosc()[1]+"px";
	gtsp('slider').innerHTML+=vtmp
	setTimeout('el("wait","none")',1000);
}
function dodaj_jeden(vtmp) {
	a="id_ul_"+vtmp;	
	if(gtsp(a)) {
	    b=gtsp(a).innerHTML+" ";
	    gtsp(a).innerHTML="<div style='width:122px'><br/>juďż˝ dodane<\/div>";
	    setTimeout('gtsp(a).innerHTML=b',1000);
	    return;
	}
//			gtsp('wait').style.height=document.body.offsetHeight+"px";
//			gtsp('progres').style.height=wysokosc()[1]+"px";
// dodanie do moj.dom.pl (ulubione) - patryk
		moj_ulubione(vtmp);
// patryk - koniec
		el("wait","");
		na_ulubione.location.replace("ulubione.php?id="+vtmp);
		moje_ulubione+=((moje_ulubione!="")?",":"")+vtmp;
		eraseCookie('ulubione');
		createCookie('ulubione',moje_ulubione,90)
		el("div_ulubione",""); el("div_ulubione2","");  el("div_ulubione3","");  el("div_ulubione4","");
		if(parseInt(gtsp('slider').style.width)==0)	{
			gtsp('slider').style.width='264px';
			gtsp('slider_contener').style.width='264px';
		}	else	{
			gtsp('slider').style.width=(parseInt(gtsp('slider').style.width)+132)+'px';
			gtsp('slider_contener').style.width=(parseInt(gtsp('slider_contener').style.width)+132)+'px';
		}
		styl4ie6();
}
function usun_ulubione(vtmp) {
	tablica_ulubione=readCookie('ulubione').split(",");
	eraseCookie('ulubione');				// usuwam wszystkier ulubione
	moje_ulubione="";
	tmp_array=new Array();		//tablica podswietlen
	for(a=0;a<tablica_ulubione.length;a++) {		// dodaje do zmiennej wcze?niej zapamietane
	    if(tablica_ulubione[a]==vtmp) continue;		// omijam przeznaczony do skasowania
	    moje_ulubione+=((moje_ulubione!="")?",":"")+tablica_ulubione[a];
		tmp_array.push(tablica_ulubione[a]);
	}
	parent.top.blend_array = tmp_array;
	el('id_ul_'+vtmp,'none');
	gtsp('id_ul_'+vtmp).id=null;
	gtsp('slider').style.width=(parseInt(gtsp('slider').style.width)-132)+'px';
	gtsp('slider_contener').style.width=(parseInt(gtsp('slider_contener').style.width)-132)+'px';
	if(moje_ulubione!="") {
	    createCookie('ulubione',moje_ulubione,90)
	} else {
	    el("div_ulubione","none"); el("div_ulubione2","none"); el("div_ulubione3","none");  el("div_ulubione4","none");
		gtsp('slider').style.width='0px';
		gtsp('slider_contener').style.width='0px';	
//			    el("zapamietaj_projekt","");
	}
}
function usun_wszystko()	{
	if(confirm("Czy na pewno chcesz usunďż˝ďż˝ wszystkie projekty ze schowka?"))	{
		eraseCookie('ulubione');
		gtsp("slider").innerHTML="";
		gtsp('slider').style.width='0px';
		gtsp('slider_contener').style.width='0px';
		parent.top.blend_array = new Array();
		el("div_ulubione","none"); el("div_ulubione2","none"); el("div_ulubione3","none");  el("div_ulubione4","none");
		el('highslide_back','none');
	}
}
function pokaz_projekty(obj) {
    el4('div_ulubione');
    el4('div_ulubione4');
    gtsp('div_ulubione3').blur()
    eraseCookie('ulubione2');
    if(gtsp('div_ulubione').style.display=="none") {
    	el("div_ulubione2","none");
    	createCookie('ulubione2',1,90);
    	ukryj_porownanie(gtsp('function_porownaj'));
    	gtsp('function_porownaj2').className="ukryj_pro_link";
    }	else	{
    	el("div_ulubione2","");
    	gtsp('function_porownaj2').className="pokaz_pro_link";
    }
}
function porownaj_projekty(obj)	{
	el('moj_domek','none');
	el('highslide_back','');
	el('div_ulubione','');
    el('div_ulubione4','');
    gtsp('div_ulubione3').blur()
    eraseCookie('ulubione2');
    el("div_ulubione2","");
    
	gtsp('div_ulubione3').style.bottom="485px";
	gtsp('div_ulubione').style.height="485px";
	gtsp('div_ulubione4').style.height="485px";
	gtsp('slider_contener').style.height="465px";
	gtsp('div_ulubione_lista').style.height="485px";
	gtsp('div_ulubione_lista_linie').style.height="485px";
	gtsp('div_ulubione_lista').style.marginLeft="132px";
	gtsp('div_ulubione_lista_linie').style.marginLeft="132px";
	if(navigator.appVersion.indexOf('MSIE')==-1)	{
		gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0])-284)+'px';
		gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0])-284)+'px';
	}	else	{
		gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0])-264)+'px';
		gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0])-264)+'px';
	}
	gtsp('div_ulubione4').className="ulubione_back_not_op";
	gtsp('legenda').style.display="";
	gtsp('legenda2').style.display="";
	obj.innerHTML="ukryj porďż˝wnanie";
	obj.onclick=new Function("ukryj_porownanie(this)");
	gtsp('function_porownaj2').className="pokaz_pro_link";
	//gtsp('function_porownaj2').onclick = new Function("ukryj_porownanie(gtsp('function_porownaj'))");
	var opisy = gtsp('slider').getElementsByTagName('DIV');
	for(i=0;i<opisy.length;i++)	{
		if(opisy[i].className=='kontener_opisu')	{
			opisy[i].style.visibility='visible';
		}
	}
}
function ukryj_porownanie(obj)	{
	var zalogowany_moj=readCookie('moj_logedin');
	if(!zalogowany_moj)
	{
		el('moj_domek','');
	}
	gtsp('highslide_back').style.display="none";
	gtsp('div_ulubione3').style.bottom="130px";
	gtsp('div_ulubione').style.height="130px";
	gtsp('div_ulubione4').style.height="130px";
	gtsp('slider_contener').style.height="100px";
	gtsp('div_ulubione_lista').style.height="130px";
	gtsp('div_ulubione_lista_linie').style.height="130px";
	gtsp('div_ulubione_lista').style.marginLeft="0px";
	gtsp('div_ulubione_lista_linie').style.marginLeft="0px";
	gtsp('div_ulubione_lista').style.width=(parseInt(wysokosc()[0]))+'px';
	gtsp('div_ulubione_lista_linie').style.width=(parseInt(wysokosc()[0]))+'px';
	gtsp('div_ulubione4').className="ulubione_back_op";
	gtsp('legenda').style.display="none";
	gtsp('legenda2').style.display="none";
	obj.innerHTML="porďż˝wnaj projekty";
	obj.onclick=new Function("porownaj_projekty(this)");

	//gtsp('function_porownaj2').className="pokaz_pro_link";
	//gtsp('function_porownaj2').onclick = new Function("porownaj_projekty(gtsp('function_porownaj'))");
	var opisy = gtsp('slider').getElementsByTagName('DIV');
	for(i=0;i<opisy.length;i++)	{
		if(opisy[i].className=='kontener_opisu')	{
			opisy[i].style.visibility='hidden';
		}
	}
}
function styl4ie6() {
	if(navigator.appVersion.indexOf('MSIE 6.0')==-1) return; 
	if(location.host.substr(0,3)=='ww2' || location.host.substr(0,3)=='ssl') return;
	a=document.getElementsByTagName('html');
	a[0].style.overflow='hidden';
	document.body.style.height='100%';
    document.body.style.overflow='hidden';
	document.body.style.margin='0';
	document.body.style.padding='0';
	
	gtsp('div4ie6').style.width='100%';
	gtsp('div4ie6').style.height='100%';
    gtsp('div4ie6').style.overflow='auto';

    gtsp('div_ulubione').style.position='absolute';
    gtsp('div_ulubione').style.overflow='hidden';		
    gtsp('div_ulubione4').style.position='absolute';
    gtsp('div_ulubione4').style.overflow='hidden';	
    	
    gtsp('div_ulubione3').style.position='absolute';
	
}
function scanAndSet(wiersz,klasa) {
	gtsp(wiersz).className=klasa;
	gtsp(wiersz+'_l_1').className=klasa.split("_")[0]+"_l";
	gtsp(wiersz+'_l_2').className=klasa.split("_")[0]+"_l";
}
function findPosX(obj) {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function init_podobne() {
	if(gtsp('podobne'))	{
		pod_a=gtsp('podobne').getElementsByTagName("IMG");
		for(i=0;i<pod_a.length;i++)	{
			pod_a[i].onmouseover = new Function("");
			pod_a[i].onmouseout = new Function("");
		}
	}
}

blokada=1;
b=0;

function init_pokazIMG() {
	a=document.getElementsByTagName("IMG");
	for(i=0;i<a.length;i++) {
		if((a[i].src.indexOf('tmb2.jpg')==-1 && a[i].src.indexOf('tmb2.gif')==-1) && (a[i].src.indexOf('tmb3.jpg')==-1 && a[i].src.indexOf('tmb3.gif')==-1)) continue;
		a[i].id='img_id_'+i;
		a[i].onmouseover = new Function('this.value=1; setTimeout("pokaz_img_tmp('+i+')",1900)')
		a[i].onmouseout  = new Function('this.value=0; setTimeout("pokaz_img_tmp('+i+')",1800)')
	}
	blokada=0;
}

function pokaz_img_tmp(a) {
	if(blokada) return;
	if(gtsp('img_id_'+a).value==1) {
		gtsp('ajloader').style.left=findPosX(gtsp('img_id_'+a))+53+"px";
		gtsp('ajloader').style.top=findPosY(gtsp('img_id_'+a))+34+"px";
		el('ajloader','');
		if(b!=a) {
			noweIMG = new Image();
			var ext = gtsp('img_id_'+a).src.substr(gtsp('img_id_'+a).src.length-3);
			if(file_exists(gtsp('img_id_'+a).src.substr(0,gtsp('img_id_'+a).src.length-5)+'1.'+ext))	{
				noweIMG.src = gtsp('img_id_'+a).src.substr(0,gtsp('img_id_'+a).src.length-5)+'1.'+ext;
			}	else if(file_exists(gtsp('img_id_'+a).src.substr(0,gtsp('img_id_'+a).src.length-9)+'.'+ext))	{
				noweIMG.src = gtsp('img_id_'+a).src.substr(0,gtsp('img_id_'+a).src.length-9)+'.'+ext;
			}
			if(noweIMG.src)	{
				gtsp('div_img_a').href="javascript:dodaj_jeden("+gtsp('img_id_'+a).parentNode.rel+")";
				czy_jest();
			}
		} else {
			b=a;
		}
	} else {
		b=0;
		el('div_img','none');
	}
}
function czy_jest() {
	if(noweIMG.complete) {
		gtsp('div_img_img').src=noweIMG.src;
		el('ajloader','none');
		el('div_img','')
	} else {
		setTimeout("czy_jest()",100);
	}
	
}

function init_CRM() {
	if(gtsp('edycja_off'))	{
		if(readCookie('crm_proj') && location.host=='projekty3.dom.pl')	{
			//gtsp('crm_frame').src='https://ssl.dom.pl/crm.php?act_proj='+ad_id;
			gtsp('edycja_frame').src='http://projekty3.dom.pl/edycja_projekt.php?ad_id='+ad_id
			gtsp('kategorie_frame').src='http://projekty3.dom.pl/kategorie_wlasne_projekt.php?ad_id='+ad_id;
			gtsp('edycja_off').style.display='';
			gtsp('custom_cat_off').style.display='';
			if(location.pathname=='/')	{
				eraseCookie('pyt_tab');
				//make_ask();
			}	
		}	else if(readCookie('crm_proj') && location.host!='projekty3.dom.pl')	{
			//window.location='http://projekty3.dom.pl/'+location.path;
		}	else	{
			gtsp('edycja_off').style.display='none';
			gtsp('edycja_on').style.display='none';
			gtsp('custom_cat_off').style.display='none';
			gtsp('custom_cat_on').style.display='none';
		}
	}
	//alert(readCookie('proj_id'));
	if(readCookie('crm_proj') && (location.host=='projekty3.dom.pl' || location.host=='ssl.dom.pl') && gtsp('old_zamow_div'))	{
		el('old_zamow_div','');
		gtsp('from_domain').disabled=false;
	}

	if(gtsp('jezyk_off'))	{
		if(ad_id > 0 && (readCookie('proj_id') == 179 || readCookie('proj_id') == 80 || readCookie('proj_id') == 95 || readCookie('proj_id') == 333))	{
			gtsp('jezyk_frame').src='edycja_jezyk.php?ad_id='+ad_id;
			gtsp('jezyk_off').style.display='';
		}	else	{
			gtsp('jezyk_off').style.display='none';
			gtsp('jezyk_on').style.display='none';
		}
	}
}

function init_reklama() {
	if(gtsp('t750x100sg'))	{
		if(param('t750x100sg'))	{
			divH=100; x=0;
			a=document.getElementById('t750x100sg');
			c=a.getElementsByTagName('*');
			while (c[x]) {
		    	if(parseInt(c[x].height)>99) {
					divH=parseInt(c[x].height); 
		    		break;
		    	}
		    	if(parseInt(c[x].style.height)>99) {
		       		divH=parseInt(c[x].style.height); 
		    		break;
		    	}
		    	x++;
			}
			if ((Exp_Height+1)>1) divH=Exp_Height;
		
			if(gtsp('r750x100sg'))	{
				gtsp('r750x100sg').style.height=divH+'px';	
				gtsp('r750x100sg').style.paddingTop='20px';
				if(gtsp('t750x100sg').innerHTML.indexOf('scrollTop')==-1)	{
					D22D('750x100sg');	
				}	else	{
					gtsp('r750x100').id="";
					var add_div=document.createElement('DIV');
					add_div.style.width='750px';
					add_div.id='r750x100';
					add_div.style.position='absolute';
					add_div.style.left='120px';
					add_div.style.top='-'+(divH+31)+'px';
					add_div.style.zIndex='100';
					add_div.style.height=divH+'px';
					gtsp('tresc_strony').appendChild(add_div);
					D22D('750x100sg');
				}	
			}
			if(divH==100) {
				gtsp('search_help_content2').style.top = '-182px';
			}
			if(divH==200) {
				gtsp('search_help_content2').style.top = '-282px';
			}
		}
	}
	if(gtsp('r300x250sg')&&param('t300x250sg'))	{
		if(gtsp('reklama_top'))
			el('reklama_top','');
		D22D('300x250sg');	
	}	
	if(gtsp('r300x250lp')&&param('t300x250lp'))	{
		if(gtsp('reklama_top'))
			el('reklama_top','');
		D22D('300x250lp');	
	}	
	if(gtsp('rlink_tekstowy')&&param('tlink_tekstowy'))	{
		gtsp('pink_cena').style.height='86px';
		gtsp('pink_cena_wew').style.height='86px';		
		D22D("link_tekstowy");
	}
}
function init_ostatnie()	{
	if(gtsp('ad_title'))	{
		var ost_ciacho="";
		ost_ciacho=encodeURIComponent(gtsp('ad_title').innerHTML)+"|"+location.pathname.substr(1);
		if(gtsp('ost_img'))	{
			ost_ciacho+="|"+gtsp('ost_img').src;
		}	else	{
			ost_ciacho+="|";
		}
		if(gtsp('pow_uzy'))	{
			ost_ciacho+="|"+gtsp('pow_uzy').innerHTML;
		}	else if(gtsp('pow_zab'))	{
			ost_ciacho+="|"+gtsp('pow_zab').innerHTML;
		}	else	{
			ost_ciacho+="|";
		}
		var dc=document.cookie.split(";");
		var new_ost = new Array();
		var new_ost_value = new Array(); 
		for(var i in dc)	{
			var tmp_ost=dc[i].split("=");
			if((tmp_ost[0].substr(0,5)==' ost_')&&(tmp_ost[0]!=(' ost_'+location.pathname.substr(1))))	{
				new_ost.push(tmp_ost[0].substr(1));
				new_ost_value.push(tmp_ost[1]);
			} 
		}
		if(new_ost.length>3)	{
			eraseCookie(new_ost[0]);
			new_ost.shift();
			new_ost_value.shift();
		}
		new_ost.push('ost_'+location.pathname.substr(1));
		new_ost_value.push(ost_ciacho);

		for(var i in new_ost)	{
			eraseCookie(new_ost[i]);
			createCookie(new_ost[i],new_ost_value[i],30);
		}
		
	}	else if(gtsp('ostatnie'))	{

		var dc=document.cookie.split(";");
		var new_ost = new Array();
		var new_ost_value = new Array(); 
		for(var i in dc)	{
			var tmp_ost=dc[i].split("=");
			
			if(tmp_ost[0].substr(0,5)==' ost_')	{
				new_ost.push(tmp_ost[0].substr(1));
				new_ost_value.push(tmp_ost[1]);
			} 
		}
		if(new_ost.length)	{
			var ulubione_in="";
			var counter=0;
			var pod_link = '';
			for(i=new_ost_value.length-1;i>=0;i--)	{
				var tmp_ost=new_ost_value[i].split("|");
				var tmp_anchor=decodeURIComponent(tmp_ost[0]);

				if((tmp_anchor+'...').length>=25)
				 {
					var tit=tmp_anchor.substr(0,20).replace(/\-/gi,'')+'...';
					var tit_tab = tit.split(' ');
					var title='';
					for(j=0;j<tit_tab.length;j++)
					 {
						if(tit_tab[j].length>=14){
							title=title+tit_tab[j].substr(0,11)+'...';
							break;
						}else
						{
							title=title+tit_tab[j]+' ';
						}
					 }

					tmp_anchor = title;
				 }

				pod_link+=',' + tmp_ost[1].substr(0,tmp_ost[1].length-4);
				ulubione_in+="<div class='tv_box1' style='left:"+(counter*169)+"px;top:0px;'> \
								<div class='tv_box2'> \
									<div class='tv_box2_1'></div> \
									<div class='tv_box2_2'></div> \
									<div class='tv_box2_3'></div> \
									<div class='tv_box2_4'></div> \
									<div class='tv_box2_5'></div> \
									<div class='tv_box2_6'></div> \
									<div class='tv_box2_7'></div> \
									<div class='tv_box2_8'></div> \
									<div class='tv_box2_9'></div> \
									<div class='tv_box2_10'></div> \
									<div class='tv_box2_11' align='center'> \
										<a href='/"+tmp_ost[1]+"' class='thumb'><img src='"+tmp_ost[2].replace(/_tmb1/i,'_tmb3').replace(/_tmb2/i,'_tmb3')+"' alt='"+decodeURIComponent(tmp_ost[0])+"' border='0' title='"+decodeURIComponent(tmp_ost[0])+" - Zobacz projekt' /></a> \
									</div> \
									<div class='tv_box2_12'> \
										<div class='opisDomek' align='right'> \
												<strong>"+tmp_ost[3].split(',')[0]+" m</strong><sup>2</sup> \
										</div> \
										<a href='/"+tmp_ost[1]+"'>"+(tmp_anchor.length>32 ? tmp_anchor.substr(0,32)+"..." : tmp_anchor)+"</a> \
									</div> \
								</div> \
							</div>";
			counter++;
			}
			
		gtsp('ostatnie').innerHTML=ulubione_in;
		el('ostatnie_title','');
		el('ostatnie','');
		pod_link=pod_link.substr(1);
		
		//nowa funkcja bo juz za duzo tutaj
		if(pod_link) {
			//set_pod(pod_link);
		}
		}
	}
	var last_search="";
	if(location.search&&location.search.substr(0,7)!='?gclid=' && location.pathname.substr(1,9)!='potwierdz' && location.pathname.substr(1,9)!='formularz')	{
		last_search=location.pathname+location.search;
	}
	if(location.pathname.substr(0,10)=='/projekty_' || location.pathname.substr(0,12)=='/na_dzialke_' || location.pathname.substr(0,14)=='/powierzchnia_')	{
		last_search=location.pathname;
	}
	if(last_search)	{
		var d= new Date();
		createCookie('last_search',d.getTime()+"|"+last_search,30);
	}
	var last_search=readCookie('last_search');
	if(last_search)	{
		last_search=last_search.split("|");
		var d= new Date();
		if((last_search[0]<(d.getTime()-120000)) && (gtsp('doc_link')))	{
			gtsp('doc_link').innerHTML="<a style='color:#B3021E;text-decoration:underline;' href='"+last_search[1]+"'>Ostatnio oglďż˝dana przez Ciebie, strona wyszukiwania - zobacz</a>"
		}
	}
}
function newCaptcha()	{
	var new_date= new Date();
	var new_image = new Image();
	//gtsp('captcha_img').src='catimages/load.gif';
	
	gtsp('captcha_img').src='captcha/captcha.php?'+new_date.getTime();
}
function init_cooliris()	{
	if (gtsp('cooliris') && PicLensLite.hasClient())	{
		el('cooliris','');
		if(gtsp('sciezka_naw'))
		{
			var dlugosc = parseInt($("#sciezka_naw").css('width'));
			$("#sciezka_naw").css('width',dlugosc-30);
		}

		$(".coolwidth").each(function(){
		var dl = parseInt($(this).css('width'));
		var val=0;
		if(gtsp('film'))
			val=14;
		$(this).css('width',dl+45+val);
			}
		);
	}
	if (gtsp('cooliris2') && PicLensLite.hasClient())	{
		el('cooliris2','');
	}
	
	
}
function getDaneZamow()	{
	var old_id=parseInt(gtsp('old_zamowienie_id').value.replace('/ /ig',''));
	if(readCookie('crm_proj') && old_id)	{
		el('ajax_zamow','');
		var search_url=location.protocol+"//"+location.host+"/get_zamow.php";
		var search_string="id_zamow="+old_id;
		var akcja="do_getDaneZamow(wynik)";
		//alert(search_url+'?'+search_string)
		ajaxFunction(search_url,search_string,'get',akcja,1);
	}
}
function do_getDaneZamow(wynik)	{
	var f=document.forms['form1'];
	//alert(wynik);
	var p=wynik.getElementsByTagName('projekt')[0];
	//alert(p.length);
	//alert(p.firstChild.next_sibling.data);
	if(parseInt(p.firstChild.firstChild.data)>0)	{
		f.odbicie[1].checked=true;
	}	else	{
		f.odbicie[0].checked=true;	
	}	
	f.imie_firma.value=p.firstChild.firstChild.data;
	f.nip.value=p.firstChild.nextSibling.firstChild.data;
	f.adres.value=p.firstChild.nextSibling.nextSibling.firstChild.data;
	f.kod_pocz.value=p.firstChild.nextSibling.nextSibling.nextSibling.firstChild.data;
	f.miasto.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
	f.tel.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
	f.tel_kom.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
	f.fax.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
	f.poczta.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;

	if(p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data)	{
		pokaz_dane();
		f.imie_firma_dost.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
		f.adr_dost.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
		f.miasto_dost.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
		f.kod_pocz_dost.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
	}
	f.tel_kom.value=p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data;
	var forma_radio=gtsp('forma_div').getElementsByTagName('INPUT');
	switch (p.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.data)	{
		case 'A' : forma_radio[0].checked=true; break;
		case 'B' : forma_radio[1].checked=true; break;
		case 'C' : forma_radio[2].checked=true; break;
		case 'D' : forma_radio[3].checked=true; break;
	}
	el('ajax_zamow','none');
}
/*Cooliris*/
/* PicLens Lite: version 1.3.1 (14221)
 * Copyright (c) 2008 Cooliris, Inc.  All Rights Reserved.
 * 
 * The JavaScript part of PicLens Lite (i.e., this file) is BSD licensed (see: http://lite.piclens.com/bsdlicense)
 * This launcher includes and interacts with SWFObject (MIT), BrowserDetect (BSD Compatible), and Lytebox (CC Attribution 3.0).
 * 
 * There are two versions of this JS: 
 * http://lite.piclens.com/current/piclens.js               full commented file         (~39KB)
 * http://lite.piclens.com/current/piclens_optimized.js     lighter deployment file     (~21KB)
 */
var PicLensLite={start:function(B){this.determineBrowserParams();clearTimeout(this.REMOVE_TIMER_ID);clearTimeout(this.AUTO_CLOSE_TIMER_ID);this.ARGS={};if(typeof B!=="undefined"&&B!==null){this.ARGS=B;if(B.feedUrl){this.THE_FEED_URL=B.feedUrl;if(this.checkForPluginAndLaunchIfPossible(B.feedUrl,B.guid)){return }if(B.loadFeedInFlash){this.showFlashUI("")}else{this.loadViaXHR(B.feedUrl)}}if(typeof B.feedData!=="undefined"){this.showFlashUI(B.feedData)}}else{var A=this.indexFeeds();if(A.length!==0){var C=A[0];this.THE_FEED_URL=C.url;if(this.checkForPluginAndLaunchIfPossible(C.url)){return }this.loadViaXHR(C.url)}}},isRunning:function(){return this.LITE_IS_RUNNING},hasClient:function(){return this.hasCooliris()},addCustomButton:function(C,B,A){this.CUSTOM_BUTTON={targetURL:C,labelText:B,iconImage:A}},setCallbacks:function(A){if(A.onNoPlugins){this.ON_NO_PLUGINS=A.onNoPlugins}if(A.onExit){this.ON_EXIT=A.onExit}},setLiteURLs:function(A){if(!this.LITE_URL){if(A.swf){this.LITE_URL=A.swf}else{if(A.lite){this.LITE_URL=A.lite+"PicLensLite.swf"}}}if(!this.BUTTON_URL){if(A.button){this.BUTTON_URL=A.button}else{if(A.lite){this.BUTTON_URL=A.lite+"NoFlash.jpg"}}}var B="";if(A.lbox){B=A.lbox}else{if(A.lite){B=A.lite+"../lytebox/"}}if(!this.LBOX_CSS_URL){if(A.lboxcss){this.LBOX_CSS_URL=A.lboxcss}else{if(B!=""){this.LBOX_CSS_URL=B+"lytebox.css"}}}if(!this.LBOX_JS_URL){if(A.lboxjs){this.LBOX_JS_URL=A.lboxjs}else{if(B!=""){this.LBOX_JS_URL=B+"lytebox.js"}}}},ARGS:{},DEBUG_NOCLIENT:false,DEBUG_NOFLASH:false,HPAD:60,VPAD:20,LITE_BG_DIV:null,LITE_FG_DIV:null,LITE_URL:null,BUTTON_URL:null,LBOX_CSS_URL:null,LBOX_JS_URL:null,LBOX_COUNT:0,SHOW_LBOX:false,OS_WIN:false,OS_MAC:false,BROWSER_FFX:false,BROWSER_SAF:false,BROWSER_IE:false,BROWSER_IE6:false,OLD_B_MARGIN:null,OLD_B_OVERFLOW:null,OLD_B_HEIGHT:null,OLD_H_OVERFLOW:null,OLD_H_HEIGHT:null,THE_FEED:"",THE_FEED_URL:"",LITE_IS_RUNNING:false,piclensIsRunning_:false,FLASH_ID_1:"pllflash1",FLASH_ID_2:"pllflash2",FLASH_VER:null,FLASH_URL:"http://www.adobe.com/go/getflashplayer",PL_URL:"http://download.piclens.com/partner/",PLC:null,LEARN_PL_URL:"http://affiliate.piclens.com/partner/",FONT:"font-family: Lucida Grande, Myriad Pro, Verdana, Helvetica, Arial, sans-serif;",KEY_HANDLERS:"",ON_NO_PLUGINS:null,ON_EXIT:null,AUTO_CLOSE_TIMER_ID:0,REMOVE_TIMER_ID:0,RESIZE_TIMER_IE6:null,RESIZE_HANDLER_EXISTS:false,CUSTOM_BUTTON:null,addKeyHandlers:function(){var A=this;if(typeof document.onkeydown!=="undefined"){this.KEY_HANDLERS=document.onkeydown}document.onkeydown=function(C){var B;if(typeof C==="undefined"||C===null){B=window.event.keyCode}else{B=C.which}var D=A.handleKeyPress(B);if(typeof C!="undefined"&&C!=null){C.returnValue=D}return D}},addMouseHandlers:function(){if(window.addEventListener){window.addEventListener("DOMMouseScroll",this.handleMouseWheel,false)}else{if(document.attachEvent){document.attachEvent("onmousewheel",this.handleMouseWheel)}}window.onmousewheel=document.onmousewheel=this.handleMouseWheel},appendElementsToDocument:function(){if(this.BROWSER_FFX&&this.OS_MAC){this.LITE_BG_DIV.style.display="none"}document.body.appendChild(this.LITE_BG_DIV);document.body.appendChild(this.LITE_FG_DIV)},autoResize:function(){if(!this.isRunning()){clearInterval(this.RESIZE_TIMER_IE6);return }var C=this.getPageSize();var B=this.LITE_BG_DIV;if(B){B.style.height=C.h+"px";B.style.width=C.w+"px"}if(this.LITE_FG_DIV){var A=this.LITE_FG_DIV.style;this.resizeToPaddedBox(A);this.resizeToFitPaddedBox(A,C);this.resizeFlashToFitPaddedBox()}},checkForPluginAndLaunchIfPossible:function(B,A){if(this.hasCooliris()){if(typeof (A)!="undefined"){this.PLC.launch(B,"uid",A)}else{this.PLC.launch(B,"","")}return true}return false},createBackgroundOverlay:function(){var D=document.createElement("div");this.LITE_BG_DIV=D;D.id="lite_bg_div";var E=D.style;E.position="fixed";E.width=E.height="100%";if(this.BROWSER_IE6){var A=document.body;var C=A.currentStyle;var H=document.documentElement;var G=H.currentStyle;this.OLD_B_MARGIN=C.margin;this.OLD_B_OVERFLOW=C.overflow;this.OLD_B_HEIGHT=C.height;this.OLD_H_OVERFLOW=G.overflow;this.OLD_H_HEIGHT=G.height;this.OLD_SCROLL_Y=H.scrollTop;A.style.margin="0";A.style.overflow="auto";A.style.height="100%";H.style.overflow="auto";H.style.height="100%";E.position="absolute";var F=this.getPageSize();E.height=F.h+"px";E.width=F.w+"px"}E.left=E.right=E.top=E.bottom="0";E.backgroundColor="#000";E.zIndex=1000;E.opacity="0.5";E.filter="alpha(opacity=50)";var B=this;D.onclick=function(){B.exitPicLensLite()}},createForegroundFlashComponent:function(){var B=document.createElement("div");this.LITE_FG_DIV=B;B.id="lite_fg_div";var A=B.style;A.backgroundColor="#000";A.position="fixed";A.border="2px solid #555";A.zIndex=1001;this.resizeToPaddedBox(A);if(this.BROWSER_IE6){A.position="absolute";this.resizeToFitPaddedBox(A)}},closeFlashUI:function(C){var B=document;B.onkeydown=this.KEY_HANDLERS;window.onmousewheel=B.onmousewheel="";if(window.removeEventListener){window.removeEventListener("DOMMouseScroll",this.handleMouseWheel,false)}if(B.detachEvent){B.detachEvent("onmousewheel",this.handleMouseWheel)}this.LITE_BG_DIV.style.display=this.LITE_FG_DIV.style.display="none";this.REMOVE_TIMER_ID=setTimeout(function(){PicLensLite.removeChildren()},150);if(this.BROWSER_IE6){var A=document.body;var D=document.documentElement;A.style.margin=this.OLD_B_MARGIN;A.style.overflow=this.OLD_B_OVERFLOW;A.style.height=this.OLD_B_HEIGHT;D.style.overflow=this.OLD_H_OVERFLOW;D.style.height=this.OLD_H_HEIGHT;window.scrollTo(0,this.OLD_SCROLL_Y)}if(this.ON_EXIT!==null){this.ON_EXIT(C)}this.setRunningFlag(false)},determineBrowserParams:function(){var B=BrowserDetect.OS;var A=BrowserDetect.browser;this.OS_MAC=(B=="Mac");this.OS_WIN=(B=="Windows");this.BROWSER_FFX=(A=="Firefox");this.BROWSER_SAF=(A=="Safari");this.BROWSER_IE=(A=="Explorer");this.BROWSER_IE6=(this.BROWSER_IE&&BrowserDetect.version=="6");this.FLASH_VER=swfobjlite.getFlashPlayerVersion()},exitPicLensLite:function(){var A=this.getFlash();if(A!==null&&A.fl_exitPicLensLite){A.fl_exitPicLensLite();this.AUTO_CLOSE_TIMER_ID=setTimeout(function(){if(PicLensLite.isRunning()){PicLensLite.closeFlashUI()}},500)}else{this.closeFlashUI()}},findScriptLocation:function(){var E=document.getElementsByTagName("script");for(var C=0;C!=E.length;++C){var A=E[C];var D=A.getAttribute("type");if(D=="text/javascript"){var F=A.getAttribute("src");if(F===null){continue}var B=F.indexOf("piclens.js");if(B!=-1){this.setLiteURLs({lite:F.substring(0,B)});return }else{B=F.indexOf("piclens_optimized.js");if(B!=-1){this.setLiteURLs({lite:F.substring(0,B)});return }}}}},getPageSize:function(){var J,F,G,C;var I=document;var E=I.body;var D;if(window.innerHeight&&window.scrollMaxY){J=I.scrollWidth;F=(this.isFrame?parent.innerHeight:self.innerHeight)+(this.isFrame?parent.scrollMaxY:self.scrollMaxY)}else{if(E.scrollHeight>E.offsetHeight){J=E.scrollWidth;F=E.scrollHeight}else{D=I.getElementsByTagName("html").item(0);J=D.offsetWidth;F=D.offsetHeight;J=(J<E.offsetWidth)?E.offsetWidth:J;F=(F<E.offsetHeight)?E.offsetHeight:F}}var A=I.documentElement;if(self.innerHeight){G=(this.isFrame)?parent.innerWidth:self.innerWidth;C=(this.isFrame)?parent.innerHeight:self.innerHeight}else{if(A&&A.clientHeight){G=A.clientWidth;C=A.clientHeight}else{if(E){D=I.getElementsByTagName("html").item(0);G=D.clientWidth;C=D.clientHeight;G=(G==0)?E.clientWidth:G;C=(C==0)?E.clientHeight:C}}}var B=(F<C)?C:F;var H=(J<G)?G:J;return{pw:H,ph:B,w:G,h:C}},getElementsFromXMLFeed:function(){var B;if(window.ActiveXObject){B=new ActiveXObject("Microsoft.XMLDOM");B.async=false;B.loadXML(PicLensLite.THE_FEED)}else{var C=new DOMParser();B=C.parseFromString(PicLensLite.THE_FEED,"text/xml")}var A=B.getElementsByTagName("*");return A},getBasicSlideShowHTML:function(){if(!this.LBOX_JS_URL||!this.LBOX_CSS_URL){return""}var D=document.getElementsByTagName("head").item(0);var A=document.createElement("script");A.src=this.LBOX_JS_URL;A.type="text/javascript";D.appendChild(A);var G=document.createElement("link");G.rel="stylesheet";G.href=this.LBOX_CSS_URL;G.type="text/css";G.media="screen";D.appendChild(G);var F=this.getElementsFromXMLFeed();var C;var H="";for(C=0;C<F.length;C++){if(F[C].nodeName=="media:content"){var B=F[C].getAttribute("url");if(B.indexOf(".flv")==-1){H+='<a id="lboxImage" href="'+B+'" rel="lytebox[lite]"></a> '}}}var E="<div id='lightbox_images' align='center' style='display: none; padding-top:10px; color:#FFFFFF; font-size:.8em; "+this.FONT+" color:#999999;'>";E+='( Alternatively, <a onclick="javascript:PicLensLite.invokeLytebox();return false;" href="#" style="color:#656588">click here for a basic slideshow</a>. )';E+=H;E+="</div><br/>";return E},generateAlternativeContent:function(){var J='<div id="altContent" style="text-align:center; margin: 0 0 0 0; padding: 0 0 0 0; background-color: #000; min-width:860px;">';J+='<div align="center" style="width: 100%; padding-top:60px; '+this.FONT+'">';var I=this.FLASH_VER;var G;if(I.major>0){G="update your Flash Player from version "+I.major+"."+I.minor+"."+I.release+" to version 9.0.28 or newer"}else{G="install the most recent Flash Player"}var D="";if(this.THE_FEED!==""){D=this.getBasicSlideShowHTML()}var A=this.PL_URL;var E=this.LEARN_PL_URL;var F=this.ARGS.pid;if(F){A+=F+"/";E+=F+"/"}else{var H="000000000001/";A+=H;E+=H}if(this.SHOW_LBOX){}else{var C="<span style='padding-left:25px; color:#C6C6C6; font-size:";J+="<div style='padding:10px;'>"+C+"1.5em; font-weight: bold; "+this.FONT+"'>You're clicks away from going full screen!</span><br/>"+C+".9em; padding-bottom: 15px; "+this.FONT+"'>You must get the <a href='"+A+"' style='color:#656588'>Cooliris</a> browser plugin, or "+G+".</span></div>";if(!this.BUTTON_URL){J+='<a href="'+A+'" style="color:#ACD">Get Cooliris Now!</a>'}else{var B='<area shape="rect" coords=';J+='<img src="'+this.BUTTON_URL+'" alt="" border="0" usemap="#Map"><map name="Map" id="Map">'+B+'"0,0,33,33" href="#" onclick="javascript:PicLensLite.closeFlashUI();" />'+B+'"35,35,325,325" href="'+A+'" />'+B+'"593,209,825,301" href="'+this.FLASH_URL+'" />'+B+'"327,148,448,178" href="'+E+'" /></map>'}}J+="</div>";J+=D;J+='<div align="center" style="color:#666666; font-size:11px; '+this.FONT+'">&copy; 2008 Cooliris, Inc. All trademarks are property of their respective holders.<br/><br/><br/></div>';J+="</div>";return J},generateFlashVars:function(){var C="";var B=this.ARGS;if(typeof B.guid!=="undefined"){C+="&startItemGUID="+B.guid}if(B.loadFeedInFlash){C+="&feedURL="+encodeURIComponent(this.THE_FEED_URL)}if(B.paused){C+="&paused="+B.paused}if(B.loop){C+="&loop="+B.loop}if(B.delay){C+="&delay="+B.delay}if(B.pid){C+="&pid="+B.pid}if(typeof B.maxScale!="undefined"){C+="&maxScale="+B.maxScale}if(typeof B.overlayToolbars!="undefined"){C+="&overlayToolbars="+B.overlayToolbars}var A=this.CUSTOM_BUTTON;if(A!=null){C+="&cButtonURL="+encodeURIComponent(A.targetURL);if(A.labelText!=null){C+="&cButtonLabel="+encodeURIComponent(A.labelText)}if(A.iconImage!=null){C+="&cButtonIcon="+encodeURIComponent(A.iconImage)}}C+="&swfURL="+encodeURIComponent(this.LITE_URL);C=C.substring(1);return C},getFlash:function(){if(this.BROWSER_SAF||this.BROWSER_IE){return document.getElementById(this.FLASH_ID_1)}else{return document.getElementById(this.FLASH_ID_2)}},getWindowSize:function(){var B=document.documentElement;var D=document.body;var A=0,C=0;if(typeof (window.innerWidth)=="number"){A=window.innerWidth;C=window.innerHeight}else{if(B&&(B.clientWidth||B.clientHeight)){A=B.clientWidth;C=B.clientHeight}else{if(D&&(D.clientWidth||D.clientHeight)){A=D.clientWidth;C=D.clientHeight}}}return{w:A,h:C}},handleKeyPress:function(A){if(!this.isRunning()){return true}var B=this.getFlash();if(B!=null&&B.fl_keyPressed){B.fl_keyPressed(A)}else{if(A==27){this.closeFlashUI();return false}}if(A==9||A==13){return false}return true},handleMouseWheel:function(A){var C=0;if(!A){A=window.event}if(A.wheelDelta){C=A.wheelDelta/120;if(window.opera){C=-C}}else{if(A.detail){var B=A.detail;if(Math.abs(B)<3){C=-B}else{C=-B/3}}}if(C){PicLensLite.sendMouseScrollToFlash(C)}if(A.preventDefault){A.preventDefault()}A.returnValue=false;return false},hasPicLensClient:function(){return this.hasCooliris()},hasCooliris:function(){if(this.DEBUG_NOCLIENT){return false}var E=false;if(this.PLC){E=true}else{if(window.piclens&&window.piclens.launch){this.PLC=window.piclens;E=true}else{var B=null;if(typeof PicLensContext!="undefined"){B=new PicLensContext()}else{try{B=new ActiveXObject("PicLens.Context")}catch(D){if(navigator.mimeTypes["application/x-cooliris"]){B=document.createElement("object");B.style.display="none";B.width=0;B.height=0;B.type="application/x-cooliris";document.documentElement.appendChild(B)}else{B=null}}}this.PLC=B;if(this.PLC){E=true}}}if(E){if(this.BROWSER_SAF){return true}var A;try{A=this.PLC.version}catch(D){return false}var C=A.split(".");if(C[0]>1){return true}else{if(C[0]==1){if(C[1]>6){return true}else{if(C[1]==6){if(C[2]>0){return true}else{if(C[2]==0){if(C[3]>=824){return true}}}}}}}return false}else{return false}},invokeLytebox:function(){this.SHOW_LBOX=true;myLytebox.start(document.getElementById("lboxImage"),false,false);this.closeFlashUI()},showLyteboxLink:function(){myLytebox.updateLyteboxItems();myLytebox.doAnimations=false;var A=document.getElementById("lightbox_images");if(A!=null){A.style.display="block";if(this.SHOW_LBOX&&this.getFlash()==null){this.invokeLytebox()}}},startLytebox:function(){if(typeof myLytebox!="undefined"){this.showLyteboxLink()}else{if(typeof initLytebox!="undefined"){initLytebox();this.showLyteboxLink()}else{if(this.LBOX_COUNT>=4){return }setTimeout(function(){PicLensLite.startLytebox()},150);this.LBOX_COUNT++}}},injectFlashPlayer:function(){var A=this.LITE_FG_DIV;var D;var F;D=F="100%";if(this.BROWSER_IE6){D=F="0"}var E=this.generateFlashVars();var B=this.generateAlternativeContent();if(this.meetsReqs()){var C="<param name=";A.innerHTML='<object id="'+this.FLASH_ID_1+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%">'+C+'"movie" value="'+this.LITE_URL+'" />'+C+'"quality" value="high"/> '+C+'"bgcolor" value="#000000"/> '+C+'"allowScriptAccess" value="always"/> '+C+'"FlashVars" value="'+E+'"/> '+C+'"allowFullScreen" value="true"/> '+C+'"wmode" value="window"/> '+C+'"scale" value="noscale"/> <object type="application/x-shockwave-flash" data="'+this.LITE_URL+'" width="'+D+'" height="'+F+'" quality="high" bgcolor="#000000" id="'+this.FLASH_ID_2+'" quality="high" FlashVars="'+E+'" allowFullScreen="true" scale="noscale" wmode="window" allowScriptAccess="always">'+B+"</object></object>"}else{if(this.ON_NO_PLUGINS){this.ON_NO_PLUGINS()}else{A.innerHTML=B;A.style.minWidth="860px";A.style.minHeight="550px"}}if(this.BROWSER_SAF){this.resizeUI()}},indexFeeds:function(){var E=document.getElementsByTagName("link");var A=[];for(var B=0;B!=E.length;++B){var D=E[B],C=D.getAttribute("type");if(C=="application/rss+xml"||C=="text/xml"){A.push({title:D.getAttribute("title"),url:D.getAttribute("href")})}}return A},loadViaXHR:function(B){var A=this;var D=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("MSXML2.XMLHTTP.3.0");try{D.open("GET",B,true);D.onreadystatechange=function(){if(D.readyState==4){if((D.status==200||D.status==0)){if(D.responseText){A.showFlashUI(D.responseText)}}else{if(console){console.log("PicLens Lite could not load the RSS Feed: "+B)}}}};D.send("")}catch(C){this.ARGS.loadFeedInFlash=true;this.showFlashUI("")}},meetsReqs:function(){if(this.DEBUG_NOFLASH){return false}var B=(this.FLASH_VER.major==0)&&this.BROWSER_IE;var A=swfobjlite.hasFlashPlayerVersion("9.0.28");return A||B},removeChildren:function(){this.REMOVE_TIMER_ID=0;if(this.LITE_BG_DIV!==null){document.body.removeChild(this.LITE_BG_DIV);this.LITE_BG_DIV=null}if(this.LITE_FG_DIV!==null){document.body.removeChild(this.LITE_FG_DIV);this.LITE_FG_DIV=null}},resizeFlashToFitPaddedBox:function(){var B=this.getFlash();if(B){var C=this.getPageSize();var A=C.w-this.HPAD*2;var D=C.h-this.VPAD*2;B.style.width=A;B.style.height=D;B.width=A;B.height=D}},resizeToFitPaddedBox:function(B,A){if(typeof A=="undefined"){A=this.getPageSize()}B.width=(A.w-this.HPAD*2)+"px";B.height=(A.h-this.VPAD*2)+"px"},resizeToPaddedBox:function(A){A.left=A.right=this.HPAD+"px";A.top=A.bottom=this.VPAD+"px"},resizeUI:function(){if(this.LITE_FG_DIV){var A=this.LITE_FG_DIV.style;this.resizeToPaddedBox(A);this.resizeToFitPaddedBox(A);this.resizeFlashToFitPaddedBox()}},setRunningFlag:function(A){this.LITE_IS_RUNNING=A;this.piclensIsRunning_=A},setResizeHandler:function(){if(!this.RESIZE_HANDLER_EXISTS&&this.BROWSER_SAF){var A=this;window.addEventListener("resize",function(){A.resizeUI()},false);this.RESIZE_HANDLER_EXISTS=true}},setResizeTimer:function(){if(this.BROWSER_IE6){this.RESIZE_TIMER_IE6=setInterval(function(){PicLensLite.autoResize()},1000)}},showFlashUI:function(A){this.THE_FEED=A;this.findScriptLocation();this.createBackgroundOverlay();this.createForegroundFlashComponent();if(this.BROWSER_IE){this.appendElementsToDocument()}this.injectFlashPlayer();if(!this.BROWSER_IE){this.appendElementsToDocument()}this.addKeyHandlers();this.addMouseHandlers();this.setRunningFlag(true);this.setResizeTimer();this.setResizeHandler();this.startLytebox()},sendMouseScrollToFlash:function(B){if(!this.isRunning()){return }var A=this.getFlash();if(A!=null&&A.fl_mouseMoved){A.fl_mouseMoved(B)}}};var swfobjlite=function(){var UNDEF="undefined",OBJECT="object",SHOCKWAVE_FLASH="Shockwave Flash",SHOCKWAVE_FLASH_AX="ShockwaveFlash.ShockwaveFlash",win=window,doc=document,nav=navigator;var ua=function(){var w3cdom=typeof doc.getElementById!=UNDEF&&typeof doc.getElementsByTagName!=UNDEF&&typeof doc.createElement!=UNDEF&&typeof doc.appendChild!=UNDEF&&typeof doc.replaceChild!=UNDEF&&typeof doc.removeChild!=UNDEF&&typeof doc.cloneNode!=UNDEF,playerVersion=[0,0,0],d=null;if(typeof nav.plugins!=UNDEF&&typeof nav.plugins[SHOCKWAVE_FLASH]==OBJECT){d=nav.plugins[SHOCKWAVE_FLASH].description;if(d){d=d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");playerVersion[0]=parseInt(d.replace(/^(.*)\..*$/,"$1"),10);playerVersion[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/,"$1"),10);playerVersion[2]=/r/.test(d)?parseInt(d.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof win.ActiveXObject!=UNDEF){var a=null,fp6Crash=false;try{a=new ActiveXObject(SHOCKWAVE_FLASH_AX+".7")}catch(e){try{a=new ActiveXObject(SHOCKWAVE_FLASH_AX+".6");playerVersion=[6,0,21];a.AllowScriptAccess="always"}catch(e){if(playerVersion[0]==6){fp6Crash=true}}if(!fp6Crash){try{a=new ActiveXObject(SHOCKWAVE_FLASH_AX)}catch(e){}}}if(!fp6Crash&&a){try{d=a.GetVariable("$version");if(d){d=d.split(" ")[1].split(",");playerVersion=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)]}}catch(e){}}}}var u=nav.userAgent.toLowerCase(),p=nav.platform.toLowerCase(),webkit=/webkit/.test(u)?parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,ie=false,windows=p?/win/.test(p):/win/.test(u),mac=p?/mac/.test(p):/mac/.test(u);
/*@cc_on
			ie = true;
			@if (@_win32)
				windows = true;
			@elif (@_mac)
				mac = true;
			@end
		@*/
return{w3cdom:w3cdom,pv:playerVersion,webkit:webkit,ie:ie,win:windows,mac:mac}}();return{hasFlashPlayerVersion:function(rv){var pv=ua.pv,v=rv.split(".");v[0]=parseInt(v[0],10);v[1]=parseInt(v[1],10);v[2]=parseInt(v[2],10);return(pv[0]>v[0]||(pv[0]==v[0]&&pv[1]>v[1])||(pv[0]==v[0]&&pv[1]==v[1]&&pv[2]>=v[2]))?true:false},getFlashPlayerVersion:function(){return{major:ua.pv[0],minor:ua.pv[1],release:ua.pv[2]}}}}();var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"Unknown Browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"Unknown Version";this.OS=this.searchString(this.dataOS)||"Unknown OS"},searchString:function(D){for(var A=0;A<D.length;A++){var B=D[A].string;var C=D[A].prop;this.versionSearchString=D[A].versionSearch||D[A].identity;if(B){if(B.indexOf(D[A].subString)!=-1){return D[A].identity}}else{if(C){return D[A].identity}}}},searchVersion:function(B){var A=B.indexOf(this.versionSearchString);if(A==-1){return }return parseFloat(B.substring(A+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();
/*Skype*/
var activex = ((navigator.userAgent.indexOf('Win')  != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
var CantDetect = ((navigator.userAgent.indexOf('Safari')  != -1) || (navigator.userAgent.indexOf('Opera')  != -1));

function oopsPopup() {
    if((navigator.language && navigator.language.indexOf("ja") != -1) || (navigator.systemLanguage && navigator.systemLanguage.indexOf("ja") != -1) || (navigator.userLanguage && navigator.userLanguage.indexOf("ja") != -1)) {
        var URLtoOpen = "http://download.skype.com/share/skypebuttons/oops/oops_ja.html";
    } else {
        var URLtoOpen = "http://download.skype.com/share/skypebuttons/oops/oops.html";
    }
	var windowName = "oops";
	var popW = 540, popH = 305;
	var scrollB = 'no';
	w = screen.availWidth;
	h = screen.availHeight;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	oopswindow = window.open(URLtoOpen, windowName,'width=' + popW + ',height=' + popH + ',scrollbars=' + scrollB + ',screenx=' +leftPos +',screeny=' +topPos +',top=' +topPos +',left=' +leftPos);
	return false;
}

if(typeof(detected) == "undefined" && activex) {
    document.write(
        ['<script language="VBscript">',
        'Function isSkypeInstalled()',
        'on error resume next',
        'Set oSkype = CreateObject("Skype.Detection")',
        'isSkypeInstalled = IsObject(oSkype)',
        'Set oSkype = nothing',
        'End Function',
        '</script>'].join("\n")
    );
}

function skypeCheck() {
    if(CantDetect) {
        return true;
    } else if(!activex) {
        var skypeMime = navigator.mimeTypes["application/x-skype"];
        detected = true;
        if(typeof(skypeMime) == "object") {
            return true;
        } else {
            //return oopsPopup();
            return false;
        }
    } else {
        if(isSkypeInstalled()) {
            detected = true;
            return true;
        }
    }
    
    detected = true;
    //return oopsPopup();
    return false;
}

function loadDetection() {
    if(document.getElementById && document.getElementsByTagName) {
        if (window.addEventListener) window.addEventListener('load', addDetection, false);
        else if (window.attachEvent) window.attachEvent('onload', addDetection);
    }
}

function addDetection() {
    var pageLinks = document.getElementsByTagName("a");
    for (var i=0; i < pageLinks.length; i++) {
        if(pageLinks[i].childNodes[0] && pageLinks[i].childNodes[0].src) {
            if((pageLinks[i].childNodes[0].src.indexOf('download.skype.com\/share\/skypebuttons') != -1 || pageLinks[i].childNodes[0].src.indexOf('mystatus.skype.com') != -1) && (typeof(pageLinks[i].onclick) == "undefined" || pageLinks[i].onclick == null)) {
                pageLinks[i].onclick = function sChk() { return skypeCheck(); }
            }
        }
    }
}

loadDetection();

function moj_zapal(ob0,ob1,ob2,ob3,ob4,ob5) {
	if(ob0.checked==true){
		gtsp(ob1).style.visibility='hidden';
		gtsp(ob2).style.visibility='hidden';
		gtsp(ob3).style.display='';
		gtsp(ob4).style.display='none';
		gtsp(ob5).style.display='none';
	}else{
		gtsp(ob1).style.visibility='';
		gtsp(ob2).style.visibility='';
		gtsp(ob3).style.display='none';
		gtsp(ob4).style.display='';
		gtsp(ob5).style.display='';
	}
}
function urlencode(str) {
str = (str+'').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/\'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}
$(document).ready(function(){
	


/*NOWE LINKI*/
	$("#searchword_form").submit(function()	{
		$("#searchword_form").attr("method", "post");
		
		var str=$("#szukane_slowo_wyszuk_glowna").val();
		//alert(encodeURI(str));
		var zm=encodeURI(str);
		zm=urlencode(zm);
		//alert(zm);
		//return false
		$("#searchword_form").attr("action", "wyszukiwanie,searchword_"+zm+".html");
		//return false;
	});	

	$("#searchword_form_top").submit(function()	{
		$("#searchword_form_top").attr("method", "post");
		var tab_poz=$("#searchword_form_top input");
		var i=0;
		for(i=0;i < tab_poz.length;i++)
		{
			if($(tab_poz[i]).attr('type')=='text')
			{
				var str=$(tab_poz[i]).val();
			}
		}
		var zm=encodeURI(str);
		zm=urlencode(zm);
		$("#searchword_form_top").attr("action", "wyszukiwanie,searchword_"+zm+".html");
	});	

	$("#bigFormZ").submit(function()	{
		
		//alert("Wył?czono");
		var tab_poz=$("#bigFormZ input");
		var i=0;
		var str_cat="";
		for(i=0;i < tab_poz.length;i++)
		{
			if($(tab_poz[i]).attr('type')=='radio' && $(tab_poz[i]).attr('checked') == true)
			{
				var nazwa_id=$(tab_poz[i]).attr('id');
				nazwa_id=nazwa_id.replace(/cc/g, 'nazwa');
				var cat=$("#"+nazwa_id).val();
				str_cat=str_cat+","+cat;
			}
		}
		//alert(str_cat);
		$("#bigFormZ").attr("method", "post");
		$("#bigFormZ").attr("action", "wyszukiwanie"+str_cat+".html");

	});	


/*NOWE LINKI KONIEC*/




	$("#search_help_input_s").keyup(function()	{
		search_help_delay_s(this);
	});	
	parent.top.search_help_active=0;
	$("#search_help_input_s").blur(function()	{
		var value = jQuery.trim(this.value);
		clearTimeout(parent.top.search_help_time);
		if(value.length)	{
			//alert(parent.top.search_help_active);	
			if(!parent.top.search_help_active)	{
				$("#search_help_content_s").html("");
				$("#search_help_content_s").hide();	
			}
		}	else	{
			this.value='Szukany tekst...';
		}
	});

	if(gtsp("show_skype"))	{
		if(skypeCheck())	{
			$("#show_skype").attr('style', 'display:block;');
		}
		$("#show_skype").mouseover(function(){
			  $("#skype_cont").slideToggle("slow");
			  $(this).toggleClass("active");
		});
	}	
	if(readCookie("moj_logedin") == 1)	{
		if ($("#div_moj").length > 0) {
			$("#div_moj").load("/get_menu.php", {}, function(){
				$('#search_help_content2').css('top', '-92px');
				$('#link_moj').attr('href', 'http://moj.dom.pl/' + readCookie('moj_logedin_username') + '/');
				TB_init();
			});
		}
	}
	parent.top.search_help_active=0;
	parent.top.search_help_active2=0;
	$("#szukane_slowo_wyszuk_glowna").keyup(function()	{
		search_help_delay("#szukane_slowo_wyszuk_glowna","#search_help_content");
	});
	$("#szukane_slowo_wyszuk_glowna").blur(function()	{
		var value = jQuery.trim(this.value);
		clearTimeout(parent.top.search_help_time);
		if(value.length)	{
			//alert(parent.top.search_help_active);	
			if(!parent.top.search_help_active)	{
				$("#search_help_content").html("");
				$("#search_help_content").hide();
			}
		}	else	{
			this.value='Szukany tekst...';
		}
	});
	$("#search_help_input").keyup(function()	{
		search_help_delay("#search_help_input","#search_help_content2");
	});	
	$("#search_help_input").blur(function()	{
		var value = jQuery.trim(this.value);
		clearTimeout(parent.top.search_help_time2);
		if(value.length)	{
			//alert(parent.top.search_help_active2);	
			if(!parent.top.search_help_active2)	{
				$("#search_help_content2").html("");
				$("#search_help_content2").hide();	
			}
		}	else	{
			this.value='Szukany tekst...';
		}
	});
	$("#zak_1").click(function(){
		zmien_zakladki("zak_1","zak_2");
	});
	$("#zak_2").click(function(){
		zmien_zakladki("zak_2","zak_1");
	});
	/*
	$("#kategorie_more_link").toggle(
	function(){
		$(this).html("ukryj wiďż˝cej&raquo;");		
		$("#kontener_opis2_h").removeClass("h91");
		$("#kontener_opis2_h").addClass("h197");
		$("#search_help_content").css("top","460px");
		$("#load_progress").css("top","219px");
	},
	function(){
		$(this).html("pokaďż˝ wiďż˝cej&raquo;");
		$("#kontener_opis2_h").removeClass("h197");
		$("#kontener_opis2_h").addClass("h91");
		$("#search_help_content").css("top","355px");
		$("#load_progress").css("top","114px");
	}	
	);
	$("#kategorie_more_link").click(function(){
		$("#kategorie_more").slideToggle("slow");
	});
	*/
	//podpowiadacz
	init_podpowiadacz();
	if (location.search == '?test=1') {
		init_sugestia();
	}	
});
function zmien_zakladki(act_id,deact_id)	{		
	$("#" + act_id).removeClass('zak_off');
	$("#" + act_id).addClass('zak_on');
	$("#" + deact_id).removeClass('zak_on');
	$("#" + deact_id).addClass('zak_off');
//	if(act_id == 'zak_2')
//		$("#kontener_opis2_h").css("height","256px");
//	else
//		$("#kontener_opis2_h").css("height","216px");
	$("#kontener_opis" + deact_id.split("_")[1]).hide();
	$("#kontener_opis" + act_id.split("_")[1]).show();
}
$(function() {                  
	if(gtsp("ad_title"))	{
		$("a.highslide > img, img.user").lazyload({
			placeholder : "../tpl/dom2/graf/ajax.gif",
			effect      : "fadeIn"
		});
	}
	if(gtsp("show_skype"))	{
		$("a.highslide > img, a.thumb > img, img.thumbnail, img.user").lazyload({
			placeholder : "../tpl/dom2/graf/ajax.gif",
			effect      : "fadeIn"
		});
	}
});

function losuj(n)
{
  return ( Math.floor ( Math.random ( ) * n) );
}
/*moj.dom.pl*/
function moj_buduje(ad_id)	{
	el("wait","");
	var search_url=location.protocol+"//"+location.host+"/moj_buduje.php";
	var search_string="ad_id="+ad_id;
	var akcja="do_moj_buduje(wynik)";
	//alert(search_url+'?'+search_string)
	ajaxFunction(search_url,search_string,'get',akcja);
}
function do_moj_buduje(kom)	{
	var zalogowany_moj=readCookie('moj_logedin');
	if(zalogowany_moj)	{
		el("wait","none");
		if(kom==1)	{
			alert("Zapisano budowďż˝ domu!");
		}	else	{
			alert("Bďż˝ďż˝d zapisu. Sprďż˝buj jeszcze raz!");
		}
	//  zwrotka ze ok
	//	var search_url="http://moj.dom.pl/moj_buduje.php";
	//	var search_string=kom;
	//	var akcja="do_moj_buduje_ok(wynik)";
		//alert(search_url+'?'+search_string)
	//	ajaxFunction(search_url,search_string,'get',akcja);
	}	else	{
		//alert(kom);
		window.location="http://moj.dom.pl/user_home.php?"+kom;	
	}
	
}

/* moj.dom.pl - ulubione */
function moj_ulubione(ad_id) {
	el("wait","");
	var search_url=location.protocol+"//"+location.host+"/moj_ulubione.php";
	var search_string="ad_id="+ad_id;
	var akcja="do_moj_ulubione(wynik)";
	ajaxFunction(search_url,search_string,'get',akcja);
}

function do_moj_ulubione(kom)	{
	var zalogowany_moj=readCookie('moj_logedin');
	if(zalogowany_moj)	{
		el("wait","none");
		if(kom==1)	{
			alert("Zapisano do ulubionych!");
		}	else	{
			alert("Bďż˝ďż˝d zapisu. Sprďż˝buj jeszcze raz!");
		}
	}	else	{
		el('moj_domek','');	
	}
	
}
/*dopisane z moj.dom.pl*/

TB_WIDTH = 0;
TB_HEIGHT = 0;

var TB_doneOnce = 0;
var TB_ready = false;
var TB_useReady = true;


// add smoothbox to href elements that have a class of .smoothbox
function TB_init()
{
  TB_ready = true;
	$("a.smoothbox").each(function(el){el.onclick=TB_bind});
}

//window.addEvent('domready', TB_init);
//window.addEvent('load', TB_init);



function TB_bind(event)
{
  if( TB_useReady && !TB_ready ) return;
  
	var event = new Event(event);
	// stop default behaviour
	event.preventDefault();
	// remove click border
	this.blur();
	// get caption: either title or name attribute
	var caption = this.title || this.name || "";
	// get rel attribute for image groups
	var group = this.rel || false;
	// display the box for the elements href
	TB_show(caption, this.href, group);
    this.onclick = TB_bind;
    return false;
}

// called when the user clicks on a smoothbox link
function TB_show(caption, url, rel, loading, disable_close)
{
  if( TB_useReady && !TB_ready ) return;
  
  // set default closing mechanism
  if(!disable_close) { disable_close = 0; }

  // create iframe, overlay and box if non-existent
  if (!$("#TB_overlay").length)
  {
  	if($('#smoothbox_container').length)
    	$(document.createElement('div')).attr('id', 'TB_overlay').appendTo($('#smoothbox_container'));
    else
    	$(document.createElement('div')).attr('id', 'TB_overlay').appendTo(document.body);
    $('#TB_overlay').css('opacity','0.6');
    TB_overlaySize();
  }

  if (!$("#TB_window").length)
  {
  	if($('#smoothbox_container').length)
    	$(document.createElement('div')).attr('id', 'TB_window').appendTo($('#smoothbox_container'));
    else
    	$(document.createElement('div')).attr('id', 'TB_window').appendTo(document.body);
    $('#TB_window').css('display','none');
  	
  }
  else 
  {
    $('#TB_window').remove(); //$('TB_window').dispose();
   	if($('#smoothbox_container').length)
    	$(document.createElement('div')).attr('id', 'TB_window').appendTo($('#smoothbox_container'));
    else
    	$(document.createElement('div')).attr('id', 'TB_window').appendTo(document.body);
    //$('#TB_window').css('opacity','0');
  }
 
  if(disable_close == 0) { $("#TB_overlay").click( function () { TB_remove()}); } else { $("#TB_overlay").click(); }
  window.onscroll = TB_position;
 
  // check if a query string is involved
  var baseURL = url.match(/(.+)?/)[1] || url;
  
  // CODE TO SHOW IFRAME
  var queryString = url.match(/\?(.+)/)[1];
  var params = TB_parseQuery(queryString);

  TB_WIDTH = (params['width'] * 1) + 30;
  TB_HEIGHT = (params['height'] * 1) + 40;
  
  var ajaxContentW = TB_WIDTH - 30, ajaxContentH = TB_HEIGHT - 45;
  
  
  if (url.indexOf('TB_iframe') != -1)
  {
    urlNoQuery = url.split('TB_');
    $("#TB_window").html($("#TB_window").html() + "<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + caption + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>X</a></div></div><iframe frameborder='0' hspace='0' src='" + urlNoQuery[0] + "&in_smoothbox=true' id='TB_iframeContent' name='TB_iframeContent' scrolling='auto' style='width:" + (ajaxContentW + 29) + "px;height:" + (ajaxContentH + 17) + "px;' onload='TB_showWindow()'> </iframe>");
  }
  else
  {
    $("#TB_window").html($("#TB_window").html() + "<div id='TB_title'><div id='TB_ajaxWindowTitle'>" + caption + "</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>X</a></div></div><div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px;'></div>");
  }
  
  $("#TB_closeWindowButton").click(function () {TB_remove()});

  if (url.indexOf('TB_inline') != -1)
  {
    $("#TB_ajaxContent").html($(params['inlineId']).html());
    TB_position();
    TB_showWindow();
  }
  else if (url.indexOf('TB_iframe') != -1)
  {
    //alert("UHOH1");
    TB_position();
    if (frames['TB_iframeContent'] == undefined) {//be nice to safari
      $(document).keyup(function(e){
                    var key = e.keyCode;
                    if (key == 27) {
                        TB_remove()
                    }
      });
      TB_showWindow();
    }
  }
  else
  {
    //alert("UHOH2");
    var handlerFunc = function(){
          TB_position();
          TB_showWindow();
    };
    new Request.HTML({
      method: 'get',
      update: $("#TB_ajaxContent"),
      onComplete: handlerFunc
    }).get(url);
  }

  window.onresize = function()
  {
    TB_position();
    TB_overlaySize();
  }

  document.onkeyup = function(event)
  {
    var event = new Event(event);
    if (event.code == 27) { // close
        TB_remove();
    }
  }

}

//helper functions below

function TB_showWindow()
{
  if( TB_useReady && !TB_ready ) return;
  
  if (TB_doneOnce == 0) {
     TB_doneOnce = 1;
      
      $('#TB_window').fadeIn(1000);
  }
  else {
      $('#TB_window').css('opacity', '1');
  }
//  $('TB_window').setStyle('opacity', 1);
}

function TB_remove()
{
  if( TB_useReady && !TB_ready ) return;
  
  //$("#TB_overlay").click();
  document.onkeyup = null;
  document.onkeydown = null;
  
//  if ($('#TB_closeWindowButton')) 
//     $("#TB_closeWindowButton").click();

  $('#TB_window').fadeOut(250, function(){
  	$('#TB_window').remove(); //$('TB_window').dispose();
  });
  
  $('#TB_overlay').fadeOut(400, function(){
  	$('#TB_overlay').remove(); //$('TB_overlay').dispose();
  });
  
  window.onscroll = null;
  window.onresize = null;
  TB_init();
  TB_doneOnce = 0;
  return false;
}

function TB_position()
{
  if( TB_useReady && !TB_ready ) return;
  
  $('#TB_window').animate({
    width: TB_WIDTH + 'px',
    left: ($(window).scrollLeft() + ($(window).width() - TB_WIDTH) / 2) + 'px',
    top: ($(window).scrollTop() + ($(window).height() - TB_HEIGHT) / 2) + 'px'
	},150);	
}

function TB_overlaySize()
{
  if( TB_useReady && !TB_ready ) return;
  
  // we have to set this to 0px before so we can reduce the size / width of the overflow onresize 

  $("#TB_overlay").css({
    "height": '0px',
    "width": '0px'
  });

  $("#TB_overlay").css({
    "height": ($(document).height() + 'px'),
    "width": ($(document).width() + 'px')
  });

}


function TB_parseQuery(query)
{
  if( TB_useReady && !TB_ready ) return;
  
  // return empty object
  if (!query)  return {};
  var params = {};
  
  // parse query
  var pairs = query.split(/[;&]/);
  for (var i = 0; i < pairs.length; i++)
  {
    var pair = pairs[i].split('=');
    if (!pair || pair.length != 2) continue;
    // unescape both key and value, replace "+" with spaces in value
    params[unescape(pair[0])] = unescape(pair[1]).replace(/\+/g, ' ');
  }
  return params;
}


var open_menu;
var current_timeout = new Array();

function showMenu(id1)
{
  if($('#' + id1).length)
  {
    if($('#' + id1).css('display')=='none')
    {
      //alert(open_menu);
      if($('#' + open_menu).length) {hideMenu($('#' + open_menu)); }
      $('#' + id1).css('display','inline');
      startMenuTimeout($('#' + id1));
      $('#' + id1).bind("mouseover",function(e) { killMenuTimeout($('#' + id1)); });
      $('#' + id1).bind("mouseout",function(e) { startMenuTimeout($('#' + id1)); });
      open_menu = id1;
    }
  }
}

function killMenuTimeout(divEl)
{
  clearTimeout(current_timeout[divEl.id]);
  current_timeout[divEl.id] = '';
}

function startMenuTimeout(divEl)
{
//	alert(divEl.id);
  if(current_timeout[divEl.id] == '') {
    current_timeout[divEl.id] = setTimeout(function() { hideMenu(divEl); }, 1000);
  }
}

function hideMenu(divEl)
{
  divEl.css('display','none');
  current_timeout[divEl.id] = '';
  divEl.unbind("mouseover");
  divEl.unbind("mouseout");
}

function SwapOut(id1) {
  $('#' + id1).src = Rollarrow1.src;
  return true;
}

function SwapBack(id1) {
  $('#' + id1).src = Rollarrow0.src;
  return true;
}
function urldecode( str ) {
    
    var hash_map = {}, ret = str.toString(), unicodeStr='', hexEscStr='';
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The hash_map is identical to the one in urlencode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';
    hash_map['%20'] = '+';
    hash_map['\u00DC'] = '%DC';
    hash_map['\u00FC'] = '%FC';
    hash_map['\u00C4'] = '%D4';
    hash_map['\u00E4'] = '%E4';
    hash_map['\u00D6'] = '%D6';
    hash_map['\u00F6'] = '%F6';
    hash_map['\u00DF'] = '%DF';
    hash_map['\u20AC'] = '%80';
    hash_map['\u0081'] = '%81';
    hash_map['\u201A'] = '%82';
    hash_map['\u0192'] = '%83';
    hash_map['\u201E'] = '%84';
    hash_map['\u2026'] = '%85';
    hash_map['\u2020'] = '%86';
    hash_map['\u2021'] = '%87';
    hash_map['\u02C6'] = '%88';
    hash_map['\u2030'] = '%89';
    hash_map['\u0160'] = '%8A';
    hash_map['\u2039'] = '%8B';
    hash_map['\u0152'] = '%8C';
    hash_map['\u008D'] = '%8D';
    hash_map['\u017D'] = '%8E';
    hash_map['\u008F'] = '%8F';
    hash_map['\u0090'] = '%90';
    hash_map['\u2018'] = '%91';
    hash_map['\u2019'] = '%92';
    hash_map['\u201C'] = '%93';
    hash_map['\u201D'] = '%94';
    hash_map['\u2022'] = '%95';
    hash_map['\u2013'] = '%96';
    hash_map['\u2014'] = '%97';
    hash_map['\u02DC'] = '%98';
    hash_map['\u2122'] = '%99';
    hash_map['\u0161'] = '%9A';
    hash_map['\u203A'] = '%9B';
    hash_map['\u0153'] = '%9C';
    hash_map['\u009D'] = '%9D';
    hash_map['\u017E'] = '%9E';
    hash_map['\u0178'] = '%9F';
 
    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr]; // Switch order when decoding
        ret = replacer(hexEscStr, unicodeStr, ret); // Custom replace. No regexing
    }
    
    // End with decodeURIComponent, which most resembles PHP's encoding functions
    ret = decodeURIComponent(ret);
 
    return ret;
}
function user_moj_log()	{
	if(readCookie('moj_logedin'))	{
		var username = readCookie('moj_logedin_username');
		var displayname = readCookie('moj_logedin_displayname');
		gtsp('user_moj_log_a').href='http://moj.dom.pl/' + username;
		if(displayname)	{
			gtsp('user_moj_log_a').innerHTML='Witaj, ' + urldecode(displayname) + '!';
		}	else	{
			gtsp('user_moj_log_a').innerHTML='Witaj, ' + urldecode(username) + '!';
		}
		el('user_moj_not_log','none');
		el('user_moj_log','');
	}
}
/*
function user_moj_log2()	{
	if(readCookie('moj_logedin'))	{
		var username = readCookie('moj_logedin_username');
		var displayname = readCookie('moj_logedin_displayname');
		gtsp('profil_link').href='http://moj.dom.pl/' + username;
		gtsp('profil_tresc').innerHTML='Witaj, <a href="http://moj.dom.pl/' + urldecode(username) + '">'+urldecode(username)+'</a>!<br/>Jeste? zalogowany w <a href="http://moj.dom.pl">moj.dom.pl</a>';
		el('user_profil_not_log','none');
		el('user_profil_log','');
	}
}
*/
function user_moj_log2()	{
	if(readCookie('moj_logedin'))	{
		var username = readCookie('moj_logedin_username');
		var displayname = readCookie('moj_logedin_displayname');
		gtsp('profil_link').href='http://moj.dom.pl/' + username;
		gtsp('loged_profil').href='http://moj.dom.pl/' + username;
		username_short = username;
		if(username.length > 15)
			var username_short = username.substr(0,11)+'...';
		gtsp('loged_profil').innerHTML=username_short;
		gtsp('profil_tresc').innerHTML='...<a href="http://moj.dom.pl/zdjecia_z_budowy.html">zdjęcia z budowy</a><span class="moj_or">&nbsp;</span><br/>...<a href="http://moj.dom.pl/internetowy_dziennik_budowy.html">dziennik budowy</a><span class="moj_or">&nbsp;</span>';
		el('user_profil_not_log','none');
		el('user_profil_log','');
	}
}


function search_help_delay(obj,obj2)	{
	
	var value = jQuery.trim($(obj).val());
	
	clearTimeout(parent.top.search_help_time);
	if(value.length >2)	{
		parent.top.search_help_time = setTimeout("search_help('"+$(obj).val()+"','"+obj2+"')",100);
	}	else	{
		$(obj2).html("");
		$(obj2).hide();
	}
}

var search_help_buffer = new Array();
function search_help(obj,obj2)	{
for(i=0;i<search_help_buffer.length;i++)	{
	if(search_help_buffer[i]==obj)	{
		if(search_help_buffer[i+1])	{
			$(obj2).html(search_help_buffer[i+1]);
			$(obj2).show();
		}	else	{
			$(obj2).html("");
			$(obj2).hide();
		}
		return false;
	}
}

$.ajax({
  type: "GET",
  url: 'search_help.php',
  data: 'search=' + obj,
  dataType: "xml",
  success: function(xml){
          //alert(xml);
          //return;
          var toPrint = '';
		  var ct=0;
		  $(xml).find('res').each(function(){
			if(!ct)	{
				$(obj2).html("");
				$('<div></div>').html('<span>PROJEKTY:</span>').appendTo(obj2);
			}
			var ad_title = $(this).find('res_title').text();
			var ad_link = $(this).find('res_link').text();
			var ad_foto = $(this).find('res_foto').text();
			//alert(ad_title);

			$('<div class="item_search"></div>').html('<a href="'+ad_link+'"><img src="'+ad_foto+'" alt="'+ad_title+'" width="50" height="33"/></a><a style="color:#03318B;" href="'+ad_link+'">'+ad_title+'</a>').appendTo(obj2);
		  	
		  	ct++;
		  });
		  if(ct)	{
		  	search_help_buffer.push(obj);
		  	search_help_buffer.push($(obj2).html());
		  	$(obj2 +' a').mouseover(function()	{
		  		parent.top.search_help_active=1;
		  		parent.top.search_help_active2=1;
		  	});		  	
		  	$(obj2+ ' a').mouseout(function()	{
		  		parent.top.search_help_active=0;
		  		parent.top.search_help_active2=0;
		  	});		
		  	$(obj2).show();
		  }	else	{
		  	search_help_buffer.push(obj);
		  	search_help_buffer.push("");
		  	$(obj2).hide();		  
		  }
  },
  error: function(){
	search_help_buffer.push(obj);
	search_help_buffer.push("");
  	$(obj2).html("");
  	$(obj2).hide();
  }
});

}

function set_pod(pod_link)	{
	//alert(pod_link);
	//return false;
	//alert(pod_link);
	$.ajax({
		  type: "GET",
		  url: 'podobne.php',
		  data: 'pod_link=' + pod_link,
		  dataType: "xml",
		  success: function(xml){
			var podobne_in="";
			var counter=0;
		 	$(xml).find('res').each(function() {
				var ad_title = $(this).find('res_title').text();
				var ad_link = $(this).find('res_link').text();
				var ad_foto = $(this).find('res_foto').text();
				var ad_m = $(this).find('res_m').text();
					podobne_in+="<div class='tv_box1' style='left:"+(counter*169)+"px;top:0px;'> \
									<div class='tv_box2'> \
										<div class='tv_box2_1'></div> \
										<div class='tv_box2_2'></div> \
										<div class='tv_box2_3'></div> \
										<div class='tv_box2_4'></div> \
										<div class='tv_box2_5'></div> \
										<div class='tv_box2_6'></div> \
										<div class='tv_box2_7'></div> \
										<div class='tv_box2_8'></div> \
										<div class='tv_box2_9'></div> \
										<div class='tv_box2_10'></div> \
										<div class='tv_box2_11' align='center'> \
											<a href='"+ad_link+"' class='thumb'><img src='"+ad_foto+"' alt='"+ad_title+"' border='0' title='"+ad_title+" - Zobacz projekt' /></a> \
										</div> \
										<div class='tv_box2_12'> \
											<div class='opisDomek' align='right'> \
													<strong>"+ad_m+" m</strong><sup>2</sup> \
											</div> \
											<a href='"+ad_link+"'>"+(ad_title>32 ? ad_title.substr(0,32)+"..." : ad_title)+"</a> \
										</div> \
									</div> \
								</div>";
				counter++;				
		 	});
			if(podobne_in)	{
				$('#podobne_new').html(podobne_in);
				$('#podobne_new_title').show();
				$('#podobne_new').show();
			}
			//alert('sukces');
		  },
		  error: function(){
			//alert('error');
		  }
	});
	
}
function doIframe(){
	o = document.getElementsByTagName('iframe');
	for(i=0;i<o.length;i++){
		if (/\bautoHeight\b/.test(o[i].className)){
			setHeight(o[i]);
			addEvent(o[i],'load', doIframe);
		}
	}
}

function setHeight(currentfr){
	var FFextraHeight = 30;
	if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) {//ns6 syntax
		currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
	}	else if	(currentfr.contentDocument && currentfr.contentDocument.documentElement.offsetHeight)	{ //ns6 syntax
		currentfr.height = currentfr.contentDocument.documentElement.offsetHeight+FFextraHeight;
	}	else if	(currentfr.Document && currentfr.Document.body.scrollHeight)	{ //ie5+ syntax
		alert(1);currentfr.height = currentfr.Document.body.scrollHeight;
	}	else if	(currentfr.Document && currentfr.Document.documentElement.scrollHeight)	{ //ie5+ syntax
		currentfr.height = currentfr.Document.documentElement.scrollHeight;
	}
}

function addEvent(obj, evType, fn){
	if(obj.addEventListener)
	{
	obj.addEventListener(evType, fn,false);
	return true;
	} else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
	return r;
	} else {
	return false;
	}
}
if (document.getElementById && document.createTextNode){
 addEvent(window,'load', doIframe);	
}

function init_podpowiadacz() {
	
	//return false;
	if(location.search=='?podpowiadacz')	{
		$("#podpowiadacz_cont").click(function () {
			close_podpowiadacz();
		});
		$("#fix").show();
		//sizeIFrame();
	//	$("#podpowiadacz_frame").load(sizeIFrame());

		$("#podpowiadacz_cont").show();
		
		
		$("#podpowiadacz_cont a.close").click(function () {
			close_podpowiadacz();
		});
	}
}
function close_podpowiadacz() {
	$("#podpowiadacz_cont").hide();	
	$("#fix").hide();	
}
if(readCookie('login_proj3') == 1 && location.host == 'projekty3.dom.pl' )
{
	createCookie('login_proj3','1',	0.042,'.dom.pl');
}
function init_sugestia() {
	if (location.host != 'projekty3.dom.pl') {
		return false;
	}	else	{
		$("body").append("<a href=\"/sugestia.php\" onclick=\"return hs.htmlExpand(this, { objectType: 'iframe', dimmingOpacity: '0.7',width: '450'} )\" id=\"twoja_sugestia\"></a>");

	}
}
function search_help_delay_s(obj)	{
	var value = jQuery.trim(obj.value);
	clearTimeout(parent.top.search_help_time);
	if(value.length >2)	{
		parent.top.search_help_time = setTimeout("search_help_s('"+obj.value+"')",100);
	}	else	{
		$("#search_help_content_s").html("");
		$("#search_help_content_s").hide();
	}
}

var search_help_buffer = new Array();
function search_help_s(obj)	{
for(i=0;i<search_help_buffer.length;i++)	{
	if(search_help_buffer[i]==obj)	{
		if(search_help_buffer[i+1])	{
			$("#search_help_content_s").html(search_help_buffer[i+1]);
			$('#search_help_content_s').show();
		}	else	{
			$("#search_help_content_s").html("");
			$("#search_help_content_s").hide();
		}
		return false;
	}
}

$.ajax({
  type: "GET",
  url: 'search_help_s.php',
  data: 'search=' + obj,
  dataType: "xml",
  success: function(xml){
         // alert(xml);
          //return;
          var toPrint = '';
		  var ct=0;
		  $(xml).find('res').each(function(){
			if(!ct)	{
				$('#search_help_content_s').html("");
				$('<div class="item_search"></div>').html('<span>PODPOWIEDZI:</span>').appendTo('#search_help_content_s');
			}
			var ad_title = $(this).find('res_title').text();
			var ad_link = $(this).find('res_link').text();
			//alert(ad_title);
			$('<div class="item_search"></div>').html('<a style="color:#03318B;" href="'+ad_link+'">'+ad_title+'</a>').appendTo('#search_help_content_s');
		  
		  	ct++;
		  });
		  var ct2=0;
		  $(xml).find('res2').each(function(){
				if(!ct && !ct2)	{
					$('#search_help_content_s').html("");
					$('<div class="item_search"></div>').html('<span>PROJEKTY:</span>').appendTo('#search_help_content_s');
				}	else if(ct && !ct2)	{
					$('<div class="item_search"></div>').html('<span>PROJEKTY:</span>').appendTo('#search_help_content_s');					
				}
				var ad_title = $(this).find('res2_title').text();
				var ad_link = $(this).find('res2_link').text();
				var ad_foto = $(this).find('res2_foto').text();
				//alert(ad_title);
				$('<div class="item_search" style="clear:both;"></div>').html('<a href="'+ad_link+'"><img style="float:left;margin:3px 3px 0 0;" src="'+ad_foto+'" alt="'+ad_title+'" width="50" height="33"/></a><a style="color:#03318B;" href="'+ad_link+'">'+ad_title+'</a>').appendTo('#search_help_content_s');
			  
			  	ct2++;
			  });
		  if(ct || ct2)	{
		  	search_help_buffer.push(obj);
		  	search_help_buffer.push($('#search_help_content_s').html());
		  	$('#search_help_content_s a').mouseover(function()	{
		  		parent.top.search_help_active=1;
		  	});
		  	$('#search_help_content_s a').mouseout(function()	{
		  		parent.top.search_help_active=0;
		  	});		  	
		  	$('#search_help_content_s').show();
		  	
		  }	else	{
		  	search_help_buffer.push(obj);
		  	search_help_buffer.push("");
		  	$('#search_help_content_s').hide();		  
		  }
  },
  error: function(){
	search_help_buffer.push(obj);
	search_help_buffer.push("");
  	$('#search_help_content_s').html("");
  	$('#search_help_content_s').hide();
  }
});
}

/*dopisane z reflection js*/
/*!
	reflection.js for jQuery v1.03
	(c) 2006-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/

(function($) {

$.fn.extend({
	reflect: function(options) {
		options = $.extend({
			height: 1/3,
			opacity: 0.5
		}, options);

		return this.unreflect().each(function() {
			var img = this;
			if (/^img$/i.test(img.tagName)) {
				function doReflect() {
					var imageWidth = img.width, imageHeight = img.height, reflection, reflectionHeight, wrapper, context, gradient;
					reflectionHeight = Math.floor((options.height > 1) ? Math.min(imageHeight, options.height) : imageHeight * options.height);
					reflectionWidth = Math.floor((options.height > 1) ? Math.min(imageWidth, options.height) : imageWidth * options.height);

					if ($.browser.msie) {
						reflection = $("<img />").attr("src", img.src).css({
							width: imageWidth,
							height: imageHeight,
							marginBottom: reflectionHeight - imageHeight,
							filter: "fliph"
						})[0];
					} else {
						reflection = $("<canvas />")[0];
						if (!reflection.getContext) return;
						context = reflection.getContext("2d");
						try {
							$(reflection).attr({width: reflectionWidth, height: imageHeight});
							context.save();
							context.translate(imageWidth-1,0);
							context.scale(-1, 1);
							context.drawImage(img, 0, 0, imageWidth, imageHeight);
							context.restore();
							context.globalCompositeOperation = "destination-out";

							
						} catch(e) {
							return;
						}
					}
					$(reflection).css({display: "block", border: 0, margin: "0 10px 0 10px", padding: "2px"});

					wrapper = $(/^a$/i.test(img.parentNode.tagName) ? "<span />" : "<div />").insertAfter(img).append([img, reflection])[0];
					wrapper.className = img.className;
					$.data(img, "reflected", wrapper.style.cssText = img.style.cssText);
					$(wrapper).css({width: imageWidth, height: reflectionHeight, overflow: "hidden"});
					img.style.cssText = "display: none; border: 0px";
					img.className = "reflected thumb4";
				}

				if (img.complete) doReflect();
				else $(img).load(doReflect);
			}
		});
	},

	unreflect: function() {
		return this.unbind("load").each(function() {
			var img = this, reflected = $.data(this, "reflected"), wrapper;

			if (reflected !== undefined) {
				wrapper = img.parentNode;
				img.className = 'no_mirror thumb4';
				img.style.cssText = reflected;
				$.removeData(img, "reflected");
				wrapper.parentNode.replaceChild(img, wrapper);
			}
		});
	}
});

})(jQuery);

/**
 * reflection.js v1.7
 *
 * Contributors: Cow http://cow.neondragon.net
 *               Gfx http://www.jroller.com/page/gfx/
 *               Sitharus http://www.sitharus.com
 *               Andreas Linde http://www.andreaslinde.de
 *               Tralala, coder @ http://www.vbulletin.org
 *
 * Freely distributable under MIT-style license.
 */
 
/* From prototype.js */
document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = new Array();
  
	for (var i = 0; i < children.length; i++) {
		var child = children[i];
		var classNames = child.className.split(' ');
		for (var j = 0; j < classNames.length; j++) {
			if (classNames[j] == className) {
				elements.push(child);
				break;
			}
		}
	}
	return elements;
}

var Reflection = {
	defaultHeight : 1,
	defaultOpacity: 1,
	
	add: function(image, options) {
		Reflection.remove(image);
		
		doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
		if (options) {
			for (var i in doptions) {
				if (!options[i]) {
					options[i] = doptions[i];
				}
			}
		} else {
			options = doptions;
		}
	
		try {
			var d = document.createElement('div');
			var p = image;
			
			var classes = p.className.split(' ');
			var newClasses = '';
			for (j=0;j<classes.length;j++) {
				if (classes[j] != "reflect") {
					if (newClasses) {
						newClasses += ' '
					}
					
					newClasses += classes[j];
				}
			}
				
			var reflectionHeight = Math.floor(p.height*options['height']);
			var divHeight = Math.floor(p.height*(1+options['height']));
			
			//var reflectionHight = p.height;
			var reflectionWidth = p.width;
			
			if (document.all && !window.opera) {
				/* Fix hyperlinks */
				if(p.parentElement.tagName == 'A') {
	                var d = document.createElement('a');
	                d.href = p.parentElement.href;
                }  
                    
				/* Copy original image's classes & styles to div */
				d.className = newClasses;
				p.className = 'reflected';
				
				d.style.cssText = p.style.cssText;
				p.style.cssText = 'vertical-align: bottom';
			
				var reflection = document.createElement('img');
				reflection.src = p.src;
				reflection.style.width = reflectionWidth+'px';
				reflection.style.height = reflectionHeight+'px';
				reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
				reflection.style.filter = 'fliph';
				reflection.className = 'thumb2';
				d.style.width = reflectionWidth+'px';
				d.style.height = divHeight/2+'px';
				
				//alert(d.style.background);			
				p.parentNode.replaceChild(d, p);

				d.appendChild(p);
				d.appendChild(reflection);
				
			} else {
				var canvas = document.createElement('canvas');
				if (canvas.getContext) {
					/* Copy original image's classes & styles to div */
					d.className = newClasses;
					p.className = 'reflected';
					
					d.style.cssText = p.style.cssText;
					p.style.cssText = 'vertical-align: bottom';
			
					var context = canvas.getContext("2d");
					canvas.style.height = reflectionHeight+'px';
					canvas.style.width = reflectionWidth+'px';
					canvas.height = reflectionHeight;
					canvas.width = reflectionWidth;
					canvas.className = 'thumb2';
					d.style.width = reflectionWidth+6+'px';
					d.style.height = divHeight/2+10+'px';
					d.align='center'
					d.style.margin = 'auto';
					if((divHeight/2+10)<100)	{
						d.style.margin='0 10px 0 10px';
						
					}
					p.parentNode.replaceChild(d, p);
					
					d.appendChild(p);
					d.appendChild(canvas);
					
					context.save();
					context.translate(image.width-1,0);
					context.scale(-1,1);
					context.drawImage(image, 0, 0, reflectionWidth+20, image.height);
	
					context.restore();	
				}
			}p.parentNode.removeChild(p);
		} catch (e) {
	    }
	},
	
	remove : function(image) {
		if (image.className == "reflected") {
			image.className = image.parentNode.className;
			image.parentNode.parentNode.replaceChild(image, image.parentNode);
		}
	}
}

function addReflections() {
	var rimages = document.getElementsByClassName('reflect');
	for (i=0;i<rimages.length;i++) {
		var rheight = null;
		var ropacity = null;
		
		var classes = rimages[i].className.split(' ');
		for (j=0;j<classes.length;j++) {
			if (classes[j].indexOf("rheight") == 0) {
				var rheight = classes[j].substring(7)/100;
			} else if (classes[j].indexOf("ropacity") == 0) {
				var ropacity = classes[j].substring(8)/100;
			}
		}
		
		Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
	}
}
function removeReflections()	{
	var nrimages = document.getElementsByClassName('highslide');
	var marg_b=((document.all && !window.opera) ? '2px' : '4px'); 
	for (i=0;i<nrimages.length;i++) {
		if(document.all && !window.opera)	{
		var old_width=nrimages[i].style.width;	
		}	else	{
		var old_width=nrimages[i].style.width;
		
		}
		if(nrimages[i].style.height=='95px')	{//elewacje
			var ad_marg='margin-left:10px;margin-right:10px;';
			var new_src = parent.top.old_img[i];
		}	else if	(nrimages[i].href.substr(nrimages[i].href.length-4,nrimages[i].href.length)=='.gif')	{	//rzuty w gifie
			var ad_marg='width:'+old_width+';';
			//var new_src = nrimages[i].href;
			var new_src = parent.top.old_img[i];
		}	else	{	//normalne zdjecia
			var ad_marg='width:'+old_width+';';	
			var new_src = parent.top.old_img[i];	
		}
		var back_image = "<img style='"+ad_marg+"margin-bottom:"+marg_b+";' class='no_mirror thumb2' src='"+new_src+"' />";	
		nrimages[i].innerHTML=back_image;
	}
}
var previousOnload = window.onload;


