function okno(strona, nazwa, width, height)
{
  okno_nowe=window.open(strona,nazwa,"width="+width+",height="+height+",left=250,top=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}

function makeChangePapperMessage(txt, step) {

	var cl = "$(this).dialog('close');";
	var t = 'Uwaga';
	var w = 470;
	
	$("#dialogPapper").attr("title", t);
	$("#dialogPapper_tresc").html(txt);
	$("#dialogPapper_tresc").width(450);
	if (!step) {
		$('#standard_service').unbind();
		$('#standard_service').click(function() { xajax_changePapper(xajax.getFormValues("koszyk2"),1); return false; });
		$('#pro_service').unbind();
		$('#pro_service').click(function() {  
			$("#dialogPapper").dialog('close'); 
			return false; });
	} else {
		$('#standard_service').unbind();
		$('#standard_service').click(function() {
			updatePaperKind(1);
			xajax_changePapper(xajax.getFormValues("koszyk2"),3); 
			return false; 
		});
		$('#pro_service').unbind();
		$('#pro_service').click(function() {
			updatePaperKind(2);
			$('#paperKind').val('2');
			xajax_changePapper(xajax.getFormValues("koszyk2"),4); 
			return false; 
		});
	}
	
	$("#dialogPapper").dialog({
			modal: true,
			width: w,
			bgiframe: true,
			close: function(ev, ui) {
				$(this).dialog('destroy'); }
		});
		
	$("#dialogPapper").dialog('open');
	
	return false;	
}

function BasketON() {
	//o('koszyk_ico').className = 'koszyk_ico_on';
}

function BasketOFF() {
	//o('koszyk_ico').className = 'koszyk_ico_off';
}

function MM_preloadImages()
  {
   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  }
function MM_swapImgRestore()
  {
   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  }
function MM_findObj(n, d)
  {
   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
  }
function MM_swapImage()
  {
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  }

function trim(str)
{
   	return str.replace(/^\s*|\s*$/g,"");
}

function addFile(src_id, ile) {

	if (document.getElementById)
	{
		document.getElementById(src_id).outerHTML += '<div id="file' + ile + '"><input name="file' + ile + '" value="" type="file" class="frm"></div>';
	}
	else if (document.all) {
		document.all[src_id].outerHTML += '<div id="file' + ile + '"><input name="file' + ile + '" value="" type="file" class="frm"></div>';
	}
}

function delFile(ile) {

	if (ile<=1) {
		alert('Nie mo?na usun?c ostatniego pola !');
		return;
	}
	if (document.getElementById)
	{
		document.getElementById('file'+ile).outerHTML = '';
	}
	else if (document.all) {
		document.all['file'+ile].outerHTML = '';
	}
}

function check_edit(text1) {

	if (document.ppform.boxchecked.value != 1) {
		display_error( 'messagebox' , 'messageText' , text1 );
		//alert(text1);
		return false;
	} else {
		return true;
	}

}
function goback() {
	if (typeof $('#flogin').data('referer') !== undefined && $('#flogin').data('referer') != '') {
		document.location.href = $('#flogin').data('referer');
	}
	else {
		document.location.href = '/fp_upload';
	}
}
function checkIfEnter(e)
{
	var iCode;
	if (e.keyCode) iCode = e.keyCode;
	else if (e.which) iCode = e.which;
	var keyChar = String.fromCharCode(iCode);
	if(keyChar == "\r")
	{
		Login(document.flogin);
		return false;
	}
}
function Login(form) {
	var login = form.login;
	var pass = form.pass;
	if(!validateEmail(login.value)) {
		$('#messageText').html('Podaj poprawny adres email.');
		$('#messageText').css('display','block');
		$("input[name=login]").focus();
	}else if(pass.value == "") {
		$('#messageText').html('Podaj hasło.');
		$('#messageText').css('display','block');
		$("input[name=pass]").focus();
	}else {
		$('#messageText').html('trwa logowanie <img src="images/kreciol_p.gif" alt="" style="float: none" />');
		$('#messageText').css('display','block');
		if (_gaq) _gaq.push(['_trackPageview', 'logowanie.htm']);
		xajax_login(xajax.getFormValues("flogin"));
	}

	return false;
}

function showLogin() {
	var login = document.loginOverlay.login;
	var pass = document.loginOverlay.pass;
	login.className = "inp_okienka";
	pass.className = "inp_okienka";
	$('#log_blad').innerHTML = '';
	$('#log_blad').hide();
	document.loginOverlay.reset();

	$("#log").dialog({
		modal: true,
		width: 500,
		bgiframe: true,
		resizable: false,
		buttons: {
			'Zaloguj': function() {
				return LoginOverlay(document.loginOverlay); 
			},
			'Anuluj': function() { 
				$(this).dialog('destroy'); 
			}
		},
		close: function(ev, ui) { $(this).dialog('destroy'); }
	});
	$("#log").dialog('open');
	
}

function LoginOverlay(form) {
	var login = form.login;
	var pass = form.pass;

	if(!validateEmail(login.value) || pass.value == "") {
		login.className = "inp_okienka_red";
		pass.className = "inp_okienka_red";
		$('#log_blad').html('Podaj poprawne dane.');
		$('#log_blad').show();

	} else {
		login.className = "inp_okienka";
		pass.className = "inp_okienka";
		$('#log_blad').html('trwa <img src="./img/loading.gif" alt="logowanie" />');
		$('#log_blad').show();
		var loginType = $('#loginType').val();
		if (_gaq) _gaq.push(['_trackPageview', 'logowanie.htm']);
		if(loginType=='recommend') {
			xajax_loginAjax(xajax.getFormValues("loginOverlay"),loginType);
		} else {
			xajax_loginAjax(xajax.getFormValues("loginOverlay"));
		}
	}

	return false;
}

function changeRecommendClick() {
	$('.recommendAnchor').removeAttr('onclick');
	$('.recommendAnchor').click(function() {
		showRecommendBox();
	});
}

function showLoggingError(msg) {
	$('#log_blad').html(msg);
}

function validateEmail(email){
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(email.match(emailRegEx)){
		return true;
	}else{
		return false;
	}
}

function checkIfEnterOverlay(e) {
	var iCode;
	if (e.keyCode) iCode = e.keyCode;
	else if (e.which) iCode = e.which;
	var keyChar = String.fromCharCode(iCode);
	if(keyChar == "\r")
	{
		LoginOverlay(document.loginOverlay);
		return false;
	}
}


function check_remove( text1, text2) {

	if (document.ppform.boxchecked.value == 0) {
		display_error( 'messagebox' , 'messageText' , text1 );
		//alert(text1);
		return false;
	} else {
		if (confirm(text2))
			return true;
		else
			return false;
	}
}

function confirm_global( text ) {

		if (confirm(text))
			return true;
		else
			return false;
}

function check_confirm( text1 ) {

		if (confirm(text1))
			return true;
		else
			return false;
}

function check_choose_one(text1) {

	if (document.ppform.boxchecked.value == 0) {
		display_error( 'messagebox' , 'messageText' , text1 );
		//alert(text1);
		return false;
	} else {
		return true;
	}
}

function check_choose_two(text1) {

	if (document.ppform.boxchecked.value != 2) {
		display_error( 'messagebox' , 'messageText' , text1 );
		//alert(text1);
		return false;
	} else {
		return true;
	}
}

function makePromoMessage(txt, button_1_text, button_1_action, button_2_text, button_2_action) {
	
	var btns = {};
	
	btns[button_1_text] = function(){ eval(button_1_action); };
	btns[button_2_text] = function(){ eval(button_2_action); };
		
	if (arguments.length == 6) {
		cl = (!arguments[5]) ? "$(this).dialog('close');" : arguments[5];
	} else if (arguments.length >= 7 && arguments[5] != '' && arguments[6] != '') {
		var action = arguments[6];
		btns[arguments[5]] = function(){ eval(action); };
		cl = (!arguments[7]) ? "$(this).dialog('close');" : arguments[7];
	} else {
		cl = (!arguments[7]) ? "$(this).dialog('close');" : arguments[7];
	}
	
	default_width = (arguments.length >=7) ? 500 : 370;
	t = (!arguments[8]) ? 'Komunikat' : arguments[8];
	// info_b
	// error_b
	// warning_b
	icon = (!arguments[9]) ? 'info_b' : arguments[9];
	w = (!arguments[10]) ? default_width+50 : arguments[10];
	
	$("#dialogPromo_ico").attr('class',icon);
	$("#dialogPromo").attr("title", t);
	$("#dialogPromo_tresc").html(txt);
	$("#dialogPromo_tresc").width('100%');
	$("#dialogPromo_tresc").css('text-align','left');
	
	$("#dialogPromo").dialog({
			modal: true,
			width: w,
			bgiframe: true,
			buttons: btns,
			close: function(ev, ui) { 
				location.href='/fp_order';
				$(this).dialog('destroy'); }
		});
	$('.ui-button').css('display','inline');
	$('.ui-button').css('margin','3px');
	$("#dialogPromo").dialog('open');
	
	return false;	
}

function fold( nr , image ) {

	var zwin = new Image();
	var rozwin = new Image();
	zwin.src =  'gfx/szablony/msg_zwin.gif';
	rozwin.src =  'gfx/szablony/msg_rozwin.gif';

	if (document.getElementById)
	{

		current = (document.getElementById(nr).style.display == 'block' || document.getElementById(nr).style.display == '') ? 'none' : 'block';
		document.getElementById(nr).style.display = current;
		document.images[image].src = (document.getElementById(nr).style.display == 'block') ? zwin.src : rozwin.src;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'block' || document.getElementById(nr).style.display == '') ? 'none' : 'block'
		document.all[nr].style.display = current;
		document.images[image].src = (document.all[nr].style.display == 'block') ? zwin.src : rozwin.src;

	}
}

/*
* Funkcja ukrywajaca pokazujaca wybrany element html o id= nr
*/
function blocking(nr)
{
	if (document.getElementById)
	{
		current = (document.getElementById(nr).style.display == 'block') ? 'none' : 'block';
		document.getElementById(nr).style.display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'block') ? 'none' : 'block'
		document.all[nr].style.display = current;
	}
	else if (document.layers)
	{
		var i = parseInt(nr.substr(nr.length-1,1));
		var replacing = heights[i-1];
		if (shown[i])
		{
			shown[i] = false;
			replacing = -replacing;
			document.layers[nr].visibility = 'hide';
			document.layers[nr].top = safe;
		}
		else
		{
			shown[i] = true;
			document.layers[nr].visibility = 'show';
			var tempname = 'header' + i;
			document.layers[nr].top = document.layers[tempname].top + headerheight;
		}
		for (j=(i+1);j<=max;j++)
		{
			name1 = 'header' + j;
			document.layers[name1].top += replacing;
			if (shown[j])
			{
				name2 = 'number' + j;
				document.layers[name2].top += replacing;
			}
		}
	}
	else alert ('Twoja przegl?darka nie obs?uguje ten funkcjonalno?ci !');
}

