var flashvars = false;
var params = {
	menu: "false",
	wmode: "transparent"
};
var attributes = false;

swfobject.embedSWF("/img_new/backgrounds/logo.swf", "logo_flash", "270", "63", "9.0.0", "", flashvars, params, attributes);
//swfobject.embedSWF("/img_new/backgrounds/oyunlife.swf", "oyunlife_advert_flash", "200", "100", "9.0.0", "", flashvars, params, attributes);
swfobject.embedSWF("", "oyunlife_advert_flash", "200", "100", "9.0.0", "", flashvars, params, attributes);
/*-------------------------------------------------------------------------
=CAROUSELS
-------------------------------------------------------------------------*/		
var scroller = new Class({
	initialize: function(elements,name,div){
			this.el=elements;
			this.el.each(function(el,i){el.id=name+i});
			this.mel = $$('#weekly_games ol li a');
			this.name = name;
			this.current =0;
			this.timer2 = '';
			if(div == 'unotices'){
				var x=0;
				var y=0;
			}else{
				var x=-30;
				var y=0;
			}
			this.scroll = new Fx.Scroll(div, {
				wait: false,
				offset: {'x': x,'y':y},
				wheelStops:false,
				duration: 500,
				transition: Fx.Transitions.Quad.easeInOut
			});
			
	},
	next: function(){
		if($('notices_prev')){
			var a=1;
		}else{
			var a=5;
		}
		
		if(this.current<(this.el.length-a)) {
			this.current ++;
			this.scroll.toElement(this.name+this.current);
		}
		else {
			this.current = 0;
			this.scroll.toElement(this.name+this.current);
		}
		
	},
	
	prev: function(){
		if($('notices_prev')){
			var a=1;
		}else{
			var a=5;
		}
		if(this.current>0) {
			this.current --;
			this.scroll.toElement(this.name+this.current);
		}
		else {
			this.current = this.el.length-a;
			this.scroll.toElement(this.name+this.current);
		}
	},
	
	run: function(){
		
		if(this.current<(this.el.length-1)) {
			this.current ++;
			this.scroll.toElement(this.name+this.current);
		}
		else {
			this.current = 0;
			this.scroll.toElement(this.name+this.current);
		}
		
	},


	timer: function(a,b){
	$clear(this.timers);
	this.mel[this.current].getElement('img').className = ''; 
	this.mel[this.current].style.backgroundPosition='0px 0px';
	
	if(a!=undefined)
		this.current=(a==0?this.mel.length-1:a-1);
	
	$o.wgame.run();
	this.mel[this.current].getElement('img').className = 'active_game';
	this.mel[this.current].style.backgroundPosition='0px -32px';
	$('play_now').getChildren()[0].href = this.mel[this.current].title;
	if(b!=undefined)
		this.timers=setTimeout('$o.wgame.timer(undefined,1)',2000);
	},


	cthumb: function(){
		this.mel.each(function(el,num){
			eval("el.addEvent('mouseover',function(){$o.wgame.timer("+num +");})");
			eval("el.addEvent('mouseout',function() {$o.wgame.timer($o.wgame.current,1);})");
		})
	},


	
	cbutton: function(){
		if($('notices_prev')){
			$('notices_next').addEvent('mouseover',function(){$o.lgame.next()});
			$('notices_prev').addEvent('mouseover',function(){$o.lgame.prev()});
		}else{
			$('next').addEvent('mouseover',function(){$clear($o.lgame.timer2);$o.lgame.timer2 = setInterval('$o.lgame.next()','400')});
			$('next').addEvent('mouseout',function(){$clear($o.lgame.timer2);$o.lgame.timer2 = setInterval('$o.lgame.next()','2000')});
			$('prev').addEvent('mouseover',function(){$clear($o.lgame.timer2);$o.lgame.timer2 = setInterval('$o.lgame.prev()','400')});
			$('prev').addEvent('mouseout',function(){$clear($o.lgame.timer2);$o.lgame.timer2 = setInterval('$o.lgame.next()','2000')});
		}
	}
	
})

