

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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) {
	createCookie(name,"",-1);
}

function clickButtonOnEnter(event, buttonID) 
{
if ((event.which ? event.which : event.keyCode) == 13)
{
event.returnValue = false;
event.cancel = true;
document.getElementById(buttonID).click();
}
}
function setFocusOnEnter (event, buttonID) 
{
if ((event.which ? event.which : event.keyCode) == 13)
{
event.returnValue = false;
event.cancel = true;
document.getElementById(buttonID).focus();
}
}


function f2f(offerID) {
 var aspxUrl = siteBaseUrl + '/Formularze/f2friendOffer.aspx';
 aspxUrl += '?url=' + URLEncode(siteBaseUrl + '/#'+ offerID);
 OpenWindow(aspxUrl, 'F2F', 450, 500);
}


function OpenWindow(url, title, w, h)
{
    if(window.screen)
    {
        aw = screen.availwidth;
        ah = screen.availheight;
    }
    else
    {
        aw = 640;
        ah = 450;
    }
    settings =
        "left="+(aw-w)/2+","
        +"top="+(ah-h)/2+","
        +"screenX="+(aw-w)/2+","
        +"screenY="+(ah-h)/2+","
        +"width="+w+","
        +"height="+h+","
        +"toolbar=no,"
        +"location=yes,"
        +"directories=no,"
        +"status=np,"
        +"menubar=no,"
        +"scrollbars=yes,"
        +"resizable=yes"

    newWindow = window.open(url, title, settings);
    newWindow.focus();
}

function selectRegion(obj,countryDIV,zagraniczny)
{
    var countries = document.getElementById(countryDIV);
    if (obj.options[obj.selectedIndex].value == zagraniczny)
        countries.style.display="";
    else
        countries.style.display="none";
}

var regionOptionsList = null;


var hiddenFieldExpanded = null;

function SwitchAllDetailFromCookie(expandLinkID,collapseLinkID)
{
    var expand = 0
    var ex = readCookie("hiddenFieldExpanded");
    
    if(ex == 1)
    {       
        expand = 1;
    }

    SwitchAllDetail(expand,expandLinkID,collapseLinkID);
}

function SwitchAllDetail(expand,expandLinkID,collapseLinkID)
{
    var expandLink = document.getElementById(expandLinkID);
    var collapseLink = document.getElementById(collapseLinkID);
    if(expand == 1)
    {
        expandLink.className = "expandAllActive";
        collapseLink.className = "collapseAllNoActive";        
    }
    else
    {
        expandLink.className = "expandAllNoActive";
        collapseLink.className = "collapseAllActive";      
    }
    var i=1;

    var  element =  document.getElementById('detailOfferInfo1'); 
    var link =  document.getElementById('switchDetailLink1'); 

    while(element != null)
    {
    
        SwitchDetailBox(expand,link,element);
        
        i++;
        element = document.getElementById('detailOfferInfo' + i); 
        link =  document.getElementById('switchDetailLink' + i); 
    }
    
    createCookie("hiddenFieldExpanded",expand);
        
    return false;  
}


function SwitchDetailBox(expand,link, box)
{            
    if (expand == 0)
    {
        box.style.display = "none";
        link.innerHTML = "<img src='/_images-app/ico_add_16.gif' width='9' height='9' border='0' alt='rozwiń szczegóły' align='middle'> rozwiń szczegóły";
        link.className = "expand"
 
    }
    else
    {
        box.style.display = "";
        link.innerHTML = "<img src='/_images-app/ico_delete_16.gif' width='9' height='9' border='0' alt='zwiń szczegóły' align='middle'> zwiń szczegóły";
        link.className = "collapse"
    }
}


function SwitchDetail(link, box)
{    
    var element = document.getElementById(box);
    if (element.style.display == "")
    {
        SwitchDetailBox(0,link,element);
    }
    else
    {
        SwitchDetailBox(1,link,element);
    }
}