/* Funkcja pokazujaca/ukrywajaca dany element html */

	function display(id, wartosc)
	{
	  if (wartosc)
	  {
	  	//alert(id);
	    if (document.getElementById) document.getElementById(id).style.display = wartosc;
	    else if (document.all) document.all[id].style.display = wartosc;
	  }
	  else
	  {
	  	//alert('2 '+id);
	    var wart = "";
	    if (document.getElementById) wart = document.getElementById(id).style.display;
	    else if (document.all) wart = document.all[id].style.display;
	    return wart;
	  }
	}

	function display_error(messagebox_id, text_id, text_value)
	{
		if (document.getElementById) document.getElementById(messagebox_id).style.display = 'block';
	    else if (document.all) document.all[messagebox_id].style.display = 'block';
	  	//alert(id);
	  	if (document.getElementById) {
	  		document.getElementById(text_id).style.display = 'block';
	  		document.getElementById(text_id).innerHTML = text_value;
	  	}
	  	else if (document.all) {
	  		document.all[text_id].style.display = 'block';
	  		document.all[text_id].innerHTML = text_value;
	  	}


	}

	function hide_error(messagebox_id, text_id)
	{
	  	//alert(id);
	  	if (document.getElementById) {
	  		document.getElementById(text_id).style.display = 'none';
	  	}
	  	else if (document.all) {
	  		document.all[text_id].style.display = 'none';
	  	}
	    if (document.getElementById) document.getElementById(messagebox_id).style.display = 'none';
	    else if (document.all) document.all[messagebox_id].style.display = 'none';

	}

