jQuery.log = function(message) { if(window.console) { console.debug(message); } }; var player = null; $(function() { detectCss(); $('#contactForm').ajaxForm( { dataType: 'json', beforeSubmit: validate, success: processJson } ); }); function processJson(response){ $('#send').blur().attr('disabled',false); //$.log(response); $('#captcha').attr('src','captcha.php?'+ new Date().getTime()); $('#code').val(''); if(response.error != undefined) { $.each(response.error, function(k, v) { if(k != undefined) $('label[for='+k+']').addClass('red'); else{ $('label[for='+k+']').removeClass('red'); } }); return false; }else{ $('#contactForm').html('

Va multumim!

'); } } function validate(formData, jqForm, options) { $('#send').blur().attr('disabled',true); $.each(formData, function(i, el) { if(el.value == '') $('label[for='+el.name+']').addClass('red'); else{ $('label[for='+el.name+']').removeClass('red'); } }); } function detectCss(){ var gmtTime = new Date() var hour = gmtTime.getHours(),sCss = 'night'; if(hour >= 7 && hour < 12) sCss = 'morning'; else if(hour >= 12 && hour < 19) sCss = 'noon'; else if(hour >= 19 && hour < 21) sCss = 'evening'; createCookie('style', sCss, 1); return sCss; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } /*function switchStylestyle(styleName) { var c = readCookie('style'); $('link[rel*=style][title]').each(function(i){ $.log(this); this.disabled = true; if (this.getAttribute('title') == styleName) this.disabled = false; }); createCookie('style', styleName, 1); }*/ jQuery.fn.imageZoom=function(conf){var config=jQuery.extend({speed:200,dontFadeIn:1,hideClicked:1,imageMargin:15,className:'jquery-image-zoom',loading:'Loading...'},conf);config.doubleSpeed=config.speed/4; return this.click(function(e){var clickedElement=jQuery(e.target);var clickedLink=clickedElement.is('a')?clickedElement:clickedElement.parents('a');clickedLink=(clickedLink&&clickedLink.is('a')&&clickedLink.attr('href').search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)$/gi)!=-1)?clickedLink:false;var clickedImg=(clickedLink&&clickedLink.find('img').length)?clickedLink.find('img'):false;if(clickedLink){clickedLink.oldText=clickedLink.text();clickedLink.setLoadingImg=function(){if(clickedImg){clickedImg.css({opacity:'0.5'})}else{clickedLink.text(config.loading)}};clickedLink.setNotLoadingImg=function(){if(clickedImg){clickedImg.css({opacity:'1'})}else{clickedLink.text(clickedLink.oldText)}};var displayImgSrc=clickedLink.attr('href');if(jQuery('div.'+config.className+' img[src="'+displayImgSrc+'"]').length){return false}var preloadOnload=function(){clickedLink.setNotLoadingImg();var dimElement=clickedImg?clickedImg:clickedLink;var hideClicked=clickedImg?config.hideClicked:0;var offset=dimElement.offset();var imgzoomBefore={width:dimElement.outerWidth(),height:dimElement.outerHeight(),left:offset.left,top:offset.top};var imgzoom=jQuery('
').css('position','absolute').appendTo(document.body);var imgzoomAfter={width:imgzoom.outerWidth(),height:imgzoom.outerHeight()};var windowDim={width:jQuery(window).width(),height:jQuery(window).height()};if(imgzoomAfter.width>(windowDim.width-config.imageMargin*2)){var nWidth=windowDim.width-config.imageMargin*2;imgzoomAfter.height=(nWidth/imgzoomAfter.width)*imgzoomAfter.height;imgzoomAfter.width=nWidth}if(imgzoomAfter.height>(windowDim.height-config.imageMargin*2)){var nHeight=windowDim.height-config.imageMargin*2;imgzoomAfter.width=(nHeight/imgzoomAfter.height)*imgzoomAfter.width;imgzoomAfter.height=nHeight}imgzoomAfter.left=(windowDim.width-imgzoomAfter.width)/2+jQuery(window).scrollLeft();imgzoomAfter.top=(windowDim.height-imgzoomAfter.height)/2+jQuery(window).scrollTop();var closeButton=jQuery('Close').appendTo(imgzoom).hide();if(hideClicked){clickedLink.css('visibility','hidden')}imgzoom.addClass(config.className).css(imgzoomBefore).animate(imgzoomAfter,config.speed,function(){closeButton.fadeIn(config.doubleSpeed)});var hideImgzoom=function(){closeButton.fadeOut(config.doubleSpeed,function(){imgzoom.animate(imgzoomBefore,config.speed,function(){clickedLink.css('visibility','visible');imgzoom.remove()})});return false};imgzoom.click(hideImgzoom);closeButton.click(hideImgzoom)};var preload=new Image();preload.src=displayImgSrc;if(preload.complete){preloadOnload()}else{clickedLink.setLoadingImg();preload.onload=preloadOnload}return false}})};$(document).keydown(function(e){if(e.keyCode==27){$('div.jquery-image-zoom a').click()}});