function returnPMap()
{var pMap={};pMap={adr:null,tTInfo:null,tTimg:null,tTPos:null,arr:null,icon:null,map:null,marker:null,point:null,extPoint:new Array(),gdir:null,gMapI:null,geo:null,mngr:null,customId:"",gMapGlobalInstance:this,iter:null,fixed:null,listaMarkerow:new Array(),setDirections:function(gMapGIns,toAddress,fromAddress,locale){gMapGIns.gdir=new GDirections(gMapGIns.map,document.getElementById("directions"));GEvent.addListener(gMapGIns.gdir,"error",function(){gMapGIns.handleErrors(gMapGIns.gdir)});gMapGIns.gdir.clear();gMapGIns.gdir.load("from: "+fromAddress+" to: "+toAddress,{"locale":locale});return;},handleErrors:function(el){alert(el.getStatus().code);},ToolTip:function(gMapGIns,empPosition,empAddress,empName){var elEmpPosition,el,empLogo,elEmpLogo,elEmpName,elEmpAddress,elControls,elControlsZoomIn,elControlsZoomOut,elControlsOptions,elControlsDir,elControlsDirInput,elControlsDirGo=null;function gMapAddCon(m){m.addControl(new GSmallMapControl());m.addControl(new GMapTypeControl());m.addControl(new GScaleControl());}
if(document.getElementById('gMapInfoDomBranch')){document.getElementById('gMapInfoDomBranch').parentNode.removeChild(document.getElementById('gMapInfoDomBranch'));}
el=document.createElement('div');el.id="gMapInfoDomBranch";elEmpName=document.createElement('p');elEmpName.innerHTML=empName;elEmpName.className="gMapEmpName";elEmpAddress=document.createElement('p');elEmpAddress.innerHTML=empAddress;elEmpAddress.className="gMapEmpAddress";elEmpPosition=document.createElement('p');elEmpPosition.innerHTML=empPosition;elEmpPosition.className="gMapEmpPosition";elControls=document.createElement('div');elControlsZoomIn=document.createElement('span');elControlsZoomIn.innerHTML="zoom+";GEvent.addDomListener(elControlsZoomIn,"click",function(){gMapGIns.map.zoomIn();});elControlsZoomIn.className="gMapControls";elControlsZoomOut=document.createElement('span');elControlsZoomOut.innerHTML="zoom-";GEvent.addDomListener(elControlsZoomOut,"click",function(){gMapGIns.map.zoomOut();});elControlsZoomOut.className="gMapControls";elControlsDir=document.createElement('div');elControlsDir.innerHTML="<p>Pokaz dojazd do: </p>";elControlsDirInput=document.createElement('input');elControlsDirInput.style.width="200px";elControlsDirInput.value="";elControlsDirInput.id="gMapOptionsDir";elControlsDirGo=document.createElement('span');elControlsDirGo.innerHTML="GO";GEvent.addDomListener(elControlsDirGo,"click",function(){gMapGIns.setDirections(gMapGIns,new String(gMapGIns.adr),new String(document.getElementById('gMapOptionsDir').value),new String('pl_PL'));});elControlsDir.appendChild(elControlsDirInput);el.appendChild(elEmpPosition);el.appendChild(elEmpName);el.appendChild(elEmpAddress);el.appendChild(elControls);return el;},init2:function(customId){var el=document.body;this.customId=document.body;this.fixed=true;if(document.getElementById('gMapW')){document.getElementById('gMapW').parentNode.removeChild(document.getElementById('gMapW'));}
var gMapW=document.createElement('div');gMapW.id="gMapW";var elTmp=customId;while(elTmp.parentNode.id!="NEWresultsList"){elTmp=elTmp.parentNode;}
gMapW.style.top=elTmp.offsetTop+10+"px";gMapW.style.left=50+"%";var close=document.createElement('div');close.id="gMapClose";close.innerHTML="<span>Zamknij</span> <img src='http://www.pracuj.pl/_images-app/close.gif' height='16' width='16'/>";GEvent.addDomListener(close,"click",(function(){var t=close.parentNode;close.parentNode.innerHTML="";t.parentNode.removeChild(t);}));gMapW.appendChild(close);var gTitle=document.createElement('p');gTitle.innerHTML="Miejsce pracy";gTitle.id="gMapTitle";gMapW.appendChild(gTitle);var gMapC=document.createElement('div');gMapC.id="gMapC";gMapW.appendChild(gMapC);if(this.fixed!=true){while(el.parentNode.id!="NEWresultsList"){el=el.parentNode;}}
if(customId=='body'){while(el.parentNode.id!="NEWresultsList"){el=el.parentNode;}}
el.appendChild(gMapW);this.adr=null;this.geo=new GClientGeocoder();var gIco=G_DEFAULT_ICON;this.icon=gIco;return;},init:function(customId){if(typeof customId=="undefined"){customId=document.body;this.customId=document.body;this.fixed=true;}else if
(typeof customId=="string"){if(customId=="body")
{var el=document.body;this.customId=document.body;this.fixed=true;}else{var el=document.getElementById(customId);this.customId=customId;this.fixed=true;}}
else if(typeof customId=="object"){var el=customId;this.customId=el.toString();}else{this.customId=customId;}
if(document.getElementById('gMapW')){document.getElementById('gMapW').parentNode.removeChild(document.getElementById('gMapW'));}
var gMapW=document.createElement('div');gMapW.id="gMapW";var close=document.createElement('div');close.id="gMapClose";close.innerHTML="Zamknij <img src='http://www.pracuj.pl/_images-app/close.gif' height='16' width='16'/>";GEvent.addDomListener(close,"click",(function(){var t=close.parentNode;close.parentNode.innerHTML="";t.parentNode.removeChild(t);}));gMapW.appendChild(close);var gMapC=document.createElement('div');gMapC.id="gMapC";gMapW.appendChild(gMapC);if(this.fixed!=true){while(el.parentNode.id!="NEWresultsList"){el=el.parentNode;}}
if(customId=='body'){while(el.parentNode.id!="NEWresultsList"){el=el.parentNode;}}
gMapW.style.top=1836+"px";gMapW.style.left=691+"px";el.appendChild(gMapW);this.adr=null;this.geo=new GClientGeocoder();var gIco=G_DEFAULT_ICON;this.icon=gIco;return;},go:function(gMapLocals,gMapXYPos){var call=this;if(typeof gMapLocals!='undefined'){call.arr=gMapLocals;}else{call.arr=new Array([call.tTInfo,call.adr]);}
call.iter=null;var t="gMapW";document.getElementById(t).style.display="block";call.tmpMarker=new Array();for(call.iter=0;call.iter<call.arr.length;call.iter++){if(call.map==null){call.map=new GMap2(document.getElementById("gMapC"),{backgroundColor:"white"});call.map.setCenter(new GLatLng(52.219002,21.002002),10);call.map.enableScrollWheelZoom();call.map.addControl(new GSmallMapControl());call.map.addControl(new GMapTypeControl());call.map.addControl(new GScaleControl());}
call.adr=(call.arr[call.iter])[1];call.tTInfo=(call.arr[call.iter])[0];call.tTPos=(call.arr[call.iter])[2];if(!gMapXYPos)
{this.resolveAddress(call.adr,call,this.gMapTTipDescription(call.tTInfo),call.tTPos);}
else
{this.resolveAddress(call.adr,call,this.gMapTTipDescription(call.tTInfo),call.tTPos,gMapXYPos);}}
return;},resolveAddress:function(address,call,opis,posi,coord){if(!coord)
{var listaMarkerowTemp=null;call.geo.getLocations(address,function(result){if(result.Status.code=="200"){var p=result.Placemark[0].Point.coordinates;var markerOptions={};markerOptions.icon=call.icon;var mark=new GMarker(new GLatLng(p[1],p[0]),markerOptions);GEvent.addDomListener(mark,"click",function(){mark.openInfoWindow(call.ToolTip(call,posi,address,opis))});call.map.addOverlay(mark);call.map.setCenter(new GLatLng(p[1],p[0]),13);mark.openInfoWindow(call.ToolTip(call,posi,address,opis));}});}else{var p=coord;var markerOptions={};markerOptions.icon=call.icon;var mark=new GMarker(new GLatLng(p[1],p[0]),markerOptions);GEvent.addDomListener(mark,"click",function(){mark.openInfoWindow(call.ToolTip(call,posi,address,opis))});call.map.addOverlay(mark);call.map.setCenter(new GLatLng(p[1],p[0]),13);mark.openInfoWindow(call.ToolTip(call,posi,address,opis));}
return this.listaMarkerow;},gMapTTipLogo:function(input){var img=null;if(typeof input=="undefined")
{img=new Image(1,1);}else if(typeof input=="object")
{img=input;}else if(typeof input=="string")
{img=document.createElement('img');img.src=input;}
return img;},gMapTTipDescription:function(input){var desc=null;if(typeof input=="undefined")
{desc="default opis";}else if(typeof input=="object")
{desc=input;}else if(typeof input=="string")
{desc=document.createElement('p');desc.innerHTML=input;desc=desc.innerHTML;}
return desc;}};return pMap;}

