

var qid_last = 0;
var iframe = 0;

$(document).ready(function(){

  var i,fqo,fqp,t;
  var a;
  
  fqo = $('#faq h3');
  fqp = $('#faq p');
  fqp.css('display', 'none');
  
  for(i = 0;i < fqo.length;i++) {
    t = fqo[i].innerHTML;
    //alert(fqo[i]);
    a = document.createElement('a');
    a.appendChild(document.createTextNode(t));
    a.setAttribute('href', 'javascript:zobrazOtazku(' + (i + 1) + ')');
    fqo[i].removeChild(fqo[i].firstChild);
    fqo[i].appendChild(a);
    
    fqp[i].setAttribute('id', 'answer-' + (i + 1));
  }


	//create a bubble popup for each DOM element with class attribute as "text", "button" or "link" and LI, P, IMG elements.
	addBubblePopup('icon_clock,icon_calendar');
	function addBubblePopup(id){
		id.toString();
		elements = id.split(',');		
		for(a=0; a <= elements.length -1; a++){
 
			text = $('#'+elements[a]+'_text').html();
			if(text == null) text = $('#'+elements[a]).attr('bubble');
				$('#'+elements[a]).CreateBubblePopup({position : 'top',align	 : 'center',innerHtml: text, innerHtmlStyle: {	'width':'200px','color':'#333333','text-align':'center'},themeName: 'orange',themePath: '/css'});
		}
	}

	$('#date').datepicker({minDate: 0, maxDate: 30, dateFormat: 'd.m.yy'});
	$("#fromTime").timePicker({startTime: "08.00", endTime: "17.00", separator: ".", step: 60});
	$("#toTime").timePicker({startTime: "08.00",endTime: "17.00",separator: ".",step: 60});
	if($('#cnow:checked').val()) {
		$('#callback').css("display","none");
	}
	$('#cnow').click(cnowChanged);
});


function formSubmit()
{
  $('#sform').submit();
}

function cnowChanged() 
{
  $('#callback').animate({height: 'toggle'});
}

function osobniUdaje() 
{
	if(iframe) {
	  alert(
	  	$('#rules p').eq(0).html() + "\n\n" +
		$('#rules p').eq(1).html() + "\n\n" +
		$('#rules p').eq(2).html() + "\n\n" +
		$('#rules p').eq(3).html() + "\n\n" +
		$('#rules p').eq(4).html() + "\n\n" +
		$('#rules p').eq(5).html() + "\n\n" +
		$('#rules p').eq(6).html()
	);
	}
	else {
    $('#rules').animate({height: 'toggle'});
	}
}

function telefon()
{
  alert('Telefon nĂˇm slouĹľĂ­ k ovÄ›Ĺ™enĂ­, Ĺľe se naĹˇe data nepokouĹˇĂ­ stĂˇhnout neoprĂˇvnÄ›nĂˇ osoba. ZĂˇroveĹ vĂˇs mĹŻĹľeme kontaktovat v pĹ™Ă­padÄ› nesrovnalostĂ­ ve vyplnÄ›nĂ©m formulĂˇĹ™i. Volat vĂˇm tak budeme maximĂˇlnÄ› jednou, ÄŤĂ­slo dĂˇle nevyuĹľĂ­vĂˇme.');
}

function showActionDialog() {

	$("#actionText").dialog({width: 800, modal: true});

	return false;
}

function zobrazOtazku(id)
{
  if(qid_last > 0) {
    $('#answer-' + qid_last).css("display", "none");
  }
  if(qid_last == id) {
    qid_last = 0;
    $('#answer-' + id).css("display", "none");
  }
  else {
    $('#answer-' + id).css("display", "block");
    qid_last = id;
  }
}

