var ColorBoxHeight;
var isFlash = $.fn.flash.hasFlash();
var versionFlash = $.fn.flash.hasFlash.playerVersion();
var pluginOptions = { version: versionFlash, expressInstall: true };

$.fn.flash.replace = function(htmlOptions) {
   if (isFlash && versionFlash != '0,0,0') {
      htmlOptions.replace = '';
	  $(this).html($.fn.flash.transform(htmlOptions));
   }
   else $(this).html(htmlOptions.replace);
};

$(document).ready(function() {
   $('body').mousemove(function(){ setCookie('z-p'); })
   $(document).pngFix();
   if ($("#gallery a[rel=fancy]").length) $("#gallery a[rel=fancy]").fancybox({ 'hideOnContentClick': true, 'overlayShow': true, 'overlayOpacity': 0.5, 'speedIn': 1000, 'speedOut': 600, 'titlePosition': 'inside', 'transitionIn': 'elastic', 'transitionOut': 'elastic' });
   var htmlOptions = { src: 'image/akziya_karta(1-31_okt).swf', width: '295', height: '142', replace: '' };
   $('#discFlash').flash(htmlOptions, pluginOptions);
   var htmlOptions = { src: 'image/vskarmlivanie3.swf', width: '100%', height: '50', replace: '' };
   if ($('#underTopFlash').length) $('#underTopFlash').flash(htmlOptions, pluginOptions);

   if ($('#colorboxlink').length) {
      $('#colorboxlink').click(function(){ $('#form_mail').show(); });
      if (($.browser.msie) && ($.browser.version == '6.0' || $.browser.version == '7.0')) ColorBoxHeight = '420px';
      else ColorBoxHeight = '390px';
      $('#colorboxlink').colorbox({
         width:"600px",
         height:ColorBoxHeight,
         inline:true,
         href:"#form_mail",
         onCleanup:function(){
            $('#form_mail input[name=fio]').val('');
            $('#form_mail input[name=email]').val('');
            $('#form_mail input[name=phone]').val('');
            $('#form_mail textarea[name=text]').val('');
            $('#form_mail').hide();
         }
      });
   }
});

function setCookie(str)
{
    var NowDate = new Date();
    var day = (NowDate.getDate() < 10 ? '0'+NowDate.getDate() : NowDate.getDate());
    var month = ((NowDate.getMonth() + 1) < 10 ? '0'+(NowDate.getMonth() + 1) : (NowDate.getMonth() + 1));
    var fullDate = day+'.'+month+'.'+NowDate.getFullYear();
    var cookieName = $().crypt({method:"md5",source:str+fullDate});
    var cookieVal = $().crypt({method:"md5",source:str+fullDate+'z-p'});
    if (!$.cookie(cookieName)) {
		var CookieOption = {path: '/'};
		$.cookie(cookieName, cookieVal, CookieOption);
    }
}