/* JALight */
function ValidateMailJAL() {
	ValidatorValidate(ctrlSearchResults_rfvEmail, "captcha", null);
	if (ctrlSearchResults_rfvEmail.isvalid == true)
		ValidatorValidate(ctrlSearchResults_revEmail, "captcha", null);
	
	//ValidatorUpdateIsValid();
	Page_BlockSubmit = !Page_IsValid;
	ValidationSummaryOnSubmit("captcha");
	return Page_IsValid;
}

function OpenCaptchaJA(mailObjId,validatemail) {
	var mailTb = document.getElementById(mailObjId);
	var captcha = document.getElementById(ctrlSearchResults_divCaptchaJA);
	
	document.getElementById(ctrlSearchResults_tbDivVisible).value = '1';
	document.getElementById(ctrlSearchResults_tbMailCaptchaId).value = mailTb.value;
	document.getElementById(ctrlSearchResults_tbMailFromCaptchaId).value = mailObjId;

	ValidateMailJAL();

	if (ctrlSearchResults_rfvEmail.isvalid && ctrlSearchResults_revEmail.isvalid) {
	    //document.getElementById('aspnetForm').appendChild(captcha);
		if (document.body.getBoundingClientRect) {
			var top = mailTb.getBoundingClientRect().top + document.documentElement.scrollTop;
			var left = mailTb.getBoundingClientRect().left + document.documentElement.scrollLeft;
		} else {
			var top = mailTb.offsetTop;
			var left = mailTb.offsetLeft;
		}

		captcha.style.top = top+35+"px";
		captcha.style.left = left-100+"px";
		captcha.className = "JALbox";

		captcha.style.display ="block";
	} else {
		captcha.style.display ="none";
		document.getElementById(ctrlSearchResults_tbDivVisible).value = "";
		document.getElementById(ctrlSearchResults_tbMailCaptchaId).value = "";
		document.getElementById(ctrlSearchResults_tbMailFromCaptchaId).value = "";
		
		// tu mozna dac kod gdy mail jest niepoprawny np
		alert("Podany adres email jest nieprawidłowy.");
		mailTb.focus();
		clsJA(mailTb);
	}

}

function clsJA(obj) {
	if (obj.value == "Twój e-mail")
		obj.value = "";
}

function hideJA(obj) {
  document.getElementById(obj).style.display = "none";
}
/* /JALight */
