var logi=0;function LOG(a){$('<div />').html(logi+' :: '+a).appendTo('body');logi++}function LOGO(obj){var a='';for(var i in obj){try{a+='<br/><b>'+i+"</b> = "+obj[i]+"\n"}catch(m){a+='<br/><b>'+i+"</b> -- not allowed -- \n"}}LOG(a)}gpadmin={uploadFile:function(el){el.parentNode.className='active';var t=el.value.toString();while(pos=t.search('\\\\')){if(pos==-1){break}t=t.substr(pos+1)}$('<div><a href="javascript:void(0)" onclick="gpadmin.rmFile(this)" >Remove</a><div class="name">'+t+'</div></div>').appendTo(el.parentNode);if($('#gp_upload_list .active').size()<5){gpadmin.addFile()}},addFile:function(){$('#gp_upload_field').clone().attr('id','').attr('class','upload_ready').appendTo('#gp_upload_list')},rmFile:function(el){$(el).closest('.active').remove();if($('#gp_upload_list .upload_ready').size()<1){gpadmin.addFile()}}};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 false}function eraseCookie(name){createCookie(name,"",-1)}$(function(){var cl='';if(IE6){cl='IE6CLASS'}else if(IE7){cl='IE7CLASS'}else{cl='STCLASS'}$('body').addClass(cl);var a=$('#gpadminpanel');if(a.size()>0){a.show().css({'display':'block','margin':'0','top':'0'});var b=$('body').prepend(a);if(IE6){}else{if(IE7){a.children().css({'position':'relative'})}a.css({'width':'100%','position':'fixed'});b.css({'marginTop':a.attr('offsetHeight')+'px'})}}eraseCookie('cookie_cmd');window.setTimeout(function(){cInit()},100);function cInit(){var tmp=$('#edit_list');$('a.ExtraEditLink').each(function(a,b){var cl='inline-block';if(!IE6){cl='block'}tmp.append($('<li>').append($(b).show().hover(function(){c=$(b).closest('div[class=editable_area]');var id=c.attr('id');var topleft=c.offset();var w=c.width();var h=c.height();var f=$('#show_'+id);if(f.length==0){f=$('<div id="show_'+id+'" class="edit_area_overlay"></div>').appendTo('body')}f.css({'top':topleft.top,'left':topleft.left}).height(h-2).width(w-2).show()},function(){var id=$(b).closest('div[class=editable_area]').attr('id');$('#show_'+id).hide()}).clone(true).css({'display':cl}).removeAttr('class').text(b.title.replace(/_/g,' '))))});if(readCookie('hide_edit_area')){ShowHideLinks(false)}$('div[class=editable_area]').hover(function(){$(this).find('.edit_area').show()},function(){$(this).find('.edit_area').hide()}).each(function(a,b){var c=$(b);if(c.height()==0){var origin=c.offset();var maxy=0;var y=0;c.children().each(function(d,e){e=$(e);y=e.offset().top+e.height();if(y>maxy){maxy=y}});c.height(y-origin.top)}});function toggle_edit_links(){var c='hide_edit_area';if(readCookie(c)){eraseCookie(c);ShowHideLinks(true)}else{createCookie(c,c,1000);ShowHideLinks(false)}}function ShowHideLinks(a){if(a){$('.ExtraEditLink').show().removeClass('edit_area')}else{$('.ExtraEditLink').hide().addClass('edit_area')}}$().ajaxError(function(event,XMLHttpRequest,ajaxOptions,thrownError){alert('Error fetching response. Reload this page to continue.')});$('input[class=gpajax]').live('click',function(e){loading();var frm=$(this).closest('form');var a=frm.serialize();a+='&gpx=true&jsoncallback=?';$.post(frm.attr('action'),a,ajaxResponse,'json');return false});LiveJQ();if(IE6||IE7){var zIndexNumber=9000;$('.expand_child').each(function(){$(this).css('zIndex',zIndexNumber);zIndexNumber-=10})}$('a[name]').live('click',function(e){var a=$(this).attr('name');var b=$(this).attr('rel');switch(a){case'ajax_box':$.fn.colorbox({opacity:0.75,href:jPrep(this.href),open:true});break;case'toggle_edit_links':toggle_edit_links();break;case'inline_box':var c=$(b).find('form').get(0);if(c){$(this).find('input').each(function(i,j){if(c[j.name]){c[j.name].value=j.value}})}$.fn.colorbox({opacity:0.75,inline:true,href:b,open:true});break;case'gpajax':jGoTo(this.href);break;case'creq':cGoTo(this.search);break;case'close_message':this.parentNode.style.display='none';break;case'gallery':var c='a[rel='+b+']';$(c).colorbox({opacity:0.75,maxWidth:"90%",maxHeight:"90%",resize:true,minWidth:"300",minHeight:"300"});$(this).trigger('click');break;default:return true}e.preventDefault();return false})}function ajaxResponse(data){for(i in data){switch(data[i].DO){case'replace':$(data[i].SELECTOR).replaceWith(data[i].CONTENT);break;case'eval':eval(data[i].CONTENT);break;default:alert('nothing for: '+data[i].DO);break}}$('#loading').fadeOut();try{$.fn.colorbox.close()}catch(er){}LiveJQ()}function LiveJQ(){$('.expand_child').unbind('mouseenter.live').unbind('mouseleave.live').bind('mouseenter.live',function(){$(this).addClass('expand');if($(this).hasClass('simple_top')){$(this).addClass('simple_top_hover')}}).bind('mouseleave.live',function(){$(this).removeClass('expand').removeClass('simple_top_hover')})}function loading(){$('body').prepend($('#loading').fadeIn('slow'))}function jGoTo(a){loading();a=jPrep(a)+'&jsoncallback=?';$.getJSON(a,ajaxResponse)}function jPrep(a){a+=(a.indexOf('?')==-1)?'?':'&';return a+'gpx=true'}function cGoTo(a){createCookie('cookie_cmd',encodeURIComponent(a),1);var b=window.location.href;window.location=b}});