/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
* @param An alternative field name
*/
function checkAll( n, fldName) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.ppform;
	//var c = f.toggle.checked;
	var c = (f.toggle.value==1) ? true : false;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.ppform.boxchecked.value = n2;
	} else {
		document.ppform.boxchecked.value = 0;
	}
}

function uncheckAll( n, fldName) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.ppform;
	var c = false;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.ppform.boxchecked.value = n2;
	} else {
		document.ppform.boxchecked.value = 0;
	}
}

/**
*/
function taskIt( n, id, task ) {

	var f = document.ppform;
	fldName = 'cb';
	cb = eval( 'f.' + id );

	for (i=0; i < n; i++) {
		elem = eval( 'f.' + fldName + '' + i );
		if (elem) elem.checked = false;
	}
	document.ppform.boxchecked.value = 0;

	if (cb) {
		cb.checked = true;
		submitbutton(task);
	}
	return;
}

function sort( sortKey, sortDir, task ) {
	document.ppform.sortKey.value = sortKey;
	document.ppform.sortDir.value = sortDir;
	submitbutton(task);
}

function page( currPage ) {
	document.ppform.currentPage.value = currPage;
	submitbutton('');
}

function nextpage( currPage ) {
	document.ppform.currentPage.value = currPage;
	submitbutton('');
}

function deleteItem( id ,task) {
	if (!task) {
     task = 'remove';
  	}
	var f = document.ppform;
	cb = eval( 'f.' + id );
	if (cb) {
		cb.checked = true;
		submitbutton(task);
	}
	return false;
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.ppform.boxchecked.value++;
	}
	else {
		document.ppform.boxchecked.value--;
	}
}

/**
* Default function.  Usually would be overriden by the component
*/
function submitbutton(pressbutton) {
	submitform(pressbutton);
}

/**
* Submit the admin form
*/
function submitform(pressbutton){
	document.ppform.task.value=pressbutton;
	try {
		document.ppform.onsubmit();
		}
	catch(e){}
	document.ppform.submit();
}

/**
* Submit the control panel admin form
*/
function submitcpform(sectionid, id){
	document.ppform.sectionid.value=sectionid;
	document.ppform.id.value=id;
	submitbutton("edit");
}

/**
* Getting radio button that is selected.
*/
function getSelected(allbuttons){
	for (i=0;i<allbuttons.length;i++) {
		if (allbuttons[i].checked) {
			return allbuttons[i].value
		}
	}
}


function chgReturnValue( frmName, srcListName, srcName) {
	var form = eval( 'document.' + frmName );
	var srcName_ = eval( 'form.' + srcName );
	var srcList = eval( 'form.' + srcListName );
	var ret_value = '';

	for (var k=0, n=srcList.length; k < n; k++)
	{
		if (srcList.options[k].selected) {
			if (ret_value != '') ret_value = ret_value + '|';
			ret_value = ret_value + srcList.options[k].value;
		}
	}
	srcName_.value = ret_value;

	if (ret_value != '') {
		return true;
	} else {
		return false;
	}
}

function IsPrice(sText)
{
   var ValidChars = ".0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}

function IsNumber(sText)
{
   var ValidChars = ".0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
          if (i==0 && Char=='-')
          	IsNumber = true;
          else
          	IsNumber = false;
         }
      }
   return IsNumber;

}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

}


// Show/Hide functions for non-pointer layer/objects
function show(id) {
	if (document.layers) document.layers[id].visibility = "show";
	else if (document.getElementById)  document.getElementById(id).style.visibility = "visible";
	else if (document.all) document.all[id].style.visibility = "visible";
}

function hide(id) {
	if (document.layers) document.layers[id].visibility = "hide";
	else if (document.getElementById)  document.getElementById(id).style.visibility = "hidden";
	else if (document.all) document.all[id].style.visibility = "hidden";
}

function hideLoadingPage() {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById('hidepage').style.visibility = 'hidden';
	}
	else {
		if (document.layers) {  // Netscape 4
			document.hidepage.visibility = 'hidden';
		}
		else {  // IE 4
			document.all.hidepage.style.visibility = 'hidden';
		}
	}
}

function removebutton( task, text ) {

		if (confirm(text)) {
				submitbutton(task);
				return true;
		} else
			return false;

}

function isValidString(sString)
{
	if (sString != null && sString != "") {
		if ((sString.value.indexOf("'")!=-1) ||
			(sString.value.indexOf('"')!=-1) ||
			(sString.value.indexOf('\\')!=-1)) {
			sString.focus();
			return false;
		}
		else
			return true;
	} else
		return true;
}

function setAttr() {
	var element;
	var a=setAttr.arguments;
	var len = a.length;
	if (len>1) {
		var elem_id = a[0];
		var attr = a[1];
		if (document.getElementById)
	  		element = (len>2) ? eval('document.getElementById(elem_id).' + attr + ' = a[2];') : eval('document.getElementById(elem_id).' + attr + ';');
	  	else if (document.all)
	  		element = eval('document.all[elem_id].' + attr + ' = a[2];');
	  	else if(document.layers)
		 	element = eval('document.layers[elem_id].' + attr + ' = a[2];');
	} else
		return false;
}

