/**
 * MT: Script s beznymi funkciami, ktore sa pouzivaju na jednoduche efekty
 * na steanke
 *
 */

 /**
  * Nastavi farebnu verziu stranky na jednu z 3 moznych farieb
  *
  */
function ChangeColor(color)
{
	if (color == 'blue') {
		document.body.className = 'eurolines';
		if (document.getElementById('left_menu_panel'))
			document.getElementById('left_menu_panel').className = 'bluemenu';
		if (document.getElementById('ticketLink'))
			document.getElementById('ticketLink').className = 'btn_open_blue';
		ShowTab(2);
	} else if (color == 'orange') {
		document.body.className = 'slovaklines';
		if (document.getElementById('left_menu_panel'))
			document.getElementById('left_menu_panel').className = 'redmenu';
		if (document.getElementById('ticketLink'))
			document.getElementById('ticketLink').className = 'btn_open_orange';
		ShowTab(3);
	} else {
		document.body.className = 'slovaklines';
		if (document.getElementById('left_menu_panel'))
			document.getElementById('left_menu_panel').className = 'redmenu';
		if (document.getElementById('ticketLink'))
			document.getElementById('ticketLink').className = 'btn_open';
		ShowTab(1);
	}
	if (document.getElementById('aside2'))
		document.getElementById('aside2').className = color;

	// Vyresetujeme obsah tabu
	clearFormsValues();

	return false;
}

/**
 * Prepinanie medzi dvoma hlavnymi farebnymi verziami stranky
 *
 */
function SwitchColor()
{
	if (document.body.className == 'slovaklines')
		ChangeColor('blue');
	else
		ChangeColor('red');

	return false;
}

/**
 * Zobrazi jednu zo zaloziek formularu, je potrebne zmenit farebnu verziu
 * zodpovedajucu farbe zalozky
 *
 */
function ShowTab(tID)
{
    document.getElementById('formm_1').className = 'tab hide';
    document.getElementById('formm_2').className = 'tab hide';
    document.getElementById('formm_3').className = 'tab hide';

    document.getElementById('li1').className = '';
    document.getElementById('li2').className = '';
    document.getElementById('li3').className = '';

    document.getElementById('formm_' + tID).className = 'tab';
    document.getElementById('li' + tID).className = 'active';
}

/**
 * Prepne z prvej zalozky na druhu a naopak a zmeni farebnu verziu
 *
 */
function SwitchTab()
{
	if (document.body.className == 'slovaklines')
		ShowTab(2); // ak mame slovaklines, zobrazi tab pre eurolines
	else
		ShowTab(1);
	SwitchColor();

	return false;
}

/**
 * Funkcia na skrytie a zobrazenie casti
 *
 * show: 0 - skryt, 1 - zobrazit, 2 - prepnut
 */
function ShowHideAll(show, parent, tag, id)
{
	var leftMenu = document.getElementById(parent);
	var liArray = leftMenu.getElementsByTagName(tag);
	var newStyle = '';
	var first = true;

	if (show == 0)
	    newStyle = 'none';

	for(i = 0; i < liArray.length; i++)
	    if (liArray[i].id.indexOf(id) != -1) {
	        if (show == 2 && first) {
	            if (liArray[i].style.display == 'none')
	            	newStyle = '';
				else
		    		newStyle = 'none';
				first = false;
	        }
	        liArray[i].style.display = newStyle;
	    }
}

function Show(id)
{
	document.getElementById(id).style.display = '';
}

function Hide(id)
{
    document.getElementById(id).style.display = 'none';
}

/**
 * Skryje/zobrazi polia podla typu listku
 *
 */
function onFormSelectType(id, sel)
{
	if(sel == 2)
		Show(id);
	else
		Hide(id);
}


/**
 * Vycisti formulare na defaultne hodnoty
 *
 */
