//funkcja do pokazywania value dla pola input
//author: Mateusz Przetocki
function show(id,value)
{
	var el = document.getElementById(id);
	if(el.value=='')
	{
		el.value = value;
	}
}

//funkcja do ukrywania value dla pola input
//author: Mateusz Przetocki
function hide(id,value)
{
	var el = document.getElementById(id);
	if(el.value==value)
	{
		el.value = '';
	}
}

//funkcja sprawdza formularz z polami textowymi które mają zadane value
//author: Mateusz Przetocki
function check_fields(form, text, def_text)
{
	if (text!='')
	{
		var pola_text=text.split("||");
		if(def_text!=0)
			var pola_def=def_text.split("||");
		
		for (var i=0; i<pola_text.length; i++)
		{
			var pole=document.getElementById(pola_text[i]);
                        var def;
			if(def_text==0)
				def='';
			else
				def=pola_def[i];
			
			if (IsEmpty(pole.value) || pole.value==def) 
			{
				alert('Wypełnij wymagane pola!');
				Focus(pole);
				return false;
			}
		}
	}	
	return true;
}

function IsEmpty(pole)
{
	if (pole=='') 
		return true
	else
		return false
}

function Focus(control)
{
  control.focus();
  control.select();
}

function prompt(text)
{
	var answer = confirm(text);
	if (answer)
		return true;
	else
		return false;
}

function initScrollBrands()
{
    var number = jQuery("#brands").attr("title");
    var widthAll = 0;
    for (i = 0; i < number ; ++i)
    {
        widthAll += jQuery("#brandId"+i).width();
    }
    
    var szerokosc = widthAll + 25 * parseInt(number);
    jQuery("#brands").attr("title", szerokosc);
}

function scrollBrands(){
	
	//box_1 = document.getElementById("box1");
	//box_2 = document.getElementById("box2");    

	//szerokosc=box_1.offsetWidth;
    //var szerokosc = jQuery("#box1").width();
	//jQuery('#brands').attr('title', szerokosc);
    
//    var number = jQuery("#brands").attr("title");
//    var widthAll = 0;
//    for (i = 0; i < number ; ++i)
//    {
//        widthAll += jQuery("#brandId"+i).width();
//    }
//    
//    //jQuery("#brands").attr("title", widthAll);
//    var szerokosc = widthAll + 25*parseInt(number);
    
    var szerokosc = jQuery("#brands").attr("title");

	//title liczony - sumowanie wszystkich dlugosci obrazków
	//szerokosc=actionBox.title;
	akcja_szerokosc=2*szerokosc;
	szerokosc_minus=szerokosc*(-1);
    
    actionBox = document.getElementById("brands");
	if( (actionBox.style.padding=='inherit inherit inherit inherit') || (actionBox.style.padding=='') || (actionBox.style.padding=='inherit') )
	{
		actionBox.style.padding=0;
		actionBox.style.width=akcja_szerokosc + 'px';
		actionBox.style.left=szerokosc_minus + 'px';
	}

	current_x=parseInt(actionBox.style.left);
	if(current_x<0){actionBox.style.left=current_x+1 + 'px';}
	else{actionBox.style.left=szerokosc_minus + 'px';}
}