function getAttr() {
	var element;
	var a=getAttr.arguments;
	var len = a.length;
	if (len > 0) {
		var elem_id = a[0];
		if (document.getElementById)
	  		element = (len>1) ? eval('document.getElementById(elem_id).' + a[1]):eval('document.getElementById(elem_id)');
	  	else if (document.all)
	  		element = (len>1) ? eval('document.all[elem_id].' + a[1]) : eval('document.all[elem_id]');
	  	else if(document.layers)
		 	element = (len>1) ? eval('document.layers[elem_id].' + a[1] ) : eval('document.layers[elem_id]');
		return element;
	} else
		return false;
}

function checkEnter(e)
{
	var iCode;
	if (e.keyCode) iCode = e.keyCode;
	else if (e.which) iCode = e.which;
	var keyChar = String.fromCharCode(iCode);
	if(keyChar == "\r")
	{
		return true;
	}
}

function collectionConstruct()
{
	this.collection = new Object();
	this.addFromDocument = function(sourceId,overwrite)
	{
		if(!overwrite && this.collection[sourceId])
		{
			return;
		}
		this.collection[sourceId] = mstd_getObjectPtr(sourceId);
	}

	this.addObject = function(objectId,objectPtr,overwrite)
	{
		if(!overwrite && this.collection[objectId])
		{
			return;
		}
		this.collection[objectId] = objectPtr;
	}

	this.get = function(objectId)
	{
		if(this.collection[objectId])
		{
			return this.collection[objectId];
		}
		else
		{
			return null;
		}
	}

	this.remove = function(objectId)
	{
		if(this.collection[objectId])
		{
			this.collection[objectId] = null;
		}
	}
}

var objectCollection = new collectionConstruct();


function pre_create()
{
	var base_element = document.createElement('SPAN');
	base_element.style.fontStyle = 'italic';
	base_element.style.textAlign = 'left';
	base_element.style.verticalAlign = 'middle';

	var element = document.createElement('IMG')
	element.src = '/images/kreciol_p.gif';
	element.style.marginRight = '0.5em';
	element.style.verticalAlign = 'middle';
	base_element.appendChild(element);
	element = document.createTextNode('Zapisuję...');
	base_element.appendChild(element);

	return base_element;
}


function pre_start(frameId,inputId)
{

	var frameObjPtr = null;
	var inputObjPtr = null;

	switch(typeof(frameId))
	{
		case 'object':
			frameObjPtr = frameId;
			break;
		default:
			frameObjPtr = getAttr(frameId);
	}

	switch(typeof(inputId))
	{
		case 'object':
			inputObjPtr = inputId;
			break;
		default:
			inputObjPtr = getAttr(inputId);
	}

	if(!frameObjPtr || !inputObjPtr) {return};

	objectCollection.addObject(inputObjPtr.id,frameObjPtr.removeChild(inputObjPtr));
	objectCollection.addObject(inputObjPtr.id+'_hg',pre_create())
	frameObjPtr.appendChild(objectCollection.get(inputObjPtr.id+'_hg'));

}

function pre_stop(frameId,inputId)
{

	var frameObjPtr = null;
	var inputObjId 	= '';

	switch(typeof(frameId))
	{
		case 'object':
			frameObjPtr = frameId;
			break;
		default:
			frameObjPtr = getAttr(frameId);
	}

	switch(typeof(inputId))
	{
		case 'object':
			inputObjId = inputId.id;
			break;
		default:
			inputObjId = inputId;
	}
	if(!frameObjPtr || !inputObjId) {return}

    frameObjPtr.removeChild(objectCollection.get(inputObjId+'_hg'));
	objectCollection.remove(inputObjId+'_hg');
	frameObjPtr.appendChild(objectCollection.get(inputObjId));

  return 1;

}

function image_preload(id)
{
	if(getAttr(id,'is_loaded'))
	{
		return;
	}
	if(!getAttr(id,'image_ptr'))
	{
		setAttr(id,'image_ptr',getAttr(id));
	}
	loadImage(getAttr(id,'image_ptr'));
	if (getAttr(id,'image_ptr').className=='ff_preload' && getAttr(id,'image_ptr').is_loaded) {
		getAttr(id,'image_ptr').className = 'ffoto';
	} else if (getAttr(id,'image_ptr').className=='bpreload') {
		getAttr(id,'image_ptr').className = 'bffoto';
	} else if (getAttr(id,'image_ptr').className=='ord_preload') {
		getAttr(id,'image_ptr').className = 'ord_foto';
	} else
		getAttr(id,'image_ptr').className = 'mfoto';
}


function loadImage(image_ptr)
{
	var new_image = null;
	if(image_ptr.name && (image_ptr.src != image_ptr.name))
	{
		new_image = new Image();
		new_image.src = image_ptr.name;
		new_image.onLoad = showLoadedImage(new_image,image_ptr);
	}
}

function showLoadedImage(src_ptr,target_ptr)
{
	target_ptr.src = src_ptr.src;
	target_ptr.is_loaded = 1;

}
var hide_time = 0;
function hide_timer(time) {
	time = time - 1000;
	if (time > 0) {
		getAttr('timer').innerHTML = Math.round(time/1000) + ' s.';
		hide_time = setTimeout('hide_timer('+time+');',1000);
	} else {
		hide_error('logbox','logText');
		return true;
	}
}
function messageTime(id, text_id, time) {
	var el = getAttr(id);
	clearTimeout(hide_time);
	hide_timer(time*1000);
}

function getPrice(price,fix) {
	var n=parseFloat(price);
	if (isNaN(n)) return "--,--";
	var p = n.toFixed(fix);
	var s = p.toString();
	return s.replace(/\./g,",");
}

function setTopHeight(idx) {
	var toplen;
	if (self.pageYOffset) {
		toplen = self.pageYOffset + 290;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		toplen = document.documentElement.scrollTop + 290;
	} else if (document.body) {
		toplen = document.body.scrollTop + 290;
	}
	setAttr(idx,'style.top',toplen+'px');
}