function clearForms(from3, to3, fromId3, toId3, date, time)
{
	var curTime = new Date();
	var dateVal = curTime.getDate() + '.' + (curTime.getMonth() + 1) + '.' + curTime.getFullYear();
	var timeVal = curTime.getHours() + ':' + ((curTime.getMinutes() < 10) ? '0' : '') + curTime.getMinutes();
	curTime.setDate(curTime.getDate()+1);
	var nextDateVal = curTime.getDate() + '.' + (curTime.getMonth() + 1) + '.' + curTime.getFullYear();

	if (date == '')
	    date = dateVal;
	if (time == '')
	    time = timeVal;

	// form 1
	document.getElementById('autocompleter_1').value = '';
	document.getElementById('where1').value = '';
	document.getElementById('h_autocompleter_1').value = '';
	document.getElementById('h_where1').value = '';
	document.getElementById('type1').value = 1;
	document.getElementById('odchod1').value = dateVal;
	document.getElementById('cas_od1').value = timeVal;
	document.getElementById('prichod1').value = nextDateVal;
	document.getElementById('cas_pri1').value = '5:00';
	Hide('div_arr1');
	document.getElementById('infoom_1').ClassName = 'hide';

	// form 2
	document.getElementById('autocompleter_2').value = '';
	document.getElementById('where2').value = '';
	document.getElementById('h_autocompleter_2').value = '';
	document.getElementById('h_where2').value = '';
	document.getElementById('type2').value = 1;
	document.getElementById('odchod2').value = dateVal;
	document.getElementById('cas_od2').value = timeVal;
	document.getElementById('prichod2').value = nextDateVal;
	document.getElementById('cas_pri2').value = '5:00';
	Hide('div_arr2');
 	document.getElementById('infoom_2').ClassName = 'hide';

	// form 3
	document.getElementById('autocompleter_3').value = from3;
	document.getElementById('where3').value = to3;
	document.getElementById('h_autocompleter_3').value = fromId3;
	document.getElementById('h_where3').value = toId3;
	document.getElementById('odchod3').value = date;
	document.getElementById('cas_od3').value = time;
 document.getElementById('infoom_3').ClassName = 'hide';
}

function ResetDate1(calendar)
{
    document.getElementById('cas_od1').value = '5:00'
}

function ResetDate2(calendar)
{
    document.getElementById('cas_od2').value = '5:00'
}

function ResetDate3(calendar)
{
    document.getElementById('cas_od3').value = '5:00'
}

/**
 * Vlozi banner
 *
 */
function putBanner(zoneid, id)
{
   // Insert click tracking URL here
   document.phpAds_ct0 ='Insert_Clicktrack_URL_Here'

   var awrz_rnd = Math.floor(Math.random()*99999999999);
   var awrz_protocol = location.protocol.indexOf('https')>-1?'https:':'http:';
   if (!document.phpAds_used) document.phpAds_used = ',';
   document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
   document.write (awrz_protocol+"//www.xmlogies.sk/max/adjs.php?n="+id);
   document.write ("&zoneid="+zoneid);
   document.write ("&exclude=" + document.phpAds_used);
   document.write ("&loc=" + escape(window.location));
   if (document.referrer)
      document.write ("&referer=" + escape(document.referrer));
   document.write ('&r=' + awrz_rnd);
   document.write ("&ct0=" + escape(document.phpAds_ct0));
   document.write ("'><" + "/script>");
   //document.write ("<a href='http://www.xmlogies.sk/max/adclick.php?n="+id+"' target='_blank'><img src='http://www.xmlogies.sk/max/adview.php?zoneid="+zoneid+"&n="+id+"' border='0' alt=''></a></noscript>");
}

/**
 * Zriesi kliknutia na logo
 *
 */
function handleLogoClick(a, b)
{
    if (document.body.className == 'eurolines') {
        if (a != '')
			window.location.href = a;
	} else {
	    if (b != '')
			window.location.href = b;
	}

	return false;
}
