/** Zagiel **/
var zagielId = 20487045;
//var zagielId = 28011111;

function policzRate( koszyk ) 
{
	window.open('https://www.zagiel.com.pl/kalkulator/index_smart.php?action=getklientdet_si_rata&shopNo=' + zagielId + '&goodsValue=' + koszyk, 'Policz_rate', 'width=630,height=500,directories=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
}

/** Uzytkownicy **/

function checkRegForm()
{
	if( document.getElementById( 'term' ).checked )
	{
		$("#idRegInfo").hide();
		document.getElementById( 'terms' ).style.borderColor = '#ffffff';
		return true;
	}
	else
	{
		$("#idRegInfo").show();
		document.getElementById( 'terms' ).style.borderColor = '#ff0000';
		return false;
	}
}

function updatebasketfield( f, k )
{
	if( parseInt( f.value ) != NaN )
	{
		f.value	= parseInt( f.value );
		var fo = document.getElementById( 'formBasket' );
		
		fo.action	= baseUrl + '/basket/update';
		fo.submit();
	}
	else
	{
		f.value = document.getElementById( 'idStore' ).value;
	}
}

function validateClientForm()
{
	
}

function checkOpinion()
{
	alert( document.getElementById( 'ovote' ).value );
	if( document.getElementById( 'ovote' ).value == '' )
	{
		markField( 'ovote', 1 );
		return false;
	}
	else
	{
		markField( 'ovote', 0 );
		return true;
	}
}

/** /Uzytkownicy **/

function markField( i, v )
{
	if( v == 0 )
	{
		document.getElementById( i ).style.borderColor = '#a61804';
		document.getElementById( i ).style.borderWidth = '1px';
	}
	else
	{
		document.getElementById( i ).style.borderColor = '#ff0000';
		document.getElementById( i ).style.borderWidth = '2px';
	}
}

function getValue( i )
{
	return document.getElementById( i ).value;
}

function emailValidate( str ) 
{

		var at		= "@";
		var dot		= ".";
		var lat		= str.indexOf(at);
		var lstr	= str.length - 1;
		var ldot	= str.indexOf(dot);
		
		if( str.indexOf( at ) == -1 )
		{
		   return false
		}

		if( str.indexOf( at ) == -1 || str.indexOf( at ) == 0 || str.indexOf( at ) == lstr )
		{
		   return false
		}

		if( str.indexOf( dot ) == -1 || str.indexOf( dot ) == 0 || str.indexOf( dot ) == lstr ) 
		{
		    return false
		}

		 if( str.indexOf( at, ( lat + 1 ) ) != -1 )
		 {
		    return false
		 }

		 if( str.substring( lat-1, lat ) == dot || str.substring( lat+1, lat+2 ) == dot )
		 {
		    return false
		 }

		 if( str.indexOf( dot, ( lat + 2 ) ) == -1 )
		 {
		    return false
		 }
		
		 if( str.indexOf(" ") != -1 )
		 {
		    return false
		 }

 		 return true					
}