/*if(!Cookie.read('full')&&Cookie.write('full','true')){
	var w=screen.availWidth,h=screen.availHeight,nh=Math.round(w*(4/3.2)),nw=Math.round(h*(4/3.2)),w=nh>h?nw:((nw>w&&(h=nh))?w:w);
	$try(function(c){
		if(document.all)window.resizeTo(w,h);window.outerHeight=h;window.outerWidth=w;
		window.moveTo(window.screenY=window.screenTop=0,window.screenX=window.screenLeft=Math.round((screen.availWidth-w)/2));
	});
}*/

document.menu=$('menu').set({opacity:0,tween:{property:'opacity',duration:200}});
document.addEvents({
	contextmenu:function(e){return $type(e.target.value)=='string'},
	click:function(e){
		var el=document.menu,trg=$(e.target),tag=trg.get('tag'),embed=$('embed');
		if(el.style.opacity>0)return el.set('opacity',0);
		if(tag!='a'&&tag!='textarea'&&tag!='input'&&!trg.getParent('a')&&!(embed&&embed.hasChild(trg))){
			var win=window.getSize(),siz=el.getSize();
			el.setStyles({
				left:(e.page.x+siz.x)>win.x?win.x-siz.x:e.page.x-20,
				top:(e.page.y+siz.y)>win.y?win.y-siz.y:e.page.y-20
			}).tween('opacity',0.7);
		}
	}
});
if($('cont').get('tag')=='img')new ScaleView();
$$('body').setStyle('cursor','pointer');

$$('form').each(function(form){
	var els=form.getElements('input[type="text"],textarea').addEvents({
		focus:function(){if(this.removeClass('unvalid').value==this.title)this.value=''},
		blur:function(){if(!this.value)this.value=this.title}
	});
	form.addEvent('submit',function(e,fail){
		els.each(function(){el.removeClass('unvalid').value||el.value!=el.title||(fail=el.addClass('unvalid'))});
		return !fail;
	});
});