document.domain = "csobautolease.cz";
var email_filter = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i;

function Pruvodce(open)
{
    if(open)
    {
	$('#wizard-close').css("display","none");
	$('#wizard-open').fadeIn();
    }
    else
    {
	$('#wizard-close').fadeIn();
	$('#wizard-open').css("display","none");
    }
	//document.getElementById('wizard-open').style.display = open?'block':'none';
	//document.getElementById('wizard-close').style.display = !open?'block':'none';
	return false;
}

$.setupJMPopups({
	screenLockerBackground: "#000000",
	screenLockerOpacity: "0.7"
});

function closepopuplayer()
{
	$.closePopupLayer('jmPopupDivId');
}

function firePruvodcePopup(content)
{
	var htmlparts = content.split('::heading::');
	document.getElementById('jpPopupHeading').innerHTML = htmlparts[0];
	document.getElementById('jpPopupDivBody').innerHTML = htmlparts[1];

	$.openPopupLayer({
		name: 'jmPopupDivId',
		target: 'jmPopupDiv',
		success: function() {
			
			document.getElementById('jpPopupHeading').innerHTML = '';
			document.getElementById('jpPopupDivBody').innerHTML = '';
			//alert('ilayer loaded - opening');
	    },
	    error:function()
	    {
	    	alert('error ocurred')
	    }
	});	
}

function firePruvodcePopupSmall(content)
{
	document.getElementById('jpPopupHeading').innerHTML = '';
	document.getElementById('jpPopupDivBody').innerHTML = content;
	
	$.openPopupLayer({
		name: 'jmPopupDivId',
		target: 'jmPopupDiv',
		success: function() {
			document.getElementById('jpPopupHeading').innerHTML = '';
			document.getElementById('jpPopupDivBody').innerHTML = '';
	    },
	    error:function()
	    {
	    	alert('error ocurred')
	    }
	});	
}

function step2()
{
	// validace formuláře
	if ($("#email-1").val() && !email_filter.test($("#email-1").val())) {
		alert('Zadejte platnou emailovou adresu!');
		return false;
	}
	
	if(($("#jmeno-1").val()
			|| $("#prijmeni-1").val()
			|| $("#telefon-1").val()
			|| $("#email-1").val())
		&& !$("#souhlas-1").attr('checked')) {
		alert('Zadali jste osobní údaje, musíte souhlasit se zpracováním osobních údajů!');
		return false;
	}

	// uložíme informaci do databáze, pokud teda něco vloženého je
	if ($("#jmeno-1").val()
			|| $("#prijmeni-1").val()
			|| $("#telefon-1").val()
			|| $("#email-1").val())
	{
		var data = "kraj=" + document.getElementById("kraj").value
		+ '&znacka=' + document.getElementById("znacka").value
		+ '&komodita=' + document.getElementById('komodita').value
		+ '&node_id=' + document.getElementById('nodeId').value
		+ "&jmeno=" + document.getElementById("jmeno-1").value
		+ '&prijmeni=' + document.getElementById("prijmeni-1").value
		+ '&telefon=' + document.getElementById('telefon-1').value
		+ '&email=' + document.getElementById('email-1').value
		+ '&poznamka=' + document.getElementById('poznamka-1').value;
		
		window.frames.iframe_pruvodce.saveFormDataFromParent(data);
	}
	else
	{
		alert('Zadali jste nekompletni údaje!');
	}

	return false;
}

function saveFormDataFromChild(msg)
{
	alert(msg);
}

