var slider=function(){
	var array=[]; var speed=10; var timer=10;
	return{
		init:function(t,c){
			var s,ds,l,i,y;
			s=document.getElementById(t); ds=s.getElementsByTagName('div'); l=ds.length; i=y=0;
			for(i=0;i<l;i++){
				var d,did; d=ds[i]; did=d.id;
				if(did.indexOf("slidehaberbaslik")!=-1){
					y++; d.onclick=new Function("slider.process(this)");
				}else if(did.indexOf("slidehabericerik")!=-1){
					array.push(did.replace('-slidehabericerik','')); d.maxh=d.offsetHeight;
					if(c!=y){d.style.height='0px'; d.style.display='none'}
					else{d.style.display='block'}
				} 
			}
		},
		process:function(d){
			var cl,i; cl=array.length; i=0;
			for(i;i<cl;i++){
				var s,h,c,cd;
				s=array[i]; h=document.getElementById(s+'-slidehaberbaslik');
				c=s+'-slidehabericerik'; cd=document.getElementById(c); clearInterval(cd.timer);
				if(h==d&&cd.style.display=='none'){
					cd.style.display='block'; this.islide(c,1);
				}else if(cd.style.display=='block'){this.islide(c,-1)}
			}
		},
		islide:function(i,d){var c,m; c=document.getElementById(i); m=c.maxh; c.direction=d; c.timer=setInterval("slider.slide('"+i +"')",timer)},
		slide:function(i){
			var c,m,h,dist; c=document.getElementById(i); m=c.maxh; h=c.offsetHeight;
			dist=(c.direction==1)?Math.round((m-h)/speed):Math.round(h/speed);
			if(dist<=1){dist=1}
			c.style.height=h+(dist*c.direction)+'px'; c.style.opacity=h/c.maxh; c.style.filter='alpha(opacity='+(h*100/c.maxh)+')';
			if(h<2&&c.direction!=1){
				c.style.display='none'; clearInterval(c.timer);
			}else if(h>(m-2)&&c.direction==1){clearInterval(c.timer)}
		}
};}();
window.onload=function(){

	var page = document.getElementById('pagename');
	if (page=='haberler'){
		slider.init('slider',1);
	} else if (page=='_default'){
		var menu=new menu.dd("menu"); menu.init("menu","menuhover");
	}
}

function ebulten(id){
  obj = document.getElementById(id);
  var xmlhttp;
  if (window.XMLHttpRequest){
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else if (window.ActiveXObject){
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    //alert("Your browser does not support XMLHTTP!");
  }

  xmlhttp.onreadystatechange=function(){
    if(xmlhttp.readyState==4){
		document.getElementById('ebulten_mesg').style.display = 'block';
		var classname = 'allgood2';
		var text = xmlhttp.responseText;

		if (text.substr(0,4)=='ERR:'){
			classname = 'error';
			text = text.substr(4, text.length-4);
		}
		document.getElementById("ebulten_mesg").setAttribute("class", classname);
		document.getElementById('ebulten_mesg').innerHTML = text;
		document.getElementById('ebulten_info').style.display = 'none';
    }
  }

  var val = obj.value;
  xmlhttp.open("GET","/_default?action=ebulten&email="+val,true);
  xmlhttp.send(null);
}