function openPage( form, currPage ) {
form.page.value = currPage;

try {
form.onsubmit();
}
catch(e){}
form.submit();
}


function csubmitform(pressbutton, form2){

	var form = eval('document.'+form2);

	form.task.value=pressbutton;
	try {
		form.onsubmit();

		}
	catch(e){}

	form.submit();

}

function clearInp(obj, tekst) {
	if(obj.value == tekst) obj.value = "";
}

function insertInp(obj, tekst) {
	if(obj.value == "") obj.value = tekst;
}

//---- mapa

function array_search(arr,val){
	for (var i=0; i<arr.length; i++)
		if (arr[i] == val)
			return i;
	return false;
}


var aPkt = new Array();
var aPktIdent = new Array();

var aPkt_tmp1 = new Array();
var aPktIdent_tmp1 = new Array();

var aPkt_tmp2 = new Array();
var aPktIdent_tmp2 = new Array();

//var aPkt = new Array(
//	new Array(0, 'nazwa1', 'adres1', 50.0070715, 19.9634099),
//	new Array(1, 'nazwa3', 'adres3', 50.0428466, 19.9268626)
//);
//aPkt[9] = new Array(9, 'nazwa9', 'adres9', 50.0818203, 20.0253792);
//
//var aPktIdent = new Array(0,1,9);

var gmarkers = new Array();
var map;
var isMapMade1 = false;
var isMapMade2 = false;
var pwybor = false;
var gmap_zoom = 15;

function showGmap(id) {

	isMapMade2 = false;

	if(!isMapMade1) {

		aPkt = 	aPkt_tmp1;
		aPktIdent = aPktIdent_tmp1;
		gmarkers = new Array();

		$("#dialogGmap").dialog({
			modal: true,
			width:900,
			height:500,
			bgiframe: true,
			buttons: {
					'Zamknij': function() { $(this).dialog('close'); }
			},
			resize: function(event, ui) { if (map) map.checkResize(); }
		});
		isMapMade1 = true;
		$("#dialogGmap").dialog('open');
		makeMap(id);

	} else {

		$("#dialogGmap").dialog('open');
		var center = new GLatLng(aPkt[id][3], aPkt[id][4]);
		map.setCenter(center, 15);
		myclick(id);
	}
}

function showGmap2(id) {
	isMapMade1 = false;

	if(!isMapMade2) {

		aPkt = 	aPkt_tmp2;
		aPktIdent = aPktIdent_tmp2;
		gmarkers = new Array();

		$("#dialogGmap").dialog({
			modal: true,
			width:900,
			height:500,
			bgiframe: true,
			buttons: {
					'Zamknij': function() { $(this).dialog('close'); }
			},
			resize: function(event, ui) { if (map) map.checkResize(); }
		});
		isMapMade2 = true;
		$("#dialogGmap").dialog('open');
		makeMap(id);

	} else {

		$("#dialogGmap").dialog('open');
		var center = new GLatLng(aPkt[id][3], aPkt[id][4]);
		map.setCenter(center, 15);
		myclick(id);
	}
}

function createMarker(point, nazwa, street, idpk) {
	var marker = new GMarker(point);
	var i = gmarkers.length;
	gmarkers.push(marker);


	GEvent.addListener(marker, "click", function() {
		var iwAnchor = marker.getIcon().infoWindowAnchor;
		var iconAnchor = marker.getIcon().iconAnchor;
		var offset = new GSize(iwAnchor.x-iconAnchor.x,iwAnchor.y-iconAnchor.y);
		var dymek_html = '<b>'+nazwa+'</b><br />'+street;
			if(pwybor) dymek_html += '<br /><div class="wybierz_punkt" style="margin-bottom:5px;float:right"><a href="javascript:void(0);" onclick="setMiejsceodbioru('+idpk+'); closeMap();"></a></div>';
		map.openInfoWindowHtml(marker.getLatLng(), dymek_html, {pixelOffset:offset});
	});

	return marker;
}


function myclick(clickid) {
	GEvent.trigger(gmarkers[array_search(aPktIdent, clickid)],"click");
}


function makeMap(clickid) {

	for(i=0; i < aPktIdent.length; i++) {
		var t = aPktIdent[i];

		var point = new GLatLng(aPkt[t][3],aPkt[t][4]);
		var marker = createMarker(point,aPkt[t][1], aPkt[t][2], aPkt[t][0]);
	}

	map = new GMap2(document.getElementById("gmappkt"));


	var center = new GLatLng(aPkt[clickid][3], aPkt[clickid][4]);
	map.setCenter(center, gmap_zoom);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.enableScrollWheelZoom();
    var mm = new GMarkerManager(map);

    mm.addMarkers(gmarkers,0,17);
    mm.refresh();


	setTimeout(function() {myclick(clickid); },10);
}

function openGMap(idCity, idRegion) {
	xjxargs = new Array();
	xjxargs[0] = idCity;
	xjxargs[1] = idRegion;
	
	showLoader('Ładowanie mapy, proszę czekać...');
	var width = $(window).width() - 200;
	var height = $(window).height() - 200;

	$('.loader_ajax').css("top", ((($(window).height() - $('#steps').height()) / 2) + 50) + $(window).scrollTop() + "px");
	showLoader('Proszę czekać. ładowanie mapy ...');
	
	$.post('/xajax',{'xjxargs[]' : xjxargs, 'xjxfun': 'getCoords', 'xjxr': new Date().getTime()},function(data) {
		var obj = eval('(' + data + ')');
		
		gmarkers = new Array();

		$("#dialogGmap").dialog({
			modal: true,
			width:width,
			height:height,
			bgiframe: true,
			buttons: {
					'Zamknij': function() { $(this).dialog('close'); }
			},
			resize: function(event, ui) { if (map) map.checkResize(); }
		});
		$("#dialogGmap").dialog('open');
		
		for(i=0; i < obj.length; i++) {
		
			var point = new GLatLng(obj[i]['latitude'], obj[i]['longitude']);
			var marker = createMarker(point,obj[i]['name'], obj[i]['street'], obj[i]['idphoto_point_gm']);
		}
		
		map = new GMap2(document.getElementById("gmappkt"));
		GEvent.addListener(map, "load", function() {
			hideLoader();
		});
		
		if(parseInt(idCity)==0) {
			var center = new GLatLng(obj[0]['state_latitude'], obj[0]['state_longitude']);
			map.setCenter(center, 8);
			
		} else {
			var center = new GLatLng(obj[0]['latitude'], obj[0]['longitude']);
			map.setCenter(center, gmap_zoom);
		}
		
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.enableScrollWheelZoom();
	    var mm = new GMarkerManager(map);

	    mm.addMarkers(gmarkers,0,17);
	    mm.refresh();
	});
}