/*-------------------------------------------------------------------------
=TABS
-------------------------------------------------------------------------*/	
var tab = new Class({
	initialize: function(tname,cname,type){
		this.current = 0;
		this.type = type;
		this.el=$$('#'+tname+' li a');
		this.con=$$('#'+cname);
	},
	
	change: function(num){
		if(this.type == 1)
			this.el[this.current].className = '';
		this.con[this.current].style.display = 'none';
		this.current = num;
		if(this.type == 1)
			this.el[this.current].className  = 'active_tab'
		this.con[this.current].style.display = 'block';
		if($o.user != undefined) {
			$o.user.settype(num);
		}
		
	},
	
	ctab: function(){
		this.el.each(function(el,num){
			el.href = 'javascript:;'
			eval("el.addEvent('click',function(){this.change("+num+")}.bind(this))");
		}.bind(this))
	}
	
})

/* yorumlar */
var url = "";
var ajax = new Request({method: 'get',url:url,onSuccess:function(responseText,responseXML){$(ajax.options.update).innerHTML=responseText}});
ajax.options.update='commentcon';
function createlist(name) {
	var element=$$('#'+name+' a');
	$each(element,function(el,index){
			el.href = 'javascript:;';
			el.alt  =  el.id.split('-')[0].replace('sayfa','');
			el.id   = 'pg'+el.id.split('-')[1];
			el.addEvent('click',function(){
				ajax.options.url=url;
				ajax.send('num='+this.id.replace('pg','')+'&id='+this.alt);
				this.className = 'current_page';
				$(current).className='';
				current = this.id;
			});
	});
}


//user

var user = new Class({
	initialize:function(){
		this.atype = new Array('incoming','outcoming','archive');
		this.type = this.atype[0];
		this.url = 'user.php';
		this.istat = false;
		this.ajax = new Ajax(this.url, {method: 'get',update:'',onComplete:function(){}});
	},
	
	loader:function(){
		$(this.type+'_messages_read').innerHTML = '<img src="/img_new/content/loader.gif" /c>';
	},
	
	get_list:function() {
		this.ajax.$events['onComplete'] = [];
		this.ajax.url = this.url+'?mtype='+this.type+'&event=getlist';
		this.ajax.options.update = this.type+'_messages_con';
		this.ajax.request();
	},
	
	settype:function(num){
		this.type = this.atype[num];
		this.get_list();
	},
	
	del:function(id){
		var ids='';
		if(id == undefined){
			$(this.type+'_messages_read').setHTML('Mesaj se?ili de?il');
			return false;
		}
		if(id.length == 0){
			return false;
		}else if(id.length != undefined) {
			for(a=0;a<id.length;a++){
					ids =  ids+(a != 0?'-':'')+id[a];
			}	
		}else{
			ids=id;
		}
		this.loader();
		this.ajax.$events['onComplete'] = [function(){this.get_list()}.bind(this)];
		this.ajax.url = this.url+'?mtype='+this.type+'&event=delete&id='+ids;
		this.ajax.options.update = this.type+'_messages_read';
		this.ajax.request();
		this.mid = undefined;
	},
	
	archive:function(id){
		var ids = '';
		if(id == undefined){
			$(this.type+'_messages_read').setHTML('Mesaj se?ili de?il');
			return false;
		}
		if(id.length == 0){
			return false;
		}else if(id.length != undefined) {
			for(a=0;a<id.length;a++){
					ids =  ids+(a != 0?'-':'')+id[a];
			}	
		}else{
			ids=id;
		}
		this.loader();
		this.ajax.$events['onComplete'] = [function(){this.get_list()}.bind(this)];
		this.ajax.url = this.url+'?mtype='+this.type+'&event=archive&id='+ids;
		this.ajax.options.update = this.type+'_messages_read';
		this.ajax.request();
		this.mid = undefined;
	},
	
	read:function(id) {
		this.loader();
		this.mid = id;
		this.ajax.url = this.url+'?mtype='+this.type+'&event=read'+'&id='+id;
		this.ajax.options.update = this.type+'_messages_read';
		this.ajax.request();
	},
	
	selectAll:function() {
		if(this.istat){
			this.istat = false;
			$$('#'+this.type+'_messages_con .item').each(function(el){
					el.checked = false;
			});
		}else{
			this.istat = true;
			$$('#'+this.type+'_messages_con .item').each(function(el){
					el.checked = true;
			});
		}
	},
	
	getIds:function(){
		var a=0;
		var array=[];
		$$('#'+this.type+'_messages_con .item').each(function(el){
				if(el.checked){
					array[a]=el.value;
					a++;
				}
		}.bind(array));
		return array;
	},
	
	makeform: function(id) {
		this.loader();
		this.mid = id;
		this.ajax.url = this.url+'?mtype='+this.type+'&event=getmsginf'+'&id='+id;
		this.ajax.options.update = this.type+'_messages_read';
		this.ajax.request();
	},
	
	send: function(id) {
		var el = $(this.type+'_messages_read');
		el = el.getElements('.input')
		var data = '';
		for(a=0;a<el.length;a++) {
			data = data+(a==0?'':'&')+el[a].id+'='+el[a].value;
		}
		this.loader();
		this.ajax.url = this.url+'?mtype='+this.type+'&event=send&id='+id+'&'+data;
		this.ajax.options.update = this.type+'_messages_read';
		this.ajax.request();
	}
	
});
/*-------------------------------------------------------------------------
=INITIALIZE SCRIPTS
-------------------------------------------------------------------------*/	
var $o={};
window.addEvent('domready', function() {
	if($('games_carousel')) {
		$o.lgame = new scroller($$('#games_carousel ul li'),'lgame','games_carousel');
		$o.lgame.cbutton();
		$o.lgame.timer2 = setInterval('$o.lgame.next()','2000')
	}
	
	if($('user_notices')) {
		$o.lgame = new scroller($$('#unotices ul li'),'lgame','unotices');
		$o.lgame.cbutton();
	}
	
	if($('weekly_games_carousel_container')) {
		$o.wgame = new scroller($$('#weekly_games_carousel_container .content'),'wgame','weekly_games_carousel');
		$o.wgame.cthumb();
		$o.wgame.timer(0,1);

	}
	if($('tcontent')){
		$o.tab1 = new tab('tabs','tcontent ul',1);
		$o.tab1.ctab();
	}
	
	if($('tab2con2')) {
		$o.tab2 = new tab('tabs2','tab2con2 ul',1);
		$o.tab2.ctab();
	}else if($('tabs2')){
		$o.tab2 = new tab('tabs2','tab2con .tb',0);
		$o.tab2.ctab();
	}
	
	if($('np_tabs')){
		$o.tab3 = new tab('np_tabs','contabs3 ul',1);
		$o.tab3.ctab();
	}
	
	if($('tab3')){
		$o.tab3 = new tab('tab3','tab3con .tb',0);
		$o.tab3.ctab();
	}
	
	if($('game_tabs')){
		$o.tab3 = new tab('game_tabs','tabs4 .tb',0);
		$o.tab3.ctab();
	}

	if($('gp_pagination')) {
		current='pg1';
		ajax.options.update='gp_comments';
		url='/oyun_yorumlar.asp';
		createlist('gp_pagination');
	}
	
	if($('user_functions_content')) {
		$o.user = new user();
	}
	
});

