var page={
statup:[],
yorumid:"",
itemid:"",
musicCookieStr:"music",

addStartup:function(str){
	this.statup.extend([str]);
},
runSturtup:function(){
	this.statup.each(function(item){ eval(item);});
	
},
changeBigImg:function(){
	if( $("bigImg")!=null ) {
			$("bigImg").set("src","/images/oylum_beldesi.jpg");
	}

},
	
sendYorum:function(type,itemid,replayid){
	if ( $('frm'+ itemid+ replayid).elements["mesaj"].value.length<=500 ){
		
		$(itemid+"d").set("load",{method:"post",url:"yorum.php",data:"mesaj="+$('frm'+ itemid+ replayid).elements["mesaj"].value+"&type="+type + "&itemid="+itemid + "&replayid="+ replayid });
		
		
	$(itemid+"d").load();
	
		
	} else {
		alert("Mesajınız en fazla 500 karakter olmalıdır!..");
		
	}
return false;	
	
},
makeYorum:function(elm,type,itemid,replayid,userName){
var elmm=$(elm).getParent();
	if (!$(itemid+"d")) {
		var div=new Element("div",{"id":itemid+"d",styles:{ "display":"block","padding":"5px 5px;" } } );
		div.inject(elmm, 'after');
		div.set("html",'\
<form id="frm'+ itemid + replayid +'" name="frm'+ elm+ replayid +'" method="post" action="" style="zoom:0.1">\
<table width="100%" border="0" cellspacing="0" cellpadding="0">\
  <tr>\
    <td width="16%">Kullanıcı</td>\
    <td width="84%">'+ userName  +'</td>\
    </tr>\
  <tr>\
    <td>Mesaj</td>\
    <td><label>\
      <textarea name="mesaj" cols="50" rows="4" id="mesaj"></textarea>\
    </label>    </td>\
    </tr>\
  <tr>\
    <td>&nbsp;</td>\
    <td><a href="#" onclick="page.sendYorum('+type+','+ itemid +','+ replayid +');">Kaydet</a></td>\
  </tr>\
</table>\
</form>\
\
');

this.yorumid='frm'+ itemid + replayid ;
this.itemid=itemid;

this.makeZoom.bind(this).delay(100);


	} else {
		this.makeNegativeZoom.bind(this).delay(100);
	}

},
makeZoom:function(){
	if ($(this.yorumid)!=null) {
		
		var zm=parseFloat($(this.yorumid).getStyle("zoom"));
		if (zm<1){
			$(this.yorumid).style.zoom=zm+0.1;
			if ( (zm+0.1)<1 )
			this.makeZoom.bind(this).delay(20);
		}
	}
	
},
makeNegativeZoom:function(){
		if ($(this.yorumid)!=null) {
				
		var zm=parseFloat($(this.yorumid).getStyle("zoom"));
			if (zm>0){
				$(this.yorumid).style.zoom=zm-0.1;
				if ( (zm-0.1)>0 )
				this.makeNegativeZoom.bind(this).delay(20);
				else
				$(this.itemid+"d").dispose();
			}
		}
		
}




} // page son







window.addEvent("domready",function(){
page.runSturtup();
});




var menu={
opened:[],
menuCookieStr:"e_pro_menu",
AcKapa:function(elm){
 var elm=$(elm);
 
 var sonraki=elm.getNext();
	if (sonraki.get('tag')=="div") {
		if (sonraki.style.display=='block'){
			sonraki.set("styles",{ "display":"none"});
			elm.getFirst().setAttribute("src","images/menu_left.gif");
			this.menuCookie(sonraki.id,0);
		} else {
			sonraki.set("styles",{ "display":"block"});	
			elm.getFirst().setAttribute("src","images/menu_bottom.gif");
			this.menuCookie(sonraki.id,1);
		}
	}
},
menuCookie:function(id,state){
var elm=(Cookie.read(this.menuCookieStr)==null)?"":Cookie.read(this.menuCookieStr);

var str="";
if(state==0) {
	
	var items=elm.split(",");
	
	for(i=0;i<items.length;i++){
		if(id!=items[i]){
			str+=items[i]+","
		}
		
	}


} else if(state==1){
	
	var items=elm.split(",");
	var acikVar=false;
		for(i=0;i<items.length;i++){
				if(items[i]!="")
				if(id==items[i]){
					acikVar=true;
					
				}else {
					str+=items[i]+",";
				}
				
		}
		if (!acikVar){
			str+=id+",";
		}

}

str=(str!="")?str.substr(0,(str.length-1)):"";
Cookie.write(this.menuCookieStr,str,{duration:365});

},
isInCookie:function(str){
	for(i=0;i<this.opened.length;i++)
	if(this.opened[i]==str)
	return true;
return false;
},
createMenu:function(){
	
this.opened.extend((Cookie.read(this.menuCookieStr))?Cookie.read(this.menuCookieStr).split(","):[]);

$(document.body).getElements("div.sub").each(function(e,i){
						    
								if (e.id.indexOf('_',1)<=0 || this.isInCookie(e.id) ) e.set( "styles",{"display":"block" } ); 
											   
											   }.bind(this));

$$("img.bullet").each( function(item,index ){
					
	item.getParent().addEvent("click",function(e){ 
		
			if (e.target.getFirst().get("tag")=="img") { this.AcKapa(e.target);  }
			e.stop();
	}.bind(this));
 }.bind(this) );





}




	

} //class sonu