function checkEnter2(e,funct) {
	var iCode;
	if (e.keyCode) iCode = e.keyCode;
	else if (e.which) iCode = e.which;
	var keyChar = String.fromCharCode(iCode);
	if(keyChar == "\r")
	{
		eval(funct);
		return false;
	}
}


function checkInvoice(form) {
	var sPostCodeRegExp = /^[0-9]{2}\-[0-9]{3}$/i;
	var sNipRegExp = /^[0-9]{10}$/i;


	if(form.invoice.checked) {
		$('#i_company, #i_street, #i_street_nr, #i_city, #i_zipcode, #i_nip').removeClass("errHilite");

		if($('#i_company').val().length < 1 || trim($('#i_company').val()) == "") {

			$('#i_company').addClass("errHilite").focus();
			display_error('messagebox','messageText','Podaj nazwę do faktury.');
			return false;

		} else if($('#i_street').val().length < 1 || trim($('#i_street').val()) == "") {

			$('#i_street').addClass("errHilite").focus();
			display_error('messagebox','messageText','Podaj ulicę do faktury.');
			return false;

		} else if($('#i_street_nr').val().length < 1 || trim($('#i_street_nr').val()) == "") {

			$('#i_street_nr').addClass("errHilite").focus();
			display_error('messagebox','messageText','Podaj nr domu/lokalu do faktury.');
			return false;

		} else if($('#i_city').val().length < 1 || trim($('#i_city').val()) == "") {

			$('#i_city').addClass("errHilite").focus();
			display_error('messagebox','messageText','Podaj miejscowość do faktury.');
			return false;

		} else if(!$('#i_zipcode').val().match(sPostCodeRegExp)) {

			$('#i_zipcode').addClass("errHilite").focus();
			display_error('messagebox','messageText','Podaj poprawny kod pocztowy do faktury.');
			return false;

		} else if(!$('#i_nip').val().match(sNipRegExp)) {

			$('#i_nip').addClass("errHilite").focus();
			display_error('messagebox','messageText','Podaj poprawny nip do faktury.');
			return false;

		} else {

			hide_error('messagebox','messageText');
			return true;

		}



	} else {
		hide_error('messagebox','messageText');
		return true;
	}
}

function pageSize() {
	
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
	
}

function showLoader(str) {
	if(str) {
		
	} else {
		str = 'Proszę czekać...';
	}
	
	$('#loader_overlay').show();
	$('#loader_ajax_span').html(str);
	var pSize = pageSize();
	$('#loader_overlay').height(pSize[1]);
	$('.loader_ajax').fadeIn();
}

function hideLoader() {
	$('.loader_ajax').fadeOut(function() {
		$('#loader_overlay').hide();
	});
}


/*
 * Polecanie Przyjacielowi
 */

function showRecommendBox() {
	closeRecommendBox();
	$('#lastRecommendId').val(0);
	$('body:last-child').append('<div id="recommendBoxOverlay"></div><div id="recommendBox"><div id="recommendHead"><a onclick="closeRecommendBox(); return false;" href="#"><img alt="" src="/images/polec_przyjacielowi/x.png" /></a></div><div class="clear"></div><div id="nameAndMailRecommend"><span>Adresaci:</span></div><div class="clear"></div><div id="recommendInputs"></div><a class="pinkRecommend" href="#" style="outline: medium none;" onclick="addRecommendInput(); return false;"><span class="recommendPlus"><img alt="" src="/images/polec_przyjacielowi/plus.png" /></span>więcej przyjaciół</a><div class="clear"></div><textarea disabled="disabled" id="recommendText">Cześć. Polecam Ci znakomity serwis FotoPrint.com.pl oferujący najtańsze i najszybsze odbitki zdjęć w Internecie!</textarea><a id="recommendationButton" href="#" onclick="sendRecommendation(); return false;"><img style="border: 0 none;" alt="" src="/images/polec_przyjacielowi/polecam.png" /></a><div class="recommendError"></div></div><input id="lastRecommendId" type="hidden" value="0" />');
	$('#recommendBox').css('left',($('body').width()/2)-($('#recommendBox').width()/2) );
	addRecommendInput();
	$('#recommendBoxOverlay').css('height','100%');
}

function enterNameInput(ev) {
	if($(ev).val() =='Imię Przyjaciela') {
		$(ev).val('');
	}
	$(ev).css('color','black');
}

function enterEmailInput(ev) {
	if($(ev).val() =='E-mail') {
		$(ev).val('');
	}
	$(ev).css('color','black');
}

