'+strLen[uid]['alias']+' MIN. '+strLen[uid]['len']+' znakova'+'');
return false;
}
}
return true;
}
function submitOffersPhoneData(oID){
console.log('stepCount: '+offersPhone_stepCount);
if(!submitOffersPhoneAllowed) return null;
var returnData = null;
if(offersPhone_stepCount<2 && offersPhone_vName=='' && offersPhone_vPhone==''){
offersPhone_vName = $('.phone-visitor-name').val().trim();
offersPhone_vPhone = $('.phone-visitor-phone').val().trim();
//console.log('vName: '+offersPhone_vName);
}
//fetch last step
offersPhone_vMail = $('#phone-order-delivery-email').val().trim();
var dataString = 'visitor_name='+offersPhone_vName+'&visitor_phone='+offersPhone_vPhone+'&order_name='+offersPhone_oName+'&order_id='+offersPhone_oID+'&visitor_address='+offersPhone_vAddress+'&visitor_address_postal='+offersPhone_vAddressPostal+'&visitor_address_town='+offersPhone_vAddressTown+'&visitor_address_county='+offersPhone_vAddressCountry+'&visitor_mail='+offersPhone_vMail+'&order_quantity='+offersPhone_vOrderQuantity+'&visitor_phone2='+offersPhone_vOrderPhone2+'&visitor_address_firstname='+offersPhone_vAddressFname+'&visitor_address_lastname='+offersPhone_vAddressLname;
//console.log(dataString);
$.ajax({
dataType:"json"
,type:"POST"
,url:"http://www.ponude.megapopust.hr/offersPhone/saveRequest"
,cache: false
,async: false
,data:dataString
,success:function (status) {
returnData = status;
submitOffersPhoneAllowed = false; // disallow next ajax until pop-up manually opened on click
if(returnData['status']!==null && typeof(returnData['status'])!=='undefined' && returnData['status']==1){
$('.phone-visitor-submit').hide();
$('#phone-order-popup div.wrapper h4').hide();
$phoneOrder.find('.wrapper div.form').html(returnData.msg);
if($phoneOrder.css('display') == 'none'){
location.reload();
}
else{
//
}
//$phoneOrder.find('p.note').addClass('success');
}
else if(offersPhone_stepCount>=0){
offersPhone_stepCount=0;
submitOffersPhoneAllowed = true;
$phoneOrderForm.html(phoneOrderTemplate);
showMessage(''+returnData.msg+'');
//alert(returnData.msg);
}
}
,error:function(err){
}
});
return returnData;
}
// when window/tab being closed
window.addEventListener("beforeunload", function (e) {
//var confirmationMessage = "\o/";
if(offersPhone_stepCount>0){
submitOffersPhoneData();
}
//(e || window.event).returnValue = confirmationMessage; //Gecko + IE
//return confirmationMessage; //Webkit, Safari, Chrome
});
$('.phone-visitor-submit').click(function(){
offersPhone_stepCount++;
console.log('stepCount: '+offersPhone_stepCount);
if(offersPhone_stepCount==1){
offersPhone_vName = $('.phone-visitor-name').val().trim();
offersPhone_vPhone = $('.phone-visitor-phone').val().trim();
if(!phoneFieldsValidation('.phone-visitor-name', offersPhone_vName)){ offersPhone_stepCount--; return false; }
if(!phoneFieldsValidation('.phone-visitor-phone', offersPhone_vPhone)){ offersPhone_stepCount--; return false; }
//var _html = '';
//$('#phone-order-popup div.wrapper h4').html(_html);
$phoneOrderForm.html(phoneOrderTemplate2);
}
else if(offersPhone_stepCount==2){
offersPhone_vAddressFname = $('#phone-order-delivery-address-fname').val().trim();
offersPhone_vAddressLname = $('#phone-order-delivery-address-lname').val().trim();
offersPhone_vAddress = $('#phone-order-delivery-address').val().trim();
offersPhone_vAddressPostal = $('#phone-order-delivery-address-postal').val().trim();
offersPhone_vAddressTown = $('#phone-order-delivery-address-town').val().trim();
offersPhone_vAddressCountry = $('#phone-order-delivery-address-country').val().trim();
offersPhone_vOrderQuantity = $('#phone-order-delivery-address-quantity').val().trim();
offersPhone_vOrderPhone2 = $('#phone-order-delivery-address-phone2').val().trim();
if(!phoneFieldsValidation('#phone-order-delivery-address-phone2', offersPhone_vOrderPhone2)){ offersPhone_stepCount--; return false; }
if(!phoneFieldsValidation('#phone-order-delivery-address-quantity', offersPhone_vOrderQuantity, 'numeric')){ offersPhone_stepCount--; return false; }
$phoneOrderForm.html(phoneOrderTemplate3);
}
else if(offersPhone_stepCount==3){
submitOffersPhoneData();
}
});
/*
*
* COUNTDOWN
*
*/
setTimeout("refreshTimers()", 1000);
/*
*
* ELEMENTS
*
*/
$('header .area a').click(function() {
$('header .other-areas').stop(true,true);
if ($('header .other-areas:visible').length > 0) {
$('header .area a').removeClass('active');
$('header .other-areas').slideUp();
} else {
$('header .area a').addClass('active');
$('header .other-areas').slideDown();
}
return false;
});
$('header .login p a').not('.profile-link').click(function() {
if ($(this).hasClass('active')) {
$('header .login ul').slideUp(function() {
$('header .login p a').removeClass('active');
});
} else {
$(this).addClass('active');
$('header .login ul').slideDown(function() {
$('header .login ul input:eq(0)').focus();
});
}
return false;
});
$('p.login a').click(function() {
$('header .login p a').not('.profile-link').click();
return false;
});
// fix z-index
// $('.login ul').css('z-index', '10001');
$('.change-area').click(function() {
$('header .area a').click();
return false;
});
$('.tabs a.tab').click(function() {
if ($(this).hasClass('active')) return false;
var index = $('.tabs a.tab').index($(this));
$('.tabs a.tab').removeClass('active');
$('.tabs a.tab:eq(' + index + ')').addClass('active');
$('.main-content div.tab:visible').hide();
$('.main-content div.tab:eq(' + index + ')').show();
if (index > 0) {
$('.main-content').css('border-radius', '7px');
} else {
$('.main-content').css('border-radius', '0 7px 7px 7px');
}
return false;
});
$('.daily-offer a, a.show-newsletter').click(function() {
//$.fancybox($('#popup-daily-offer'), { padding:0, closeBtn: false, wrapCSS:'rounded' });
$.fancybox($('#popup-first-load'), {
padding:0,
closeBtn: false,
scrolling: 'no',
wrapCSS: 'rounded',
maxWidth : $('#popup-first-load').width() + parseFloat($('#popup-first-load').css('padding-left').replace(/px/)),
afterShow: function() { $('#popup-first-load .email').focus(); } });
return false;
});
$('#popup-daily-offer .close a').click(function() {
$.fancybox.close();
});
$('#popup-first-load .close a').click(function() {
$.fancybox.close();
});
$('#alert .close a').click(function(e) {
e.preventDefault();
$.fancybox.close();
return false;
});
// if first visit open popup (skip if IE 6,7)
if (!(( $.browser.msie ) && (($.browser.version == '6.0') || (($.browser.version == '7.0')))) ) {
$.fancybox($('#popup-first-load'), { padding:0, closeBtn: false, 'scrolling': 'no', wrapCSS: 'rounded', maxWidth : $('#popup-first-load').width() + parseFloat($('#popup-first-load').css('padding-left').replace(/px/)) });
}
/*
*
* REGISTER
*
*/
$('input.register').click(function() {
$('div.register input.error').removeClass('error');
$('.list-errors li').hide();
if ($('#register_firstname').val().length < 2) {
$('#register_firstname').addClass('error');
$('.list-errors .register_error_firstname').show();
}
if ($('#register_lastname').val().length < 2) {
$('#register_lastname').addClass('error');
$('.list-errors .register_error_lastname').show();
}
if (!validateEmail($('#register_email').val())) {
$('#register_email').addClass('error');
$('.list-errors .register_error_email').show();
}
if ($('#register_password').val().length < 4) {
$('#register_password').addClass('error');
$('.list-errors .register_error_password').show();
}
if ($('#register_password').val() != $('#register_confirm').val()) {
$('#register_confirm').addClass('error');
$('.list-errors .register_error_confirm').show();
}
if ($('#register_address').val().length < 2) {
$('#register_address').addClass('error');
$('.list-errors .register_error_address').show();
}
if ( ($('#register_postal').val().length < 5) /* || ($('#register_postal').val().length > 5) */ ) {
$('#register_postal').addClass('error');
$('.list-errors .register_error_postal').show();
}
if ($('#register_town').val().length < 2) {
$('#register_town').addClass('error');
$('.list-errors .register_error_town').show();
}
if ($('#register_country').val().length < 2) {
$('#register_country').addClass('error');
$('.list-errors .register_error_country').show();
}
if (!$('#register_terms').prop("checked")) {
$('#register_terms').addClass('error');
$('.list-errors .register_error_terms').show();
}
if ($('div.register input.error').length > 0) {
$('.list-errors').fadeIn();
} else {
$('#register').ajaxForm();
$('#register').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/customer/register",
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
$('h2').html('Registracija uspješna');
$('div.register').hide();
$('div.success').show();
$('html, body').animate({
scrollTop: 0
}, 1000);
} else {
showMessage(data.message);
}
}
});
}
return false;
});
/*
*
* LOGIN
*
*/
if (document.URL.indexOf('#login') > 0) {
$('header .login p a').click();
}
$('#login').submit(function() {
$('#login .login-button').hide();
$('#login .login-message').show();
$('#login').ajaxForm();
$('#login').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/customer/login",
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
// if (document.URL.indexOf('#login') > 0) {
document.location = 'http://www.ponude.megapopust.hr/customer/profile';
return false;
// }
$('header p.cta').hide();
$('header p.daily-offer a').css('left','533px');
$('header div.login').html('Moj profil
');
if ($('#checkout-register').length > 0) {
var sURL = unescape(window.location.pathname);
window.location.href = sURL;
}
} else {
$('#login .login-message').hide()
$('#login .login-message-error').show();
setTimeout(function() {
$('#login .login-button').show();
$('#login .login-message-error').hide();
},5000);
}
}
});
return false;
});
/*
*
* PROFILE
*
*/
$('a.profile').click(function() {
if ($(this).hasClass('active')) return false;
$('.main-tabs a').removeClass('active');
$('.wrapper .content').hide();
$('.wrapper .content.profile').show();
$(this).addClass('active');
return false;
});
$('a.profile-edit').click(function() {
if ($(this).hasClass('active')) return false;
$('.wrapper .content').hide();
$('.wrapper .content.profile-edit').show();
$('.main-tabs a').removeClass('active');
$(this).addClass('active');
return false;
});
$('a.profile-coupons').click(function() {
if ($(this).hasClass('active')) return false;
$('.wrapper .content').hide();
$('.wrapper .content.profile-coupons').show();
$('.main-tabs a').removeClass('active');
$(this).addClass('active');
return false;
});
$('a.profile-newsletter').click(function() {
if ($(this).hasClass('active')) return false;
$('.wrapper .content').hide();
$('.wrapper .content.profile-newsletter').show();
$('.main-tabs a').removeClass('active');
$(this).addClass('active');
return false;
});
$('a.profile-edit-cancel').click(function() {
$('a.profile').click();
return false;
});
$('#profile-edit').submit(function() {
$('#profile-edit').ajaxForm();
$('#profile-edit').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/customer/saveprofile",
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
showMessage('Podaci su uspješno spremljeni!');
} else {
showMessage(data.message);
}
}
});
return false;
});
$('.profile-edit-button').click(function() {
$('a.profile-edit').click();
});
$('.profile-edit-password').click(function() {
$('a.profile-edit').click();
$('html, body').animate({
scrollTop: $("h3.edit-password").offset().top
}, 1000);
});
$('.show-coupons').click(function() {
if ($(this).closest('tr').find('.coupons:visible').length > 0) {
$(this).closest('tr').find('.coupons').slideUp();
} else {
$(this).closest('tr').find('.coupons').slideDown();
}
return false;
});
$('.profile-coupons .show-active').click(function() {
$('.profile-coupons .show-active').addClass('active');
$('.profile-coupons .show-expired').removeClass('active');
$('.profile-coupons .show-all').removeClass('active');
$('.profile-coupons tr.active').show();
$('.profile-coupons tr.expired').hide();
return false;
});
$('.profile-coupons .show-expired').click(function() {
$('.profile-coupons .show-active').removeClass('active');
$('.profile-coupons .show-expired').addClass('active');
$('.profile-coupons .show-all').removeClass('active');
$('.profile-coupons tr.active').hide();
$('.profile-coupons tr.expired').show();
return false;
});
$('.profile-coupons .show-all').click(function() {
$('.profile-coupons .show-active').removeClass('active');
$('.profile-coupons .show-expired').removeClass('active');
$('.profile-coupons .show-all').addClass('active');
$('.profile-coupons tr.active').show();
$('.profile-coupons tr.expired').show();
return false;
});
$('.profile-coupons .show-active').click();
$('#newsletter-form').submit(function() {
$('#newsletter-form input.prijavi').hide();
$('#newsletter-form').ajaxForm();
$('#newsletter-form').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/customer/newsletteradd",
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
var html = $('ul.newsletter').html();
if ($('ul.newsletter li em').length > 0) {
html = '';
}
html += '\
\
Primate obavijesti za grad: ' + data.town + '
\
Obriši\
';
$('ul.newsletter').html(html);
$('#newsletter-form input.prijavi').show();
newsletterDelete();
} else {
showMessage('Već ste prijavljeni da primate obavijesti za odabrani grad!');
$('#newsletter-form input.prijavi').show();
}
}
});
return false;
});
function newsletterDelete() {
$('ul.newsletter a.delete').click(function() {
var btn = $(this);
btn.hide();
$.ajax({
url: "http://www.ponude.megapopust.hr/customer/newsletterremove/"+$(this).attr('item_id'),
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
btn.parent().remove();
if ($('ul.newsletter li').length == 0) {
$('ul.newsletter').html('\
\
Niste prijavljeni na nijedan newsletter :(\
');
}
} else {
btn.show();
}
}
});
return false;
});
}
newsletterDelete();
// newsletter - new
$('#newsletter-form .prijavi').click(function() {
var towns = '';
$('#newsletter-towns li.checked').each(function() {
towns += $(this).find('a').attr('town_id') + ',';
});
$('#newsletter-form .towns-data').val(towns);
$('#newsletter-form').ajaxForm();
$('#newsletter-form').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/customer/newsletteradd",
type: "POST",
dataType: 'json',
success: function(data){
showMessage('Promjene prijave na newsletter su uspješno spremljene.');
}
});
});
$('#unsubscribe-form .prijavi').click(function() {
var towns = '';
$('#newsletter-towns li.checked').each(function() {
towns += $(this).find('a').attr('town_id') + ',';
});
$('#unsubscribe-form .towns-data').val(towns);
$('#unsubscribe-form').ajaxForm();
$('#unsubscribe-form').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/newsletter/change",
type: "POST",
dataType: 'json',
success: function(data){
showMessage('Promjene prijave na newsletter su uspješno spremljene.');
}
});
});
/*
*
* CHECKOUT
*
*/
$('#coupons').change(function() {
checkoutCalcTotal();
});
$('#couponsfriends').change(function() {
checkoutCalcTotal();
friendsFields();
});
function checkoutCalcTotal() {
var total = parseFloat($('#price').val()) * ( parseFloat($('#coupons').val()) + parseFloat($('#couponsfriends').val()) );
$('.total').html(total.toFixed(2) + ' kn');
}
function friendsFields() {
var count = 0;
$('ul.friend').each(function() {
count++;
if (count <= parseFloat($('#couponsfriends').val())) {
$(this).show();
} else {
$(this).hide();
}
});
}
function validateCheckoutCustomerFields() {
$('#checkout-register li.error').removeClass('error');
if ($('#checkout-firstname').val().length < 2) {
$('#checkout-firstname').closest('li').addClass('error');
}
if ($('#checkout-lastname').val().length < 2) {
$('#checkout-lastname').closest('li').addClass('error');
}
if ($('#checkout-address').val().length < 2) {
$('#checkout-address').closest('li').addClass('error');
}
if ($('#checkout-postal').val().length < 5) {
if (!$('#checkout-postal').attr('readonly')) $('#checkout-postal').closest('li').addClass('error');
}
if ($('#checkout-town').val().length < 2) {
$('#checkout-town').closest('li').addClass('error');
}
if ($('#checkout-country').val().length < 2) {
if (!$('#checkout-country').attr('readonly')) $('#checkout-country').closest('li').addClass('error');
}
if (!validateEmail($('#checkout-email').val())) {
$('#checkout-email').closest('li').addClass('error');
}
if ($('#checkout-password').val().length < 5) {
$('#checkout-password').closest('li').addClass('error');
} else {
if ($('#checkout-password').val() != $('#checkout-password-confirm').val()) {
$('#checkout-password-confirm').closest('li').addClass('error');
}
}
if ($('#checkout-password-confirm').val().length < 5) {
$('#checkout-password-confirm').closest('li').addClass('error');
}
// login
if (!validateEmail($('#checkout-login-email').val())) {
$('#checkout-login-email').closest('li').addClass('error');
}
if ($('#checkout-login-password').val().length < 4) {
$('#checkout-login-password').closest('li').addClass('error');
}
}
checkoutCalcTotal();
friendsFields();
$('#checkout-register .complete').click(function() {
validateCheckoutCustomerFields();
if ($('#checkout-login-email:visible').length > 0) {
if ($('#checkout-register .customer-login .error:visible').length > 0) {
return false;
}
$('#checkout-register .login').click();
return false;
}
if ($('#checkout-register .customer-info:visible .error:visible').length > 0) {
return false;
}
if ($('#checkout-register .customer-info.customer-login li:visible').length > 0) {
showMessage('Molimo da prvo potvrdite prijavu!');
return false;
}
if ($('#checkout-register .customer-register-confirm:visible').length > 0) {
showMessage('Molimo da prvo dovršite registraciju!');
return false;
}
if ( ($('input.payway:checked').length == 0) && ($('input.bank-transfer:checked').length == 0)
&&( $('input.pouzece').length>0 && $('input.pouzece:checked').length == 0)
) {
showMessage('Molimo odaberite način plaćanja!');
return false;
}
//$('#checkout-register').submit();
});
$('#checkout-register .customer-register-confirm').click(function() {
validateCheckoutCustomerFields();
if ($('#checkout-register .customer-info:visible .error:visible').length > 0) {
return false;
}
if ($('#checkout-register .customer-info.customer-login li:visible').length > 0) {
showMessage('Molimo da prvo potvrdite prijavu!');
return false;
}
$('#checkout-register .customer-info:visible li input').attr('readonly', true);
$('html, body').animate({
scrollTop: $(".wrapper").offset().top
}, 500);
//$('#checkout-register').ajaxForm();
//$('#checkout-register').ajaxSubmit();
$('#delivery').text($('#checkout-firstname').val() + " " + $('#checkout-lastname').val() + ", " + $('#checkout-address').val() + ", " + $('#checkout-postal').val() + " " + $('#checkout-town').val());
$('#checkout-register').ajaxForm();
$('#checkout-register').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/customer/register",
type: "POST",
dataType: 'json',
success: function(data){
$.ajax({
url: "http://www.ponude.megapopust.hr/customer/login",
data: "email=" + $('#checkout-email').val() + "&password=" + $('#checkout-password').val(),
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
userLoggedIn = 1;
if($('#additional-info-wrap').length>0){
var $additionalInfoWrap = $('#additional-info-wrap');
$additionalInfoWrap.find('input[name="ai-fname"]').val($('#checkout-firstname').val());
$additionalInfoWrap.find('input[name="ai-lname"]').val($('#checkout-lastname').val());
$additionalInfoWrap.find('input[name="ai-address"]').val($('#checkout-address').val());
$additionalInfoWrap.find('input[name="ai-postal"]').val($('#checkout-postal').val());
$additionalInfoWrap.find('input[name="ai-town"]').val($('#checkout-town').val());
$additionalInfoWrap.find('input[name="ai-country"]').val($('#checkout-country').val());
$additionalInfoWrap.find('input[name="ai-contact"]').val($('#checkout-mobile').val());
}
$('#checkout-register .customer-register-confirm').fadeOut();
$('#checkout-register').ajaxFormUnbind();
if(!$('#checkout-register input[name="payment"]').is(":checked")){
showMessage('Za dovršetak kupovine odaberite način plaćanja i pritisnite "Nastavak".');
}
else{
showMessage('Za dovršetak kupovine pritisnite "Nastavak".');
}
}
}
});
}
});
return true;
});
$('#checkout-register').attr('autocomplete', 'on');
$('#checkout-login-email').attr('autocomplete', 'on');
$('#checkout-register .login').click(function() {
$.ajax({
url: "http://www.ponude.megapopust.hr/customer/login",
data: "email=" + $('#checkout-login-email').val() + "&password=" + $('#checkout-login-password').val(),
type: "POST",
dataType: 'json',
success: function(data){
if (data.success) {
document.location = 'http://www.ponude.megapopust.hr/checkout/register';
/*
$('#checkout-register').unbind('submit');
$('#checkout-register').ajaxForm();
$('#checkout-register').ajaxSubmit({
type: "POST",
dataType: 'json',
success: function(data){
document.location = 'http://www.ponude.megapopust.hr/checkout/register';
}
});
*/
} else {
$('#checkout-register .customer-info.customer-login li.forgot-password').fadeIn();
}
}
});
return false;
});
$('#checkout-register .customer-register').click(function() {
$('#checkout-register .new-user .hidden-password').show();
$('#checkout-register .complete').show();
$('#checkout-register .new-user-caption').html('Registrirajte se');
$('#checkout-register .customer-login-back').show();
$('#checkout-register .login-user').slideUp();
$('#checkout-register .new-user').fadeIn();
return false;
});
$('#checkout-register .customer-login-back-link').click(function() {
$('#checkout-register .login-user').slideDown();
$('#checkout-register .new-user').fadeOut();
return false;
});
$('#checkout-select').submit(function() {
var result = true;
try {
if (!((parseFloat($('#coupons').val()) + parseFloat($('#couponsfriends').val())) > 0)) {
showMessage('Molimo odaberite broj kupona!');
return false;
}
} catch (ex) {
showMessage('Molimo odaberite broj kupona!');
return false;
}
$('ul.friend:visible').each(function() {
if ($(this).find('.friend-name').val().length < 2) {
result = false;
}
});
if (!result) {
showMessage('Molimo unesite imena svih prijatelja kojima želite pokloniti kupon!');
return false;
}
return true;
});
if ($('#webshop_data').length > 0) {
setTimeout(function() {
$('#webshop_data').submit();
}, 3000);
};
$("a").click(function(){
var adresa = $(this).attr("href");
// console.log (adresa);
if ((adresa == "http://ponude.megapopust.hr/proizvodi") || (adresa == "http://www.ponude.megapopust.hr/proizvodi")) {
event.preventDefault();
window.open('http://megapopust.hr/collections/all-products', '_blank');
}
});
//
// Gallery
//
$('.gallery .preview').hover(
function() {
clearTimeout(galDefImgTimeout);
},
function() {
galDefImgTimeout = setTimeout(function() {
$('.gallery .preview').removeClass('active');
$('.main-image a:visible').fadeOut();
$('.main-image a:eq(0)').fadeIn();
}, 7000);
}
);
$('.gallery .preview').click(function() {
// $('.main-image').attr('src', $(this).attr('href'));
if ($(this).hasClass('active')) return false;
$('.gallery .preview').removeClass('active');
$(this).addClass('active');
var index = $('.gallery .preview').index($(this));
$('.main-image a:visible').fadeOut();
$('.main-image a:eq(' + index + ')').fadeIn();
return false;
});
$('.gallery .btns .item-1 a').click(function() {
$('.gallery-inner').stop(true,true);
var top = parseFloat($('.gallery-inner').css('top').replace(/px/));
var height = parseFloat($('.gallery-inner').height());
if ((height + top - 80) <= $('.gallery').height()) {
$('.gallery-inner').animate({
'top':'-=80px'
}, 500, function() {
if (parseFloat($('.gallery-inner').css('top').replace(/px/)) < 0) {
$('.gallery .btns .item-2 a').fadeIn();
}
});
$('.gallery .btns .item-1 a').fadeOut();
return false;
}
$('.gallery-inner').animate({
'top':'-=80px'
}, 500, function() {
if (parseFloat($('.gallery-inner').css('top').replace(/px/)) < 0) {
$('.gallery .btns .item-2 a').fadeIn();
}
});
return false;
});
$('.gallery .btns .item-2 a').click(function() {
$('.gallery-inner').stop(true,true);
var top = parseFloat($('.gallery-inner').css('top').replace(/px/));
if ((top + 80) >= 0) {
$('.gallery-inner').animate({
'top':'+=' + (Math.abs(top)) + 'px'
}, 500, function() {
$('.gallery .btns .item-1 a').fadeIn();
});
$('.gallery .btns .item-2 a').fadeOut();
return false;
}
$('.gallery-inner').animate({
'top':'+=80px'
}, 500, function() {
$('.gallery .btns .item-1 a').fadeIn();
});
return false;
});
$('.fancybox').fancybox({
openEffect: 'fade',
closeEffect: 'fade',
nextEffect: 'fade',
prevEffect: 'fade',
maxWidth : '100%'
});
/*
*
* NEWSLETTER
*
*/
$('#newsletter .newsletter-towns').click(function() {
if (!validateEmail($('#newsletter .email').val())) {
showMessage('Molimo unesite ispravnu e-mail adresu!');
return false;
}
$.fancybox($('#newsletter-towns'), { padding:0, closeBtn: false, 'scrolling': 'no', wrapCSS: 'rounded', maxWidth : $('#newsletter-towns').width() + parseFloat($('#newsletter-towns').css('padding-left').replace(/px/)) });
return false;
});
$('#newsletter .email').focus(function() {
if ($(this).val() == 'Unesite svoju email adresu') {
$(this).val('');
}
});
$('#newsletter .email').blur(function() {
if ($(this).val() == '') {
$(this).val('Unesite svoju email adresu');
}
});
$('.newsletter-towns li a').click(function() {
if ($(this).parent().hasClass('checked')) {
$(this).parent().removeClass('checked');
} else {
$(this).parent().addClass('checked');
}
return false;
});
$('#newsletter-towns .send').click(function() {
if ($('#newsletter-towns li.checked').length == 0) {
showMessage('Molimo odaberite grad!');
return false;
}
$.fancybox.close();
var towns = '';
$('#newsletter-towns li.checked').each(function() {
towns += $(this).find('a').attr('town_id') + ',';
});
$('#newsletter .towns').val(towns);
$('#newsletter .newsletter').ajaxForm();
$('#newsletter .newsletter').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/newsletter/add",
type: "POST",
dataType: 'json',
success: function(data){
document.location = 'http://www.ponude.megapopust.hr/newsletter-prijava';
}
});
});
$('#newsletter-towns p.close a').click(function() {
$.fancybox.close();
return false;
});
$('#popup-first-load .submit').click(function() {
if (!validateEmail($('#popup-first-load .email').val())) {
$('#popup-first-load label.error').html('Molimo unesite ispravnu e-mail adresu!');
$('#popup-first-load label.error').fadeIn();
return false;
}
if ($('#popup-first-load li.checked').length == 0) {
$('#popup-first-load label.error').html('Molimo odaberite grad!');
$('#popup-first-load label.error').fadeIn();
return false;
}
$.fancybox.close();
var towns = '';
$('#popup-first-load li.checked').each(function() {
towns += $(this).find('a').attr('town_id') + ',';
});
$('#popup-first-load .towns').val(towns);
$('#popup-first-load .newsletter').ajaxForm();
$('#popup-first-load .newsletter').ajaxSubmit({
url: "http://www.ponude.megapopust.hr/newsletter/add",
type: "POST",
dataType: 'json',
success: function(data){
document.location = 'http://www.ponude.megapopust.hr/newsletter-prijava';
}
});
$('#popup-first-load label.error').fadeOut();
});
/*
*
* SEARCH
*
*/
$('li.search a').click(function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active');
$('#search').slideUp();
} else {
$(this).parent().parent().find('.active').removeClass('active');
$('li.search a').addClass('active');
$('#search').slideDown();
}
return false;
});
$('.search-box').focus(function() {
if ($(this).val() == 'Traži ponudu... npr. Restoran, Pizza, Hotel') $(this).val('');
});
$('.search-box').blur(function() {
if ($(this).val() == '') $(this).val('Traži ponudu... npr. Restoran, Pizza, Hotel');
});
/*
*
* FIX ROUND BORDERS
*
*/
if ($('.main-tabs ul li a').index($('.main-tabs ul li a.active')) == 0) {
$('.content').css('border-radius', '0 7px 7px 7px');
}
$('#popup-first-load .submit').click(function() {
});
/*
*
* FIX ROUND BORDERS
*
*/
$('a.gmap').click(function() {
$.fancybox($('#gmap'), { padding:0, 'scrolling': 'no', wrapCSS: 'rounded', maxWidth : $('#gmap').width() + parseFloat($('#gmap').css('padding-left').replace(/px/)) });
try {
initialize_map();
} catch (ex) {
console.log(ex);
}
});
/*
*
* NEW PASSWORD
*
*/
$('#new-password-form').submit(function() {
if ($('#new-password').val().length < 4) {
showMessage('Lozinka mora biti duga minimalno 4 znaka!');
return false;
}
if ($('#new-password').val() != $('#confirm-password').val()) {
showMessage('Molimo potvrdite lozinku!');
return false;
}
return true;
});
$('.back-to-top').click(function() {
$('html, body').animate({
scrollTop: 0
}, 1000);
});
$('header .inner div.login ul').css('z-index', '10001');
// FIX Z-INDEX (IE 6,7 ONLY)
if ( ( $.browser.msie ) && (($.browser.version == '6.0') || (($.browser.version == '7.0'))) ) {
var zIndexNumber = 1000;
$('div').each(function() {
$(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});
if ($.browser.version == '6.0') {
$('.featured .offer').css('width','720px');
$('.featured .offer .info').css('float', 'right');
}
}
// SELECT RELATED
$('.select-related').click(function() {
$.fancybox($('#related-offers'), { padding:0, 'scrolling': 'yes', wrapCSS: 'rounded', maxWidth : $('#related-offers').width() + parseFloat($('#related-offers').css('padding-left').replace(/px/)) });
return false;
});
});
function showMessage(text) {
$('#alert p.message').html(text);
$.fancybox($('#alert'), { padding:0, closeBtn: false, 'scrolling': 'no', wrapCSS: 'rounded', maxWidth : $('#alert').width() + parseFloat($('#alert').css('padding-left').replace(/px/)) });
}