/**
*   @version $Id$
*	@package frontend
*	@author piotrj
*/

/**--------------------------------------------------------------------
*	zamowienia/zapytania
*---------------------------------------------------------------------*/
var orderFormAction = '#';
var currentOrderStep = 0;

	/**
	*	Opis: ustawia ktora transakcja ma zmienic stan i status, oraz na jakie wartosci
	*/
	function moveToBasketFromTransaction( id, text )
	{
		if( confirm( text ) )
		{
			$( "moveToBasketFromTransaction" ).value = id;
			$( "koszykmem" ).submit();
		}
	}

	/**
	*	Opis: sbmituje zmiane w ofercie aukcyjnej
	*/
	function switchDeliveryTabs( tabNum )
	{
		for( var i = 1; i <= 2; i++ )
		{
			tabVis = 'none';
			if( i == tabNum )
			{
				tabVis = 'block';
			}
			$( "deliveryTab"+i+"" ).style.display = tabVis;
		}
		/*if( tabNum == 1 )
		{
			$( "topCourierPrice" ).style.display = 'block';
		}
		else
		{
			$( "topCourierPrice" ).style.display = 'none';
		}*/
	}

	/**
	*	Opis: dodaje produkt do koszyka
	*/
	function setStep( stepNum )
	{
		//$( "basketStep" ).value = stepNum;
		$( "orderform" ).target = "_self";
		$( "orderform" ).action = orderFormAction+'/step/'+( stepNum+1 );
		$( "orderform" ).submit();
	}

	/**
	*	Opis: dodaje produkt do koszyka
	*/
	function nextStep( txt, stepNum, a_text, a_text1, a_text2  )
	{
		if( stepNum == 0 )
		{
			//$( "basketStep" ).value = stepNum+1;
			var ok = 1;
			var textToAlert = Array( '', '', '' );
			var alertText = '';
			var fieldsToCheck = Array(  'cpname', 'cpsurname', 'cpstreet', 'cpcity', 'cppostcode', 'cpphone', 'cpnip', 'dpname', 'dpsurname', 'dpstreet', 'dpcity', 'dppostcode', 'dpphone', 'dpinstitution', 'dpdepartment' );
			for( var i = 0; i <= 14; i++ )
			{
				oObj = $( fieldsToCheck[i] );
				oVal = oObj.value;
				re = /[\s\t\r\n]+/g;
				oVal = oVal.replace( re, '' );
				if( oVal == '' )
				{
					oObj.className = 'textLF1';
					ok = 0;
					textToAlert[0] = a_text+"\n";
				}
				else
				{
					oObj.className = 'textLF0';
				}
			}
			if( checkPostCode( $( 'cppostcode' ).value ) == 0 )
			{
				ok = 0;
				$( 'cppostcode' ).className = 'textLF1';
				textToAlert[1] = a_text1+"\n";
			}
			if( checkNip( $( 'cpnip' ).value ) == 0 ) 
			{
				ok = 0;
				$( 'cpnip' ).className = 'textLF1';
				textToAlert[2] = a_text2+"\n";
			}
			if( checkPostCode( $( 'dppostcode' ).value ) == 0 )
			{
				ok = 0;
				$( 'dppostcode' ).className = 'textLF1';
				textToAlert[1] = a_text1+"\n";
			}
			if( ( $( 'dpnip' ).value != '' ) && ( checkNip( $( 'dpnip' ).value ) == 0 ) ) 
			{
				ok = 0;
				$( 'dpnip' ).className = 'textLF1';
				textToAlert[2] = a_text2+"\n";
			}
			for( var i = 0; i <= 2; i++ )
			{
				alertText += textToAlert[i];
			}
			
			if( ok == 1 )
			{
				$( "orderform" ).target = "_self";
				$( "orderform" ).action = orderFormAction+'/step/'+( stepNum+2 );
				$( "orderform" ).submit();
			}
			else
			{
				alert( alertText );
			}
		}
		else if( stepNum == 1 )
		{
			//$( "deliveryTypeDetails" ).value = delTypDet;
			//$( "basketStep" ).value = stepNum+1;
			$( "orderform" ).target = "_self";
			$( "orderform" ).action = orderFormAction+'/step/'+( stepNum+2 );
			$( "orderform" ).submit();
		}
		else if( stepNum == 2 )
		{
			//if( $( "paymentType1" ).checked || $( "paymentType2" ).checked )
			//{
				ok = 1;
			/*}
			else
			{
				ok = 0;
			}*/
			if( ok == 1 )
			{
				//$( "basketStep" ).value = stepNum+1;
				$( "orderform" ).target = "_self";
				$( "orderform" ).action = orderFormAction+'/step/'+( stepNum+2 );
				$( "orderform" ).submit();
			}
			else
			{
				alert( txt );
			}
		}
	}

	/**
	*	Opis: dodaje produkt do koszyka
	*/
	function deleteFromBasket( basketId )
	{
		$( "idtodelete" ).value = basketId;
		$( "orderform" ).target = "_self";
		$( "orderform" ).action = orderFormAction;
		$( "orderform" ).submit();
	}
	
	/**
	*	Opis: dodaje produkt do koszyka
	*/
	function deleteAllFromBasket()
	{
		$( "deleteall" ).value = 1;
		$( "orderform" ).target = "_self";
		$( "orderform" ).action = orderFormAction;
		$( "orderform" ).submit();
	}

	/**
	*	Opis: dodaje produkt do koszyka
	*/
	function setFullBasket( productCount )
	{
		var fullBasketOrder = '';
		for( var i = 0; i < productCount; i++ )
		{
			if( fullBasketOrder != '' )
			{
				fullBasketOrder += '|';
			}
			/*
			id koszyka z tabeli bmbasketmemory
			komentarz uzytkownika
			ilosc produktow
			*/
			n1 = "ordcode"+i+"";
			n2 = "kpr"+i+"";
			fullBasketOrder += ''+$( n1 ).value+'++'+$( n2 ).value+'';
		}
		$( "fullbasket" ).value = fullBasketOrder;
		$( "orderform" ).target = "_self";
		$( "orderform" ).action = orderFormAction;
		$( "orderform" ).submit();
	}

	/**
	*	Opis: wysyla zamowienie
	*/
	function sendOrder( a_text, a_text2 )
	{
		//if( $( "acceptregulations" ).checked )
		//{
			if( confirm( a_text ) )
			{
				//$( "ordzamow" ).value = 1;
				$( "ordertype" ).value = 1;
				$( "orderform" ).target = "_self";
				$( "orderform" ).action = orderFormAction+'/wyslij_zamowienie';
				$( "orderform" ).submit();
			}
		//}
		//else
		//{
		//	alert( a_text2 );
		//}
	}

	/**
	*	Opis: wysyla zamowienie
	*/
	function sendOrder_old( a_text, a_type, a_text2, a_logged, a_order, productCount )
	{
		if( a_logged == 1 )
		{
			if( $( "regulamin" ).checked == true )
			{
				ok = 1;
			}
			else
			{
				ok = 0;
			}
		}
		else
		{
			ok = 1;
		}
		if( ok == 1 )
		{
			//exprovince
			provinceChosen = 0;
			if( ( sObj = $( "dlProvince" ) ) || ( sObj = $( "ordProvince" ) ) || ( sObj = $( "exprovince" ) ) )
			{
				provinceChosen = sObj.value
			}
			if( ( ( a_type == 1 ) || ( ( $( "exname" ).value != "" ) && ( $( "exsurname" ).value != "" ) && ( $( "exmail" ).value != "" ) && ( $( "exphone" ).value != "" ) && ( provinceChosen > 0 ) ) ) && ( $( "captchaCode" ).value != "" ) )
			{
				$( "ordzamow" ).value = 1;
				if( a_order == 1 )
				{
					$( "ordertype" ).value = 1;
				}
				else
				{
					$( "ordertype" ).value = 0;
				}
				setFullBasket( productCount );
				//setOrder( 0, 0 );
			}
			else
			{
				alert( a_text );
			}
		}
		else
		{
			alert( a_text2 );
		}
	}

	/**
	*	Opis: dodaje produkt do koszyka
	*/
	function setOrder( a_id, a_del )
	{
		oInp = $( "kpr"+a_id );
		if( !myIsInt( oInp.value, 1, 10 ) )
		{
			oInp.value = 1;
		}
		if( a_del == 1 )
		{
			todel = a_id;
		}
		else
		{
			todel = -1;
		}
		num = 0;
		name = "ordcode"+num;
		fullcode = "";
		while( l_code = $( name ) )
		{
			if( num != todel )
			{
				ilosc = $( "kpr"+num ).value;
				fullcode += l_code.value+"+"+ilosc+"|";
			}
			num++;
			name = "ordcode"+num;
		}
		$( "setfull" ).value = 1;
		$( "fullorder" ).value = fullcode;
		$( "orderform" ).target = "_self";
		$( "orderform" ).action = orderFormAction;
		$( "orderform" ).submit();
	}
	
	var poccSlide = null;
	
	function showOrderElem( productId, bmOrderCodeIds, priceVis, pageLang, pageLangNum )
	{
		var oDiv = $( 'orderShowOrderElemDiv' );
		manageSelectsAll( 'hidden' );
		LightboxForData.show( 'hideOrderElem()', 'orderShowOrderElemDiv' );
		var dataToSend = "productId="+productId+"&bmOrderCodeIds="+bmOrderCodeIds+"&priceVis="+priceVis+"&lang="+pageLang+"&langNum="+pageLangNum;//+"&code="+code+"&vat="+vat+"&price="+price+"&orderId="+orderId+"&canOrder="+canOrder+"&productId="+productId+"";
		//alert( 'dataToSend: ' + dataToSend + '; pageHost/showOrderElem.php5: '+ pageHost+'/showOrderElem.php5' );
		new Ajax( pageHost+'/showOrderElem.php5',
			{
				method: 'post',
				data: dataToSend,
				onFailure: function()
							{
								alert( 'cus ni tak' );
							},
				onSuccess: function()
							{
								//this.response.text
								oDiv.innerHTML = this.response.text;
								setSlideOnShowOrderElem( 'orderShowOrderElemDiv', 'orderShowOrderElemScrollDivIn1' );
							},
				//update: oDiv,
				evalScripts: false
			}
		).request();
	}

	/**
	*	Opis: resetuje konfiguracje
	*/
	function setSlideOnShowOrderElem( divId, divToScrollId )
	{
		if( $( divId ).style.display == 'block' )
		{
			if( ( aSlide = $( 'areaSlide' ) ) && ( kSlide = $( 'knobSlide' ) ) )
			{
				//aSlide.style.height = '400px';
				oScrollDiv = $( divToScrollId );
				scrollDivH = ( ( oScrollDiv.offsetHeight-400 )/400 );
				if( scrollDivH > 0 )
				{
					if( oScrollDiv.offsetHeight > 400 )
					{
						kSlideHeight = ( 160000/oScrollDiv.offsetHeight );
					}
					else
					{
						kSlideHeight = 400;
					}
					kSlide.style.height = ''+( kSlideHeight )+'px';
					poccSlide = new Slider( aSlide, kSlide, {
											steps: 400,
											mode: 'vertical',
											onChange: function( step )
													{
														oScrollDiv.style.marginTop = '-'+( step*scrollDivH )+'px';
														//alert( step );
														//$( 'upd3' ).setHTML( step );
													}
											} ).set( 0 );
				}
				else
				{
					kSlide.style.height = '396px';
					kSlide.setOpacity( 0.8 );
				}
			}
		}
		else
		{
			setTimeout( 'setSlideOnShowOrderElem( "'+divId+'", "'+divToScrollId+'" )', 100 );
		}
	}
	
	function hideOrderElem()
	{
		LightboxForData.close();
		manageSelectsAll( 'visible' );
	}

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	logowanie, formularz rejestracyjny
*---------------------------------------------------------------------*/

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function sendPassword( a_text1, a_text2 )
	{
		oObj = $( 'exemail' );
		oVal = oObj.value;
		re = /[\s\t\r\n]+/g;
		oVal = oVal.replace( re, '' )
		if( oVal != '' )
		{
			if( isEMail( oVal ) == 1 )
			{
				$( 'sendpass' ).value = 1;
				docFormExL = $( "exlogin" );
				docFormExL.submit();
			}
			else
			{
				oObj.className = 'textLF1';
				alert( a_text2 );
			}
			//docFormExL.action = a_adr;
		}
		else
		{
			oObj.className = 'textLF1';
			alert( a_text1 );
		}
	}

	/**
	*	Opis: przelacza pomiedzy wyborem polskich wojewodztw, a zmiana kraju
	*/
	function changeCountry( a_id )
	{
		adiv = $( a_id );
		ainp = $( "exkraj" );
		asel = $( "exprovince" );
		if( $( "exinny" ).checked == true )
		{
			adiv.style.color = "#cccccc";
			ainp.style.borderColor = "#7c94a5";
			ainp.disabled = false;
			asel.disabled = true;
			asel.value = 0;
		}
		else
		{
			adiv.style.color = "#666666";
			ainp.value = "";
			ainp.style.borderColor = "#cccccc";
			ainp.disabled = true;
			asel.disabled = false;
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function checkRegistrationForm( a_text, a_pass_text, a_type, a_adr, a_user_type )
	{
		ok = 1;
		if( ( a_type != 4 ) && $( "exReg" ) )
		{
			if( $( "exregulation" ).checked == true )
			{
				ok = 1;
			}
			else
			{
				ok = 0;
			}
		}
		if( a_user_type == 1 )
		{
			if( ( $( "exstreet" ).value == "" ) || ( $( "expostcode" ).value == "" ) || ( $( "excity" ).value == "" ) || ( $( "exnip" ).value == "" ) || ( $( "exprovince" ).value == "" ) || ( $( "exfirmname" ).value == "" )|| ( $( "exshortfirmname" ).value == "" ) || ( $( "exnumber" ).value == "" ) )
			{
				ok = 0;			
			}
		}
		if( (  a_type == 4 ) || ( ( ok == 1 ) && ( $( "exclientlogin" ).value != "" ) && ( $( "exmail" ).value != "" ) && ( ( ( $( "expass" ).value != "" ) && ( $( "expass2" ).value != "" ) ) || ( a_type == 2 ) ) && ( $( "captchaCode" ).value != "" ) ) ) 
		{
			if( $( "expass" ).value == $( "expass2" ).value )
			{
				docFormExL = $( "exlogin" );
				if( a_type == 2 || a_type == 4 )
				{
					docFormExL.action = a_adr;
				}
				docFormExL.submit();
			}
			else
			{
				alert( a_pass_text );
			}
		}
		else
		{
			alert( a_text );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function checkLogin( a_text1, a_text2, a_text3 )
	{
		var ok = 1;
		var fieldsToCheck = Array( 'exemail', 'exhaslo' );
		var fieldsMinLenght = Array( 0, 6 );
		var textToAlert = Array( '', '', '' );
		var alertText = '';
		for( i = 0; i <= 1; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text1+"\n";
			}
			else if( ( fieldsMinLenght[i] > 0 ) && ( oVal.length < fieldsMinLenght[i] ) )
			{
				oObj.className = 'textLF1';
				ok = 2;
				textToAlert[1] = a_text2+"\n";
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( isEMail( $( 'exemail' ).value ) == 0 )
		{
			ok = 0;
			$( 'exemail' ).className = 'textLF1';
			textToAlert[2] = a_text3+"\n";
		}
		for( var i = 0; i <= 2; i++ )
		{
			alertText += textToAlert[i];
		}
		if( ok == 1 )
		{
			$( "exlogin" ).submit();
		}
		else
		{
			alert( alertText );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function checkNewUser( a_text, a_text2, a_text3, a_text4, a_text5, a_text6 )
	{
		var ok = 1;
		var textToAlert = Array( '', '', '', '', '', '' );
		var alertText = '';
		var fieldsToCheck = Array( 'newemail', 'newpasswd', 'newconfirm', 'newname', 'newsurname', 'newinstitution', 'newdepartment', 'newstreet', 'newcity', 'newpostcode', 'newphone', 'newnip', 'newlogin' );
		var fieldsMinLenght = Array( 0, 6, 6, 0, 0, 0, 0 );
		for( var i = 0; i <= 12; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' );
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text+"\n";
			}
			else if( ( fieldsMinLenght[i] > 0 ) && ( oVal.length < fieldsMinLenght[i] ) )
			{
				oObj.className = 'textLF1';
				if( ok == 1 )
				{
					ok = 2;
					textToAlert[2] = a_text3+"\n";
				}
			}
			else
			{
				oObj.className = 'textLF0';	
			}
		}
		loginValue = $( 'newlogin' ).value;
		if( ( loginValue.length < 3 ) || ( loginValue.length > 30 ) )
		{
			ok = 0;
			$( 'newlogin' ).className = 'textLF1';
		}
		else
		{
			$( 'newlogin' ).className = 'textLF0';
		}
		if( ( $( 'newpasswd' ).value != $( 'newconfirm' ).value ) )
		{
			$( 'newpasswd' ).className = 'textLF1';
			$( 'newconfirm' ).className = 'textLF1';
			ok = 3;
			textToAlert[3] = a_text4+"\n";
		}
		if( isEMail( $( 'newemail' ).value ) == 0 )
		{
			ok = 0;
			$( 'newemail' ).className = 'textLF1';
			textToAlert[1] = a_text2+"\n";
		}
		if( checkPostCode( $( 'newpostcode' ).value ) == 0 )
		{
			ok = 0;
			$( 'newpostcode' ).className = 'textLF1';
			textToAlert[4] = a_text5+"\n";
		}
		if( ( $( 'newnip' ).value != '' ) && ( checkNip( $( 'newnip' ).value ) == 0 ) )
		{
			ok = 0;
			$( 'newnip' ).className = 'textLF1';
			textToAlert[5] = a_text6+"\n";
		}
		var fieldsToCheck = Array( 'dpname', 'dpsurname', 'dpstreet', 'dpcity', 'dppostcode', 'dpphone', 'dpinstitution', 'dpdepartment' );
		for( var i = 0; i <= 7; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' );
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text+"\n";
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( checkPostCode( $( 'dppostcode' ).value ) == 0 )
		{
			ok = 0;
			$( 'dppostcode' ).className = 'textLF1';
			textToAlert[4] = a_text5+"\n";
		}
		if( ( $( 'dpnip' ).value != '' ) && ( checkNip( $( 'dpnip' ).value ) == 0 ) ) 
		{
			ok = 0;
			$( 'dpnip' ).className = 'textLF1';
			textToAlert[5] = a_text6+"\n";
		}
		else
		{
			$( 'dpnip' ).className = 'textLF0';	
		}
		
		for( var i = 0; i <= 5; i++ )
		{
			alertText += textToAlert[i];
		}
		
		
		if( ok == 1 )
		{
			$( "logintype1" ).value = 1;
			$( "exlogin" ).submit();
		}
		else
		{
			alert( alertText );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function addNewUser( a_text, a_text2 )
	{
		ok = 1;
		fieldsToCheck = Array( 'exemail', 'exhaslo' );
		fieldsMinLenght = Array( 0, 6 );
		for( i = 0; i <= 1; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/gi;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( ok == 1 )
		{
			$( "exlogin" ).submit();
		}
		else if( ok == 0 )
		{
			alert( a_text );
		}
		else
		{
			alert( a_text2 );
		}
	}

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	modul projekty
*---------------------------------------------------------------------*/

	/**
	*	Opis: resetuje filtry w module projekty
	*/
	function dropProjectFilters()
	{
		$( "dropPFilters" ).value = 1;
		$( "pWords2" ).value = "";
		$( "pWords" ).value = "";
		$( "projectFilterForm" ).submit();
	}

	/**
	*	Opis: ustawia slowa do wyszukania w module projekty
	*/
	function sendProjectWords( txt )
	{
		words = $( "pWords2" ).value;
		if( words != "" )
		{
			words = erase_space( words, 1 );
			//re = /\+/g;
			//words = words.replace( re, " " );
			$( "pWords" ).value = words;
			//$( "dropPFilters" ).value = 1;
			$( "projectFilterForm" ).submit();
		}
		else
		{
			alert( txt );
		}
	}

/**-------------------------------------------------------------------*/


/**--------------------------------------------------------------------
*	modul aukcje
*---------------------------------------------------------------------*/

	/**
	*	Opis: sbmituje zmiane w ofercie aukcyjnej
	*/
	function auctionFormSubmit( a_txt, a_txt2 )
	{
		formatPrice( "acprice" );
		formatNumber( "acpayment" );
		formatNumber( "acdelivery" );
		acprice = $( "acprice" ).value;
		acpayment = $( "acpayment" ).value;
		acdelivery = $( "acdelivery" ).value;
		if( ( acprice != "0.00" ) && ( acpayment != "0" ) && ( acdelivery != "0" ) )
		{
			if( confirm( a_txt2 ) )
			{
				$( "accheck" ).value = "1";
				$( "auctionForm" ).submit();
			}
		}
		else
		{
			alert( a_txt );
		}
	}

/** ----------------------------------------------------------------------
* 
*-----------------------------------------------------------------------*/

	/**
	*	Opis: ??
	*/
	function checkName( name, minLength, maxLength, txt )
	{
		t = name.length;
		if( ( t < minLength ) || ( t > maxLength ) )
		{
			alert( txt );
			return 0;
		}
		else
		{
			return 1;
		}
	}

/** ----------------------------------------------------------------------
* 	to dla "moje ogloszenia"
*-----------------------------------------------------------------------*/

	/**
	*	Opis: sbmituje zmiane w ofercie aukcyjnej
	*/
	function submitFilterAnForm( filterType )
	{
		$( "myAnFilterType" ).value = filterType;
		$( "filterAnForm" ).submit();
	}

	/**
	*	Opis: sbmituje zmiane w ofercie aukcyjnej
	*/
	function setMyAnnouncementAction( aType, aTarget, txt )
	{
		if( ( txt == '' ) || ( confirm( txt ) ) )
		{
			$( "actionType" ).value = aType;
			$( "actionTarget" ).value = aTarget;
			$( "filterAnForm" ).submit();
		}
	}

	function showHideBox( selectId, boxId, optionName )
	{
		if( $( selectId ) )
		{
			num = $( selectId ).selectedIndex;
			if ( $( selectId ).options[num].text == optionName )
			{
				$( boxId ).style.display = 'none';
			}
			else
			{
				$( boxId ).style.display = 'block';
			}
		}
	}

	function showHideAddress( radioId, boxId, optionName )
	{
		if( $( radioId ) && $( boxId ) )
		{
			if(  $( radioId ).value == 0 )
			{
				$( boxId ).style.display = 'none';
			}
			else
			{
				$( boxId ).style.display = 'block';
			}
		}
	}

	function printOrder( adr )
	{
		if( $( "orderform" ) )
		{
			$( "orderform" ).action = adr;
			$( "orderform" ).target = "_blank";
			$( "orderform" ).submit();
		}
	}
	
	/**
	*	Opis: sbmituje zmiane w ofercie aukcyjnej
	*/
	function submitFilterEcForm( filterType )
	{
		$( "myEcFilterType" ).value = filterType;
		$( "filterEcForm" ).submit();
	}

	/**
	*	Opis: sbmituje zmiane w ofercie aukcyjnej
	*/
	function setMyEventAction( aType, aTarget, txt )
	{
		if( ( txt == '' ) || ( confirm( txt ) ) )
		{
			$( "actionType" ).value = aType;
			$( "actionTarget" ).value = aTarget;
			$( "filterEcForm" ).submit();
		}
	}

	/**
	*	Opis: submituje komentarz
	*/
	function setMyEventCategory( vCategory, vAdr )
	{
		$( "ecCategorySet" ).value = vCategory;
		mef = $( "filterEcForm" );
		mef.action = vAdr;
		mef.submit();
	}

	/**
	*	Opis: submituje komentarz
	*/
	function setMyEventTag( vTag, vAdr )
	{
		$( "ecTagsToSearch" ).value = vTag;
		$( "searchOnlyInTags" ).value = 1;
		mef = $( "filterEcForm" );
		mef.action = vAdr;
		mef.submit();
	}

	/**
	*	Opis: submituje komentarz
	*/
	function addEventForUser2( txt, eventId )
	{
		var remind = 0;
		if( confirm( txt ) )
		{
			remind = 1;
		}
		$( "ecAddEventForUser" ).value = eventId;
		$( "ecEventForUserRemind" ).value = remind;
		var calForm = $( "filterEcForm" );
		//calForm.action = '#';
		calForm.submit();
	}

	/**
	*	Opis: submituje komentarz
	*/
	function removeEventFromUser( txt, eventId )
	{
		if( confirm( txt ) )
		{
			$( "ecRemoveEventFromUser" ).value = eventId;
			var calForm = $( "filterEcForm" );
			//calForm.action = '#';
			calForm.submit();
		}
	}

/**-------------------------------------------------------------------*/

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function changePassword( a_text1, a_text2, a_text3 )
	{
		var ok = 1;
		var textToAlert = Array( '', '', '' );
		var alertText = '';
		var fieldsToCheck = Array( 'newpass', 'passconfirm' );
		var fieldsMinLenght = Array( 6, 6 );
		for( var i = 0; i <= 1; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text1+"\n";
			}
			else if( ( fieldsMinLenght[i] > 0 ) && ( oVal.length < fieldsMinLenght[i] ) )
			{
				oObj.className = 'textLF1';
				if( ok == 1 )
				{
					ok = 2;
					textToAlert[1] = a_text2+"\n";
				}
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( ( $( 'newpass' ).value != $( 'passconfirm' ).value ) )
		{
			$( 'newpass' ).className = 'textLF1';
			$( 'passconfirm' ).className = 'textLF1';
			ok = 3;
			textToAlert[2] = a_text3+"\n";
		}
		for( var i = 0; i <= 2; i++ )
		{
			alertText += textToAlert[i];
		}
		if( ok == 1 )
		{
			$( "changepassword" ).value = 1;
			$( "exlogin" ).submit();
		}
		else
		{
			alert( alertText );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function updatePassword( a_text1, a_text2, a_text3 )
	{
		var ok = 1;
		var textToAlert = Array( '', '', '' );
		var alertText = '';
		var fieldsToCheck = Array( 'oldpass', 'newpass', 'passconfirm' );
		var fieldsMinLenght = Array( 6, 6, 6 );
		for( var i = 0; i <= 2; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text1+"\n";
			}
			else if( ( fieldsMinLenght[i] > 0 ) && ( oVal.length < fieldsMinLenght[i] ) )
			{
				oObj.className = 'textLF1';
				if( ok == 1 )
				{
					ok = 2;
					textToAlert[1] = a_text2+"\n";
				}
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( ( $( 'newpass' ).value != $( 'passconfirm' ).value ) )
		{
			$( 'newpass' ).className = 'textLF1';
			$( 'passconfirm' ).className = 'textLF1';
			ok = 3;
			textToAlert[2] = a_text3+"\n";
		}
		for( var i = 0; i <= 2; i++ )
		{
			alertText += textToAlert[i];
		}
		if( ok == 1 )
		{
			$( "changepassword" ).value = 1;
			$( "exlogin" ).submit();
		}
		else
		{
			alert( alertText );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function updateYourData( a_text, a_text1, a_text2, a_text3  )
	{
		var ok = 1;
		var textToAlert = Array( '', '', '', '', '', '' );
		var alertText = '';
		var fieldsToCheck = Array( 'myname', 'mysurname', 'myemail', 'myinstitution', 'mydepartment', 'mystreet', 'mycity', 'mypostcode', 'myphone', 'mynip', 'mylogin' );
		for( var i = 0; i <= 10; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' );
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				textToAlert[0] = a_text+"\n";
				ok = 0;
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		loginValue = $( 'mylogin' ).value;
		if( ( loginValue.length < 3 ) || ( loginValue.length > 30 ) )
		{
			ok = 0;
			$( 'mylogin' ).className = 'textLF1';
		}
		else
		{
			$( 'mylogin' ).className = 'textLF0';
		}
		if( isEMail( $( 'myemail' ).value ) == 0 )
		{
			ok = 0;
			$( 'myemail' ).className = 'textLF1';
			textToAlert[1] = a_text1+"\n";
		}
		if( checkPostCode( $( 'mypostcode' ).value ) == 0 )
		{
			ok = 0;
			$( 'mypostcode' ).className = 'textLF1';
			textToAlert[2] = a_text2+"\n";
		}
		if( ( $( 'mynip' ).value != '' ) && ( checkNip( $( 'mynip' ).value ) == 0 ) )
		{
			ok = 0;
			$( 'mynip' ).className = 'textLF1';
			textToAlert[3] = a_text3+"\n";
		}
		
		var fieldsToCheck = Array( 'dpname', 'dpsurname', 'dpstreet', 'dpcity', 'dppostcode', 'dpphone', 'dpinstitution', 'dpdepartment' );
		for( var i = 0; i <= 7; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' );
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
				textToAlert[0] = a_text+"\n";
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( checkPostCode( $( 'dppostcode' ).value ) == 0 )
		{
			ok = 0;
			$( 'dppostcode' ).className = 'textLF1';
			textToAlert[4] = a_text5+"\n";
		}
		if( ( $( 'dpnip' ).value != '' ) && ( checkNip( $( 'dpnip' ).value ) == 0 ) ) 
		{
			ok = 0;
			$( 'dpnip' ).className = 'textLF1';
			textToAlert[5] = a_text6+"\n";
		}
		else
		{
			$( 'dpnip' ).className = 'textLF0';	
		}
		
		
		for( var i = 0; i <= 3; i++ )
		{
			alertText += textToAlert[i];
		}
		if( ok == 1 )
		{
			$( "changedata" ).value = 1;
			$( "exlogin" ).submit();
		}
		else
		{
			alert( alertText );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function updateCompanyData( a_text1 )
	{
		var ok = 1;
		var fieldsToCheck = Array( 'cpname', 'cpnip', 'cpstreet', 'cpcity', 'cpcode', 'cpphone', 'cpprovince' );
		for( var i = 0; i <= 6; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( ok == 1 )
		{
			$( "changedata" ).value = 1;
			$( "exlogin" ).submit();
		}
		else
		{
			alert( a_text1 );
		}
	}

	/**
	*	Opis: sprawdza, czy e-mail i haslo do rejestracji nie sa puste
	*/
	function updateDeliveryData( a_text1 )
	{
		var ok = 1;
		var fieldsToCheck = Array( 'cpname', 'cpstreet', 'cpcity', 'cpcode', 'cpprovince' );
		for( var i = 0; i <= 4; i++ )
		{
			oObj = $( fieldsToCheck[i] );
			oVal = oObj.value;
			re = /[\s\t\r\n]+/g;
			oVal = oVal.replace( re, '' )
			if( oVal == '' )
			{
				oObj.className = 'textLF1';
				ok = 0;
			}
			else
			{
				oObj.className = 'textLF0';
			}
		}
		if( ok == 1 )
		{
			$( "changedata" ).value = 1;
			$( "exlogin" ).submit();
		}
		else
		{
			alert( a_text1 );
		}
	}
	
	function checkPostCode( txt )
	{
		re = /^[0-9]{2}-[0-9]{3}$/;
		var patt = new RegExp( re );
		if( patt.test( txt ) )
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	
	function checkNip( txt )
	{
		re = /^[0-9]{3}-[0-9]{3}-[0-9]{2}-[0-9]{2}$/;
		var patt = new RegExp( re );
		if( patt.test( txt ) )
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}