function formkontrol(theForm)
{
   if (theForm.text.value == "")
   {
      alert("L?tfen Arama Alan?n? Bo? B?rakmay?n?z");
      return false
   }
   else if (theForm.tip.value == "")
   {
      alert("L?tfen Arama T?r? Alan?n? Bo? B?rakmay?n?z");
      return false
	  }     
	else if (theForm.text.value == "Kelime girin...")
   {
      alert("L?tfen Arama Alan?n? Bo? B?rakmay?n?z");
      return false
	  }  
    return true
}


function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function form_validator(theForm)
{

	if(theForm.kadi.value == "" || theForm.sifre.value == "") {
		 alert("L?tfen Kullan?c? Ad? ve ?ifrenizi giriniz...");
		 return(false);
	}

	return (true);
}



function dogrula()
{
return confirm("Bu i?lemi yapmak i?in ?ye olman?z gerekmektedir!!!! ?ye olarak sitemizin bir?ok ?zelli?inden faydalanmak ister misiniz?");
}



window.addEvent('domready', function() {
 
	/**
	 * That CSS selector will find all <a> elements with the
	 * class boxed
	 *
	 * The example loads the options from the rel attribute
	 */
	SqueezeBox.assign($$('a[rel=boxed]'));
	SqueezeBox.assign($$('a.boxed'), {
		parse: 'rel'
	});
 
});

function buyut(){
var x = document.getElementById('sbox-window');
x.style.width="650px";
x.style.height="600px";

var t = document.getElementsByTagName('iframe');
var f = t.length;
while(f--){
if(t[f].width == 500 || t[f].width == 377){
t[f].width="650px";
t[f].height="600px";
}
}

x.style.top = x.offsetTop-130+"px";
x.style.left = x.offsetLeft-137+"px";
};



