
var isIE6=navigator.userAgent.toLowerCase().indexOf('msie 6')!=-1;jQuery.fn.megamenu=function(options){options=jQuery.extend({activate_action:"mouseover",deactivate_action:"mouseleave",show_method:"slideDown",hide_method:"slideUp",justify:"left",enable_js_shadow:true,shadow_size:3,mm_timeout:250},options);var $megamenu_object=this;if(options.activate_action=="click")options.mm_timeout=0;$megamenu_object.children("li").each(function(){jQuery(this).addClass("mm-item");jQuery(".mm-item").css({'float':options.justify});jQuery(this).find("div:first").addClass("mm-item-content");jQuery(this).find("a:first").addClass("mm-item-link");var $mm_item_content=jQuery(this).find(".mm-item-content");var $mm_item_link=jQuery(this).find(".mm-item-link");$mm_item_content.hide();jQuery(document).bind("click",function(){jQuery(".mm-item-content").hide();jQuery(".mm-item-link").removeClass("mm-item-link-hover");});jQuery(this).bind("click",function(e){e.stopPropagation();});$mm_item_content.wrapInner('<div class="mm-content-base"></div>');if(options.enable_js_shadow==true){$mm_item_content.append('<div class="mm-js-shadow"></div>');}
var $mm_timer=0;jQuery(this).bind(options.activate_action,function(e){e.stopPropagation();var mm_item_link_obj=jQuery(this).find("a.mm-item-link");var mm_item_content_obj=jQuery(this).find("div.mm-item-content");clearTimeout($mm_timer);$mm_timer=setTimeout(function(){mm_item_link_obj.addClass("mm-item-link-hover");mm_item_content_obj.css({'top':($mm_item_link.offset().top+$mm_item_link.outerHeight())-1+"px",'left':($mm_item_link.offset().left)-5+'px'})
if(options.justify=="left"){var mm_object_right_end=$megamenu_object.offset().left+$megamenu_object.outerWidth();var mm_content_right_end=$mm_item_link.offset().left+$mm_item_content.outerWidth()-5;if(mm_content_right_end>=mm_object_right_end){mm_item_content_obj.css({'left':($mm_item_link.offset().left-(mm_content_right_end-mm_object_right_end))-2+'px'});}}else if(options.justify=="right"){var mm_object_left_end=$megamenu_object.offset().left;var mm_content_left_end=$mm_item_link.offset().left-mm_item_content_obj.outerWidth()+
$mm_item_link.outerWidth()+5;if(mm_content_left_end<=mm_object_left_end){mm_item_content_obj.css({'left':mm_object_left_end+2+'px'});}else{mm_item_content_obj.css({'left':mm_content_left_end+'px'});}}
if(options.enable_js_shadow==true){mm_item_content_obj.find(".mm-js-shadow").height(mm_item_content_obj.height());mm_item_content_obj.find(".mm-js-shadow").width(mm_item_content_obj.width());mm_item_content_obj.find(".mm-js-shadow").css({'top':(options.shadow_size)+(isIE6?2:0)+"px",'left':(options.shadow_size)+(isIE6?2:0)+"px",'opacity':0.5});}
switch(options.show_method){case"simple":mm_item_content_obj.show();break;case"slideDown":mm_item_content_obj.height("auto");mm_item_content_obj.slideDown('fast');break;case"fadeIn":mm_item_content_obj.fadeTo('fast',1);break;default:mm_item_content_obj.each(options.show_method);break;}},options.mm_timeout);});jQuery(this).bind(options.deactivate_action,function(e){e.stopPropagation();clearTimeout($mm_timer);var mm_item_link_obj=jQuery(this).find("a.mm-item-link");var mm_item_content_obj=jQuery(this).find("div.mm-item-content");switch(options.hide_method){case"simple":mm_item_content_obj.hide();mm_item_link_obj.removeClass("mm-item-link-hover");break;case"slideUp":mm_item_content_obj.slideUp('fast',function(){mm_item_link_obj.removeClass("mm-item-link-hover");});break;case"fadeOut":mm_item_content_obj.fadeOut('fast',function(){mm_item_link_obj.removeClass("mm-item-link-hover");});break;default:mm_item_content_obj.each(options.hide_method);mm_item_link_obj.removeClass("mm-item-link-hover");break;}
if(mm_item_content_obj.length<1)mm_item_link_obj.removeClass("mm-item-link-hover");});});this.find(">li:last").after('<li class="clear-fix"></li>');this.show();};;function openDialog(html,newOptions)
{var defaults={minWidth:300,minHeight:300,autoResize:true,width:600,height:"auto",resizable:true,modal:true,position:'center'};var options=jQuery.extend({},defaults,newOptions);jQuery("#popup").remove();jQuery("body").append("<div id=\"popup\">"+html+"</div>");jQuery("#popup").dialog(options);return true;}
jQuery.popup=function(newOptions)
{var defaults={url:"",data:null,onLoad:null,dialogOptions:null};var popupOptions=jQuery.extend({},defaults,newOptions);if(popupOptions.url!="")
jQuery.post(popupOptions.url,popupOptions.data,function(data)
{openDialog(data.data,popupOptions.dialogOptions);if(typeof popupOptions.onLoad=="function")
popupOptions.onLoad();},"json");return false;};jQuery.popupForm=function(newOptions)
{var defaults={beforeSubmit:null,success:null,url:"",dataType:"json",data:null,formData:null,form:"FreazyForm",dialogOptions:null};var popupFormOptions=jQuery.extend({},defaults,newOptions);if(popupFormOptions.url)
jQuery.post(popupFormOptions.url,popupFormOptions.data,function(data)
{openDialog(data.data,popupFormOptions.dialogOptions);var formName=popupFormOptions.form;if(!jQuery("#"+formName).length)
formName=jQuery("form:first",jQuery("#popup")).attr("id");var options={target:"#popup",dataType:"json",type:"POST",iframe:true,width:"auto",forceSync:false,error:function(xhr,desc,exceptionobj)
{return false;},beforeSubmit:function(formData,form,options)
{options.url=options.url+"/ajax/true/json/true";if(typeof popupFormOptions.beforeSubmit=="function")
return popupFormOptions.beforeSubmit(formData,form,options);if($(form).hasClass("validate"))
return $(form).valid();return true;},success:function(response,status)
{jQuery("#popup").dialog("close");jQuery("#popup").remove();if(typeof popupFormOptions.success=="function")
{return popupFormOptions.success(response,status);}
return false;}};jQuery("#"+formName).ajaxForm(options);return false;},"json");return false;};
var httpData=$.httpData||function(xhr,type,s){var ct=xhr.getResponseHeader("content-type")||"",xml=type==="xml"||!type&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.nodeName==="parsererror"){$.error("parsererror");}
if(s&&s.dataFilter){data=s.dataFilter(data,type);}
if(typeof data==="string"){if(type==="json"||!type&&ct.indexOf("json")>=0){data=$.parseJSON(data);}else if(type==="script"||!type&&ct.indexOf("javascript")>=0){$.globalEval(data);}}
return data;};;$(function($)
{$.ajaxSetup({dataType:"json",jsonp:false,jsonpCallback:"standardJsonpCallback",crossDomain:false});$(document).ajaxComplete(function(event,xhr,options)
{var response=httpData(xhr,options.dataType);if(options.dataType=="json")
{if(response.redirect)
if(response.redirect!="")
window.location.href=response.redirect;if(response.message)
$(".module:first").prepend(response.message);if(response.title)
document.title=response.title;}});$(".validate").livequery(function()
{if(!$.isFunction($.fn.validate))
$.lazy({src:"/freazy/plugins/jquery/validate/jquery.validate.js",name:"validate"});$(this).validate();});$(".video").livequery(function()
{flowplayer(this,"/freazy/plugins/jquery/flowplayer/flowplayer-3.1.5.swf",{});});$(".media").livequery(function()
{if(!$.isFunction($.fn.media))
$.lazy({src:"/freazy/plugins/jquery/media/jquery.media.js",name:"media"});$(this).media({scale:"exactfit"});});$(".datepicker, .dateiso").livequery(function()
{if($.isFunction($.fn.datepicker))
{$(this).datepicker({dateFormat:'yy-mm-dd',yearRange:'1900:2020',changeMonth:true,changeYear:true,beforeShow:function()
{$('#ui-datepicker-div').maxZIndex();}});}});jQuery.expr[':'].parents=function(a,i,m){return jQuery(a).parents(m[3]).length<1;};$("a[rel*=popup], .popup").not(".freazyPageContent a").livequery(function()
{$(this).fancybox({overlayShow:false,hideOnContentClick:true,easingIn:"easeOutBack",easingOut:"easeInBack",zoomSpeedChange:1000,zoomSpeedIn:1000,zoomSpeedOut:500,imageScale:true,frameWidth:500,frameHeight:500});return false;});$("a[rel*=zoom], .zoom").livequery(function()
{$(this).jqzoom({zoomWidth:500,zoomHeight:500,xOffset:10,yOffset:0,position:"bottom",preloadPosition:"center",title:false,fadeInSpeed:2000,fadeOutSpeed:2000,showEffect:"fadein",hideEffect:"fadeout"});return false;});$(".tabs").livequery(function()
{$(this).tabs({cache:true,fx:{opacity:"toggle"},spinner:"Loading"});});$(".buttonTab").livequery("click",function()
{var nTab=$(this).attr("id").split('_')[1];$(".tabs").tabs('select',Number(nTab));return false;});$("body").delegate(".freazyToggleDiv","click",function()
{$.log($(this));$(this).toggleClass("freazyMinus");$(this).next(".freazyToggleDetails").slideToggle("fast");return false;});$("body").delegate(".freazyRedirect","click",function()
{var id=new String($(this).attr("id"));window.location.href="/"+id.replace(/[_]/g,"/");return false;});$(".warningMessage, .infoMessage, .errorMessage, .successMessage").livequery(function()
{if($(this).hasClass("flash"))
$(this).fadeIn(2000);$(this).click(function()
{$(this).fadeOut(1000,function()
{$(this).remove();});});});$(".print").livequery("click",function()
{window.print();return false;});$(".toggle").livequery("click",function()
{$(this).nextAll("div:first").toggle("slow");});$("form input, form select").livequery("keypress",function(e)
{if($(this).parents("form").find("button[type=submit].default, input[type=submit].default").length<=0)
return true;if((e.which&&e.which==13)||(e.keyCode&&e.keyCode==13))
{$(this).parents("form").find("button[type=submit].default, input[type=submit].default").click();return false;}
else
return true;});$(".popupform").livequery("click",function()
{var href=$(this).attr("href");var id=new String($(this).attr("id"));var options={url:href,data:{"id":id}};$.popupForm(options);return false;});});
$(function($)
{$("#widget__language li").live("click",function()
{var lang=new String($(this).attr("id"));lang=lang.replace("language__language","");$.post("/language/setlanguage/lang/"+lang,{},function()
{$("#language__language"+lang).fadeOut().fadeIn();window.location.replace(window.location.href);},"json");return false;});});
$(function($)
{$(".megamenu").megamenu();});;$(function($)
{var contentBefore=null;$('.freazyUpdatable').livequery('click',function()
{if(!($(this).is("select")))
{$(this).attr("contentEditable",true);contentBefore=$(this).html();$.log("contenteditable");}
else
{contentBefore=$(this).find("option:selected").html();}});$(".freazyUpdatable").live("keyup",function()
{$("[_moz_dirty]").remove();});$('.freazyUpdatable').livequery('blur',function()
{if(contentBefore!=$(this).html())
{var aSplit=$(this).attr("id").split('_');var name=aSplit[0];var id=aSplit[1];var attribute=aSplit[2];var langid=aSplit[3];var value=null;if($(this).is("select"))
{value=$(this).find("option:selected").attr("value");}
else
{value=$(this).html();}
$.post("/editable/update/modelname/"+name+"/id/"+id+"/attr/"+attribute+"/langid/"+langid,{"value":value},function(data)
{$(this).html(data.data);},"json");}
if(!($(this).is("select")))
{$(this).removeAttr("contentEditable");}});$(".freazyDeletable").livequery("click",function(event)
{var name=$(this).attr("id").split('_')[0];var id=$(this).attr("id").split('_')[1];var langid=$(this).attr("id").split('_')[2];var element=$(this).closest(".freazyDeleteMarker"+id);$.post("/editable/delete/modelname/"+name+"/id/"+id+"/languageid/"+langid,{},function(data)
{if(data.type=="success")
{element.slideUp(1000,function(){$(this).remove();});}},"json");});});