function addRecommendInput() {
	var actualNumber = parseInt($('#lastRecommendId').val() );
	if(actualNumber < 4) {
		var nextNumber = actualNumber + 1;
		$('#recommendInputs').append('<div style="margin-top: 10px;"><input onmouseover="if($(this).val()==\'Imię Przyjaciela\') $(this).empty(); return false;" onblur="if($(this).val().length==0) {$(this).val(\'Imię Przyjaciela\'); $(this).css(\'color\',\'gray\');}" id="friendName_'+nextNumber+'" class="recommendInput" onclick="enterNameInput(this); return false" value="Imię Przyjaciela" style="color: gray;" /><input onclick="enterEmailInput(this); return false" onmouseover="if($(this).val()==\'E-mail\') $(this).empty(); return false;" onblur="if($(this).val().length==0) {$(this).val(\'E-mail\'); $(this).css(\'color\',\'gray\');}" id="friendEmail_'+nextNumber+'" style="margin-left: 8px; color: gray;" class="recommendInput" value="E-mail" /></div><div class="clear"></div>');
		$('#lastRecommendId').val(nextNumber);
	} else {
		$('.pinkRecommend').remove();
	}
	$('.recommendInput').keydown(function() {
		if($(this).val()=='Imię Przyjaciela' || $(this).val()=='E-mail') {
			$(this).val('');
			$(this).css('color','black');
		}
	});
}

function closeRecommendBox() {
	$('#recommendBoxOverlay').remove();
	$('#recommendBox').fadeOut(function() {
		$(this).remove();
	});
}

function sendRecommendation() {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var howMany = parseInt($('#lastRecommendId').val() );
	var xjxargs = new Array();
	var i = 0;
	var errorEm = 0;
	var errorN = 0;
	var errorDiv = '';

	while(howMany > 0) {
		xjxargs[i] = new Array();
		if(reg.test($('#friendEmail_'+howMany).val() ) == true) {
		} else {
			$('#friendEmail_'+howMany).css('color','red');
			errorEm = 1;
		}

		if($('#friendName_'+howMany).val().length > 1 && $('#friendName_'+howMany).val()!='Imię Przyjaciela') {
		} else {
			$('#friendName_'+howMany).css('color','red');
			errorN = 1;
		}

		if(errorEm==0 && errorN==0) {
			xjxargs[i][0] = $('#friendName_'+howMany).val();
			xjxargs[i][1] = $('#friendEmail_'+howMany).val();
		}
		howMany--;
		i++;
	}

	if(errorEm==1 || errorEm==1) {
		errorDiv = '<p>Sprawdź poprawność wprowadzonych adresów e-mail oraz imion przyjaciół.</p>';
	}
	$('.recommendError').html(errorDiv);
	if(errorEm==0 && errorN==0) {
		showLoader('Trwa wysyłanie e-maili, proszę czekać...');
		xajax_sendRecommendation(xjxargs);
	} else {
		return false;
	}
}

function showRecommendationEnd(valid,invalid) {
	var text = $('#recommendText').val();
	var divCont = '<div id="recommendHead"><a onclick="closeRecommendBox(); return false;" href="#"><img alt="" src="/images/polec_przyjacielowi/x.png" /></a></div><div class="clear"><br /><br /><div style="margin-left: 98px;text-align: left;"><span>Twoja wiadomość o treści:</span><p style="font-weight:normal; margin-top: 5px; width:337px">'+text+'</p></div><div style="margin-left: 45px; margin-top: 15px;"></div><a onclick="closeRecommendBox(); return false;" style="position: absolute; float: right; bottom: 302px; right: 147px;" href="#"><img alt="" src="/images/polec_przyjacielowi/zamknij.png" style="border: 0pt none;"></a>';
	var invalidDiv = '';
	var validDiv = '';

	if(valid) {
		validDiv = '<div style="font-weight:bold; margin-top: 2px; margin-left: 99px;text-align:left;">została wysłana na następujące adresy:';
		for(var i=0;i<valid.length;i++) {
			validDiv = validDiv + '<div style="font-weight:normal; margin-top: 5px;">'+valid[i][1]+' / '+valid[i][0]+'</div>';
		}
		validDiv += '</div>';
	}

	if(invalid) {
		validDiv = '<div style="font-weight:bold; margin-top: 2px; margin-left: 99px;text-align:left;">nie została wysłana z powodu błędu na następujące adresy:';
		for(var i=0;i<invalid.length;i++) {
			invalidDiv = invalidDiv + '<div style="font-weight:normal; margin-top: 2px; margin-left: 99px;text-align:left;">'+invalid[i][1]+' / '+invalid[i][0]+'</div>';
		}
		validDiv += '</div>';
	}

	divCont += validDiv;
	divCont += invalidDiv;
	divCont += '</div><input id="lastRecommendId" type="hidden" value="0" />';
	$('#recommendBox').html(divCont);
	hideLoader();
}

function makeMessage2(txt) {
	
	t = (!arguments[1]) ? 'Komunikat' : arguments[1];
	// info_b
	// error_b
	// warning_b
	icon = (!arguments[2]) ? 'info_b' : arguments[2];
	w = (!arguments[3]) ? 350 : arguments[3];
	c = (!arguments[4]) ? '$(this).dialog(\'close\');' : arguments[4];


	document.getElementById('dialog_ico').className = icon;
	document.getElementById('dialog').setAttribute("title", t);
	document.getElementById('dialog_tresc').innerHTML = txt;


	$("#dialog").dialog({
		modal: true,
		width: w,
		bgiframe: true,
		buttons: {
				'OK': function() { eval(c); }
		},
		close: function() { $("#dialog").dialog('destroy'); }
	});
	$("#dialog").dialog('open');

	return false;
}

/*
 * Polecanie Przyjacielowi
 */

function showRecommendBox() {
	closeRecommendBox();
	$('#lastRecommendId').val(0);
	$('body:last-child').append('<div id="recommendBoxOverlay"></div><div id="recommendBox"><div id="recommendHead"><a onclick="closeRecommendBox(); return false;" href="#"><img alt="" src="/images/polec_przyjacielowi/x.png" /></a></div><div class="clear"></div><div id="nameAndMailRecommend"><span>Adresaci:</span></div><div class="clear"></div><div id="recommendInputs"></div><a class="pinkRecommend" href="#" style="outline: medium none;" onclick="addRecommendInput(); return false;"><span class="recommendPlus"><img alt="" src="/images/polec_przyjacielowi/plus.png" /></span>więcej przyjaciół</a><div class="clear"></div><textarea disabled="disabled" id="recommendText">Cześć. Polecam Ci znakomity serwis FotoPrint.com.pl oferujący najtańsze i najszybsze odbitki zdjęć w Internecie!</textarea><a id="recommendationButton" href="#" onclick="sendRecommendation(); return false;"><img style="border: 0 none;" alt="" src="/images/polec_przyjacielowi/polecam.png" /></a><div class="recommendError"></div></div><input id="lastRecommendId" type="hidden" value="0" />');
	$('#recommendBox').css('left',($('body').width()/2)-($('#recommendBox').width()/2) );
	addRecommendInput();
	$('#recommendBoxOverlay').css('height','100%');
}

