/*
	Powered by Mootools
	Developed by Enes Tanrıöver
	@email enes@workattack.com
*/
window.addEvent('domready', function() {

menus = $$('#hbottom a');

menus.each(function(element) {
	$(element).addEvent('click', function(e){
		e.stop();
		var target=element.getLeft();
		target=target-26;
	
		var hbase = $('hbase');
		var myFx = new Fx.Tween(hbase);
		myFx.start('left', target);
	});
	$(element).addEvent('mouseup', function(e){
		var hbase = $('hbase');
		var targetw=element.getWidth();
		var myFx = new Fx.Tween(hbase);
		myFx.start('width', targetw);
		setTimeout("redirect('"+e.target.innerHTML+"')",700);
	});
});
	
var toggler = $$('#leftmenus div.toggler','#leftmenus div.element');
for(i=0;i<(toggler.length/2);i++){
	var togg=toggler[i];
	var element=toggler[parseInt(i+(toggler.length/2))];

	$(togg).addEvent('click', function(e){
		var ind=e.target.id.substring(2.3);
		var myelement=$('a-'+ind);
		
		var myLoc=window.location.href;
		myLoc=myLoc.split("/");
		myLoc=myLoc[myLoc.length-1];
		if(myLoc.indexOf("?")!=-1){
			myLoc=myLoc.split("?");
			if(myLoc[0]=="product.php"){
				var qs=myLoc[1];
				var sonuc=qs.substring(2,qs.indexOf("&id="));
				if(sonuc=="ev"){
					myLoc="ev_mobilyalari.php";
				}
			}else{
				myLoc=myLoc[0];
			}
		}
		
		if(myLoc!="ev_mobilyalari.php"){
			myLoc="ofis_mobilyalari.php";
		}
		window.location.href=myLoc+"?c="+ind;
		//setTimeout("mop("+cachem+","+cacheid+")",500);
	});
}
});
var cachem,cacheid,first;
function mop(m,id){
	cachem=m;
	cacheid=id;
	var menu=$("a-"+m);
	var link=$("li-"+id);
	var ok=$("ok-left");
	
	/*var myHorizontalSlide = new Fx.Slide(menu, {mode: 'vertical'});
	myHorizontalSlide.slideIn();*/
	menu.style.display="inline";
	
	var toph=link.getTop();
	var topw=link.getLeft();


	var myFx = new Fx.Tween(ok);
	myFx.set('display', 'inline');
	myFx.set('position', 'absolute');
	myFx.set('left', (topw-10));
	myFx.set('top', ok.getTop());
	toph=(first==undefined)?parseInt(toph+4):parseInt(toph+4);
	myFx.start('top', toph);
	first="no";
}

function redirect(mn){
	if(mn=="EV MOBİLYALARI"){
		window.location.href="ev_mobilyalari.php";
	}else if(mn=="OFİS MOBİLYALARI"){
		window.location.href="ofis_mobilyalari.php";
	}else if(mn=="KAMPANYALAR"){
		window.location.href="index.php";
	}else if(mn=="İLETİŞİM"){
		window.location.href="iletisim.php";
	}else if(mn=="SİPARİŞLERİM"){
		window.location.href="siparislerim.php";
	}
}
function initmenu(num){
	menus = $$('#hbottom a');
	
	var sttarget=menus[num].getLeft();
	sttarget=sttarget-26;
	var fxst = new Fx.Tween($('hbase'));
	fxst.set('left',sttarget);
	fxst.set('width',menus[num].getWidth().toInt());
}
function go(r){window.location.href=r;}

function fordfocus(obj,way,oldtext){
	if(way){
		if(obj.value==oldtext){obj.value="";}
	}else{
		if(obj.value==""){obj.value=oldtext;}
	}
}
function formkontrol(params){
	params=params.split(",");
	for(i=0;i<params.length;i++){
		if(document.getElementById(params[i]).value==""){
			alert("Formda Doldurulması Gereken Boş Alanlar Var");
			return false;
		}else if(params[i]=="email"){
			if(document.getElementById(params[i]).value.indexOf("@")==-1 || document.getElementById(params[i]).value.indexOf(".")==-1 || document.getElementById(params[i]).value.length < 8){
				alert("Email Alanı Yanlış Girildi !");
				return false;
			}
		}
	}
	return true;
}
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};