// START: functions for multistep cart support

function GoCommand(cmd)
{
  el = document.getElementById('cmd');
  el.value = cmd;
  form = document.getElementById('obj1');
  form.action = 'eakce.php';
  form.submit();
}

function ChangeStep(step)
{
  el = document.getElementById('kosik_step');
  el.value = step;
  form = document.getElementById('obj1');
  form.action = 'kosik.php';
  form.submit();
}

// END: functions for multistep cart support

function zobrazSkryj(idecko)
	{
	el=document.getElementById(idecko).style;
	el.display=(el.display == 'block')?'none':'block';
	
  if (browser () != 'stupid')
    el.height='auto';
	}



//inteligenci browser
function browser ()
{
  var browser = '';
  browser = navigator.userAgent;
  //document.write(navigator.userAgent);
  
  $name = browser.split('/');
  
  //document.write (browser);
  if (browser.search('Firefox')> 0)
  {
    return 'firefox';
  }
  else if (browser.search('Opera')> 0)
  {
    return 'opera';
  }
  else if ($name[0] == 'Opera')
  {
    return 'opera';
  }
  else {
    return 'stupid';
  }
}

//prida do oblibenych
function bookmark()
{
  if (browser () == 'stupid')
  {
    window.external.AddFavorite('http://www.snowboardsport.cz','Free Style');
  }
  else{
    alert ('Váš prohlížeč nepodporuje automatické přdávání favourites/bookmarks.\n\n'+
           'Zkuste kombinaci kláves:\n'+
           '  - Mozilla/Mozilla Firefox: Ctrl-D\n'+
           '  - Opera: Ctrl-T\n\n'+
           'POZNÁMKA: pokud používáte jiný prohlížeč tak vyhledejte v menu položku "help -> system/documentation"');
  }
}

//prida home page
function homepage ()
{
  if (browser () == 'stupid')
  {
     document.body.style.behavior='url(#default#homepage)';document.body.setHomePage('http://www.snowboardsport.cz/');
  }
  else{
    alert ('Váš prohlížeč nepodporuje automatické nastavení domovské stránky.');
  }
}


// kosik
function KosikPlatbaZmena(){
	document.getElementById('doprava_delete').value = '1';
	document.getElementById('form_kosik').submit();
}

function copyPrihlaska() {
	document.getElementById('p_firma').value = document.getElementById('f_firma').value
	document.getElementById('p_titul').value = document.getElementById('f_titul').value
	document.getElementById('p_jmeno').value = document.getElementById('f_jmeno').value
	document.getElementById('p_prijmeni').value = document.getElementById('f_prijmeni').value
	document.getElementById('p_ulice').value = document.getElementById('f_ulice').value
	document.getElementById('p_psc').value = document.getElementById('f_psc').value
	document.getElementById('p_mesto').value = document.getElementById('f_mesto').value
	document.getElementById('p_email').value = document.getElementById('f_email').value
	document.getElementById('p_tel').value = document.getElementById('f_tel').value
}

function bodyPrihlaska(k_body,k_cena,t_body,t_cena,p_body,p_cena,u_body,m_body) {

    if (parseFloat(m_body) > 0) { 
	
		k_body = Math.abs(Number(k_body))	// cena kongresu v bodoch
		k_cena = Math.abs(Number(k_cena))	// cena kongresu v CZK
		
		u_body = Math.abs(Number(u_body))	//body od usera
		m_body = Math.abs(Number(m_body))	//pocet bodov usera
		
		t_body = Math.abs(Number(t_body))	//body za teoteticku cast
		t_cena = Math.abs(Number(t_cena))	//cena za teoreticku cast
		
		p_body = Math.abs(Number(p_body))	// body za prakticku cast
		p_cena = Math.abs(Number(p_cena))	// body za teoreticku cast
		
		
		var pomer = k_cena/k_body;
	
		if(!isNaN(u_body) && k_body!=0) {
			if(u_body > m_body) u_body = m_body;
			if(u_body >= k_body) {
				document.getElementById('mh_body').value = (k_body);
				var zbytok = 0;
			}
			if(u_body < k_body) {
				document.getElementById('mh_body').value = (u_body);
				var zbytok = ((k_body-u_body)*pomer);
			}
			document.getElementById('doplatit').innerHTML = Math.round(zbytok);
		}
		else {
			document.getElementById('mh_body').value = '';
			document.getElementById('doplatit').innerHTML = k_cena;
		}
	} else {
	   alert('Máte příliš málo bodů pro uplatnění.');
	}
}

function addPrihlaska(t_body,p_body,t_cena,p_cena) {
	//t_body	- body za teoreticku cast
	//p_body	- body za prakticku cast
	//t_cena	- cena za teoreticku cast
	//p_cena	- cena za prakticku cast
	p_cena = Math.abs(Number(p_cena));
	t_cena = Math.abs(Number(t_cena));
	t_body = Math.abs(Number(t_body));
	p_body = Math.abs(Number(p_body));

	if(document.getElementById('p_cast').checked == true) {
		document.getElementById('doplatit').innerHTML = (t_cena+p_cena);
		document.getElementById('txt_cena').innerHTML = (t_cena+p_cena)+',- / '+(t_body+p_body);
		document.getElementById('inp_body').value = (t_body+p_body);
		document.getElementById('inp_cena').value = (t_cena+p_cena);
		document.getElementById('mh_body').value = 0;
	}
	else {
		document.getElementById('doplatit').innerHTML = (t_cena);
		document.getElementById('txt_cena').innerHTML = (t_cena)+',- / '+(t_body) ;
		document.getElementById('inp_cena').value = (t_cena);
		document.getElementById('inp_body').value = (t_body);
		document.getElementById('mh_body').value = 0;
	}
}
