function showAvailabilityQuestionBox( productName ){
// vymazani obsahu
$("#showAvailabilityQuestion").html('');
$("#showAvailabilityQuestion").text('');
// vytvoreni elementu
$('#showAvailabilityQuestion').createAppend(
'h1', {}, 'Poslat dotaz na dostupnost'
);
$('#showAvailabilityQuestion').createAppend(
'strong', {}, ''
);
$('#showAvailabilityQuestion').createAppend(
'p', {}, 'Po odeslání Vašeho dotazu ověříme dostupnost v nejbližším smluvním skladu a ozveme se Vám zpět. Obvykle odpovídáme do&nbsp;24&nbsp;hodin, ve výjimečných případech může odpověď trvat déle.'
);
// vytvoreni formulare
$('#showAvailabilityQuestion').createAppend(
'form', { id: 'availabilityQuestionForm', className: 'tForm', action: 'javascript:void(0)' }, ''
);
// vytvoreni formularovych poli
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Vaše jméno a příjmení:* ',
'input', { type: 'text', id: 'customer_name', name: 'customer_name', style: 'width: 300px; margin-left: 10px;' }, ''
]
);  
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'E-mail:* ',
'input', { type: 'text', id: 'customer_email', name: 'customer_email', style: 'width: 300px; margin-left: 10px;' }, ''
]
);
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Telefonní číslo:* ',
'input', { type: 'text', id: 'customer_phone', name: 'customer_phone', style: 'width: 300px; margin-left: 10px;' }, ''
]
);
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Město:* ',
'input', { type: 'text', id: 'customer_city', name: 'customer_city', style: 'width: 300px; margin-left: 10px;' }, ''
]
);
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Vaše zpráva pro nás:* ',
'textarea', { id: 'customer_text', name: 'customer_text', style: 'width: 300px; height: 150px; margin-left: 10px;' }, 'Dotaz na skladovou dostupnost produktu ' + productName + '',
'input', { type: 'hidden', id: 'productName', name: 'productName', style: 'display: none;', value: '' + productName + '' }, ''
]
);
// tlacitko
/*$('#availabilityQuestionForm').createAppend(
'button', { type: 'button', onclick: 'checkAllData( "' + productName + '" )' }, 'Odeslat'
);*/
$(document).ready(function(){
$("#showAvailabilityQuestion").dialog({
modal: true,
width: 650,
buttons: { "Odeslat": function() { checkAllData( productName ); } }
});
if( !$("#showAvailabilityQuestion").dialog( "isOpen" )  ){
$("#showAvailabilityQuestion").dialog( "open" );
}
});
}
function showRecommendationBox( productName, productUrl ){
// vymazani obsahu
$("#showAvailabilityQuestion").html('');
$("#showAvailabilityQuestion").text('');
// vytvoreni elementu
$('#showAvailabilityQuestion').createAppend(
'h1', {}, 'Doporučit produkt emailem'
);
// vytvoreni formulare
$('#showAvailabilityQuestion').createAppend(
'form', { id: 'availabilityQuestionForm', className: 'tForm', action: 'javascript:void(0)' }, ''
);
// vytvoreni formularovych poli
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Vaše jméno a příjmení:* ',
'input', { type: 'text', id: 'sender_name', name: 'sender_name', style: 'width: 300px; margin-left: 10px;' }, ''
]
);
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Váš e-mail:* ',
'input', { type: 'text', id: 'sender_email', name: 'sender_email', style: 'width: 300px; margin-left: 10px;' }, ''
]
);
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'E-mail příjemnce zprávy:* ',
'input', { type: 'text', id: 'recipient_email', name: 'recipient_email', style: 'width: 300px; margin-left: 10px;' }, ''
]
);
$('#availabilityQuestionForm').createAppend(
'div', { className: 'formItem' }, [
'label', { style: 'width: 165px;' }, 'Zpráva:* ',
'textarea', { id: 'message', name: 'message', style: 'width: 300px; height: 150px; margin-left: 10px;' }, 'Doporučuji navštívit stránku na adrese http://' + productUrl + '',
'input', { type: 'hidden', id: 'productName', name: 'productName', style: 'display: none;', value: '' + productName + '' }, '',
'input', { type: 'hidden', id: 'productUrl', name: 'productUrl', style: 'display: none;', value: '' + productUrl + '' }, ''
]
);
// tlacitko
/*$('#availabilityQuestionForm').createAppend(
'button', { type: 'button', onclick: 'checkAllData( "' + productName + '" )' }, 'Odeslat'
);*/
$(document).ready(function(){
$("#showAvailabilityQuestion").dialog({
modal: true,
width: 650,
buttons: { "Odeslat": function() { checkAllDataRecommedation( productName ); } }
});
if( !$("#showAvailabilityQuestion").dialog( "isOpen" )  ){
$("#showAvailabilityQuestion").dialog( "open" );
}
});
}
function checkAllData( productName ){
if( $("#sender_name").val() == "" ){
alert( 'Musíte vyplnit Vaše jméno a příjmení' );
$("#sender_name").focus();
return false;
}else if( $("#sender_email").val() == "" ){
alert( 'Musíte vyplnit Váš email' );
$("#customer_email").focus();
return false;
}else if( $("#rec_text").val() == "" ){
alert( 'Musíte vyplnit text zprávy' );
$("#customer_text").focus();
return false;
}else if( $("#customer_phone").val() == "" ){
alert( 'Musíte vyplnit telefonní číslo' );
$("#customer_phone").focus();
return false;
}else if( $("#customer_city").val() == "" ){
alert( 'Musíte vyplnit město' );
$("#customer_city").focus();
return false;
}else{
sendAvailabilityQuestion( productName );
return true;
}
}
function checkAllDataRecommedation( productName ){
if( $("#customer_name").val() == "" ){
alert( 'Musíte vyplnit Vaše jméno a příjmení' );
$("#customer_name").focus();
return false;
}else if( $("#customer_email").val() == "" ){
alert( 'Musíte vyplnit Váš e-mail' );
$("#customer_email").focus();
return false;
}else if( $("#recipient_email").val() == "" ){
alert( 'Musíte vyplnit e-mail příjemce zprávy' );
$("#recipient_email").focus();
return false;
}else if( $("#message").val() == "" ){
alert( 'Musíte vyplnit text zprávy' );
$("#message").focus();
return false;
}else{
sendRecommendation( productName );
return true;
}
}
function sendAvailabilityQuestion( productName ){
sData     = $('#availabilityQuestionForm').formSerialize();
$.ajax({
type: "POST",
url: './questionAjax.php',
data: sData,
success: function () {
$("#showAvailabilityQuestion").dialog( "close" );
$("#showAvailabilityQuestion").html( "" );
$("#showAvailabilityQuestion").text( "" );
}
});
}
function sendRecommendation( productName ){
sData     = $('#availabilityQuestionForm').formSerialize();
$.ajax({
type: "POST",
url: './recommendationAjax.php',
data: sData,
success: function () {
$("#showAvailabilityQuestion").dialog( "close" );
$("#showAvailabilityQuestion").html( "" );
$("#showAvailabilityQuestion").text( "" );
}
});
}