function enterNameInput(ev) {
	if($(ev).val() =='Imię Przyjaciela') {
		$(ev).val('');
	}
	$(ev).css('color','black');
}

function enterEmailInput(ev) {
	if($(ev).val() =='E-mail') {
		$(ev).val('');
	}
	$(ev).css('color','black');
}

function addRecommendInput() {
	var actualNumber = parseInt($('#lastRecommendId').val() );
	if(actualNumber < 4) {
		var nextNumber = actualNumber + 1;
		$('#recommendInputs').append('<div style="margin-top: 10px;"><input onmouseover="if($(this).val()==\'Imię Przyjaciela\') $(this).empty(); return false;" onblur="if($(this).val().length==0) {$(this).val(\'Imię Przyjaciela\'); $(this).css(\'color\',\'gray\');}" id="friendName_'+nextNumber+'" class="recommendInput" onclick="enterNameInput(this); return false" value="Imię Przyjaciela" style="color: gray;" /><input onclick="enterEmailInput(this); return false" onmouseover="if($(this).val()==\'E-mail\') $(this).empty(); return false;" onblur="if($(this).val().length==0) {$(this).val(\'E-mail\'); $(this).css(\'color\',\'gray\');}" id="friendEmail_'+nextNumber+'" style="margin-left: 8px; color: gray;" class="recommendInput" value="E-mail" /></div><div class="clear"></div>');
		$('#lastRecommendId').val(nextNumber);
	} else {
		$('.pinkRecommend').remove();
	}
	$('.recommendInput').keydown(function() {
		if($(this).val()=='Imię Przyjaciela' || $(this).val()=='E-mail') {
			$(this).val('');
			$(this).css('color','black');
		}
	});
}

function closeRecommendBox() {
	$('#recommendBoxOverlay').remove();
	$('#recommendBox').fadeOut(function() {
		$(this).remove();
	});
}

function sendRecommendation() {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var howMany = parseInt($('#lastRecommendId').val() );
	var xjxargs = new Array();
	var i = 0;
	var errorEm = 0;
	var errorN = 0;
	var errorDiv = '';
	
	while(howMany > 0) {
		xjxargs[i] = new Array();
		if(reg.test($('#friendEmail_'+howMany).val() ) == true) {
		} else {
			$('#friendEmail_'+howMany).css('color','red');
			errorEm = 1;
		}
		
		if($('#friendName_'+howMany).val().length > 1 && $('#friendName_'+howMany).val()!='Imię Przyjaciela') {
		} else {
			$('#friendName_'+howMany).css('color','red');
			errorN = 1;
		}
		
		if(errorEm==0 && errorN==0) {
			xjxargs[i][0] = $('#friendName_'+howMany).val();
			xjxargs[i][1] = $('#friendEmail_'+howMany).val();
		}
		howMany--;
		i++;
	}
	
	if(errorEm==1 || errorEm==1) {
		errorDiv = '<p>Sprawdź poprawność wprowadzonych adresów e-mail oraz imion przyjaciół.</p>';
	}
	$('.recommendError').html(errorDiv);
	if(errorEm==0 && errorN==0) {
		showLoader('Trwa wysyłanie e-maili, proszę czekać...');
		xajax_sendRecommendation(xjxargs);
	} else {
		return false;
	}
}

function showRecommendationEnd(valid,invalid) {
	var text = $('#recommendText').val();
	var divCont = '<div id="recommendHead"><a onclick="closeRecommendBox(); return false;" href="#"><img alt="" src="/images/polec_przyjacielowi/x.png" /></a></div><div class="clear"><br /><br /><div style="margin-left: 98px;text-align: left;"><span>Twoja wiadomość o treści:</span><p style="font-weight:normal; margin-top: 5px; width:337px">'+text+'</p></div><div style="margin-left: 45px; margin-top: 15px;"></div><a onclick="closeRecommendBox(); return false;" style="position: absolute; float: right; bottom: 302px; right: 147px;" href="#"><img alt="" src="/images/polec_przyjacielowi/zamknij.png" style="border: 0pt none;"></a>';
	var invalidDiv = '';
	var validDiv = '';
	
	if(valid) {
		validDiv = '<div style="font-weight:bold; margin-top: 2px; margin-left: 99px;text-align:left;">została wysłana na następujące adresy:';
		for(var i=0;i<valid.length;i++) {
			validDiv = validDiv + '<div style="font-weight:normal; margin-top: 5px;">'+valid[i][1]+' / '+valid[i][0]+'</div>';
		}
		validDiv += '</div>';
	}
	
	if(invalid) {
		validDiv = '<div style="font-weight:bold; margin-top: 2px; margin-left: 99px;text-align:left;">nie została wysłana z powodu błędu na następujące adresy:';
		for(var i=0;i<invalid.length;i++) {
			invalidDiv = invalidDiv + '<div style="font-weight:normal; margin-top: 2px; margin-left: 99px;text-align:left;">'+invalid[i][1]+' / '+invalid[i][0]+'</div>';
		}
		validDiv += '</div>';
	}

	divCont += validDiv;
	divCont += invalidDiv;
	divCont += '</div><input id="lastRecommendId" type="hidden" value="0" />';
	$('#recommendBox').html(divCont);
	hideLoader();
}
 
