function Browser(){
	var ua = navigator.userAgent.toLowerCase(); 
	this.Gecko = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
	this.Safari = (ua.indexOf('safari') != - 1);
	this.IE = (ua.indexOf('msie') != -1 && !this.Opera && (ua.indexOf('webtv') == -1) ); 
	this.Mozilla = (this.Gecko && ua.indexOf('gecko/') + 14 == ua.length);
	this.Firefox = ( (ua.indexOf('firebird/') != -1) || (ua.indexOf('firefox/') != -1) );
	this.NS = ( (this.Gecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.Opera && !this.Safari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
	this.IECompatible = ( (ua.indexOf('msie') != -1) && !this.IE);
	this.NSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.NS && !this.Mozilla);
	this.geckoVersion = ( (this.Gecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
	this.equivalentMozilla = ( (this.Gecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
	this.versionMinor = parseFloat(navigator.appVersion); 
	if (this.Gecko && !this.Mozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
	else if (this.Mozilla) this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
	else if (this.IE && this.versionMinor >= 4) this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
	else if (this.Safari) this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
	this.versionMajor = parseInt(this.versionMinor); 
	this.DOM1 = (document.getElementById);
	this.DOM2Event = (document.addEventListener && document.removeEventListener);
	this.mode = document.compatMode ? document.compatMode : 'BackCompat';
	this.Win = (ua.indexOf('win') != -1);
	this.Mac = (ua.indexOf('mac') != -1);
	this.NS6x = (this.NS && this.versionMajor == 6);
	this.NS6up = (this.NS && this.versionMajor >= 6);
	this.NS7up = (this.NS && this.versionMajor >= 7);
	this.IE4 = (this.IE && this.versionMajor == 4);
	this.IE5 = (this.IE && this.versionMajor == 5);
	this.IE55 = (this.IE && this.versionMinor == 5.5);
	this.IE5up = (this.IE && this.versionMajor >= 5);
	this.IE6x = (this.IE && this.versionMajor == 6);
	this.IE6up = (this.IE && this.versionMajor >= 6);
}
var is = new Browser();

var flashVersion = 0;
function getFlashVersion() {
	var latestFlashVersion = 25;
	var agent = navigator.userAgent.toLowerCase(); 
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object'){ 
			for (var i = latestFlashVersion; i >= 3; i--){
	            if (flashPlugin.description.indexOf(i + '.') != -1){
	               flashVersion = i;
	               break;
	            }
			}
		}
	}
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
		var doc = '<scr' + 'ipt language="VBScript"\> \n';
		doc += 'On Error Resume Next \n';
		doc += 'Dim obFlash \n';
		doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
		doc += '	Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
		doc += '	If IsObject(obFlash) Then \n';
		doc += '		flashVersion = i \n';
		doc += '		Exit For \n';
		doc += '	End If \n';
		doc += 'Next \n';
		doc += '</scr' + 'ipt\> \n';
		document.write(doc);
	} else {flashVersion = flashVersion_DONTKNOW; }
return flashVersion;
}
flashVersion_DONTKNOW = -1;
function FlashObject(){
	this.maxVersion;
	this.SwfFile;
	this.minVersion;
	this.altSwfFile;
	this.altImage;
	this.altImageAddAtribute;
	this.altImageHTML;
	this.width;
	this.height;
	this.menu;
	this.background;
	this.wmode;
	this.clientFlashVersion;
}
FlashObject.prototype.rnd=function(){
	this.ranNum= Math.random()*255;
    return this.ranNum;
}
FlashObject.prototype.reEmbed=function(){
	this.embed(true);
}

FlashObject.prototype.embed=function(reEmbed,secure){
	var buff;
	if(!reEmbed){
		this.clientFlashVersion = getFlashVersion();
	}
	if(this.clientFlashVersion>=this.maxVersion){
		buff=''+
			'<OBJECT ID="FLASHWINDOW" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH='+this.width+' HEIGHT='+this.height+'><PARAM NAME=movie VALUE="'+this.SwfFile+'?'+this.rnd()+'"><PARAM NAME=menu VALUE='+this.menu+'><param name="wmode" value="'+this.wmode+'"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="'+this.background+'">'+
				'<EMBED src="'+this.SwfFile+'?'+this.rnd()+'" menu="'+this.menu+'" wmode="'+this.wmode+'" quality="high" bgcolor="'+this.background+'"  WIDTH="'+this.width+'" HEIGHT="'+this.height+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>'+
			'</OBJECT>';
	}else if((this.clientFlashVersion> this.minVersion) && (this.clientFlashVersion< this.maxVersion) && this.altSwfFile){
		buff=''+
			'<OBJECT ID="FLASHWINDOW" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH='+this.width+' HEIGHT='+this.height+'><PARAM NAME=movie VALUE="'+this.altSwfFile+'?'+this.rnd()+'"><PARAM NAME=menu VALUE='+this.menu+'<param name="wmode" value="'+this.wmode+'"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE='+this.background+'>'+
				'<EMBED src="'+this.altSwfFile+'?'+this.rnd()+'" menu="'+this.menu+'" wmode="'+this.wmode+'" quality=high bgcolor='+this.background+'  WIDTH='+this.width+' HEIGHT='+this.height+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>'+
			'</OBJECT>';
	}else{
		this.altImageAddAtribute ? (buff='<img src="'+this.altImage+'" width="'+this.width+'" height="'+this.height+'" border="0" '+this.altImageAddAtribute+' />'+this.altImageHTML) : (buff='<img src="'+this.altImage+'" width="'+this.width+'" height="'+this.height+'" border="0" />');
	}
	if(!reEmbed)
		document.write(buff);
	else
		document.getElementById("movie").innerHTML = buff;
}

function init(){
	if (!document.getElementsByTagName) return;
	imgArray = document.getElementsByTagName("img");
		for (i=0;i<imgArray.length;i++){
			if(imgArray[i].alt!=-1) imgArray[i].title=imgArray[i].alt;
		}
	aArray = document.getElementsByTagName("a");
		for (i=0;i<aArray.length;i++){
			if(aArray[i] && aArray[i].href && !aArray[i].title && aArray[i].childNodes[0])	aArray[i].title = aArray[i].childNodes[0].nodeValue;
		}
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
			anchor.target = "_blank";
		}
	}
}

function PopItUp(src,w,h,s,r) {
	(s)?(w=w+17):w;
	(!r)?(r=0):(r=1);
	Popwin = window.open(src,"popwin","width=" + w + ",height=" + h + ",location=0,directories=0,status=1,scrollbars="+s+",menubar=0,resizable=1,copyhistory=0");
	Popwin.focus();
	return false;
}

function getUrl(obj){
	selectedObj=obj.options[obj.selectedIndex];
	document.location.href=selectedObj.value;
	return true;
}

function preload() {
	for(j=1;j<=4;j++){
		for (i=1;i<=2;i++) {
			x=new Image();
			x.src='/i/tm_0'+j+'_0'+i+'.png';
		}
	}
}

function MagicTab(menuObj, maindivID, subdivID, language){
	this.menuObj=menuObj;
	this.maindivID=maindivID;
	this.subdivID=subdivID;
	this.MenuData=new Array;
	this.tabImgPrefix="dy_";
	this.SubMenuData=new Array;
	this.firstActive=-1;
	this.SubMenuData;
	this.activeTabIndex;
	this.subOldIndex=-1;
	this.subIndex=-1;
	this.overClass;
	this.outClass;
	this.timer;
	this.mainDiv=this.getID(this.maindivID);
	this.subDiv=this.getID(this.subdivID);
	this.language = language;
	if(language=="TR")this.iFolder="img/topmenu/";else this.iFolder="En/img/topmenu/";
}
MagicTab.prototype.getID=function(id){
	return document.getElementById(id);
}
MagicTab.prototype.ShowActiveTab=function(){
	if( this.firstActive!=-1){
		this.getID((this.subdivID+"ul"+this.firstActive)).className="show";
		this.getID((this.tabImgPrefix+"0"+this.firstActive)).src=this.iFolder+this.tabImgPrefix+'0'+(this.firstActive+1)+'_02.png';
	}
}
MagicTab.prototype.SetActiveTab=function(){
	if( this.firstActive!=-1){
		this.TabTimer=setTimeout(this.menuObj+".ShowActiveTab("+this.firstActive+")",401);
	}
}
MagicTab.prototype.ClearActiveTab=function(){
	if( this.firstActive!=-1){
		this.getID((this.subdivID+"ul"+this.firstActive)).className="";
		this.getID((this.tabImgPrefix+"0"+this.firstActive)).src=this.iFolder+this.tabImgPrefix+'0'+(this.firstActive+1)+'_01.png';
	}	
}
MagicTab.prototype.buildSubmenu=function(k){
	var subMenuDataLength=this.SubMenuData[k].length;
	var subMenuCont;
	var submenutmp="";
	if(is.IE){
		submenutmp +='<ul id="'+this.subdivID+'ul'+k+'" onmouseover="'+this.menuObj+'.showSubMenu('+k+');">';
	}else{
		var newUL = document.createElement("ul");
			newUL.setAttribute("id", this.subdivID+"ul"+k)
			newUL.setAttribute("onmouseover", this.menuObj + ".showSubMenu("+k+")");
	}
	for(i=0;i<subMenuDataLength;i++){
		var subMenuCont=new Array();
			subMenuCont=this.SubMenuData[k][i].split("|");

			if(is.IE){
				submenutmp +='<li onmouseover="'+this.menuObj+'.showSub('+k+')"><a href="'+subMenuCont[1]+'">'+subMenuCont[0]+'</a></li>';
			}
			else{
				var newLI = document.createElement("li");
					newLI.setAttribute("onmouseover", this.menuObj + ".showSub("+k+")");
				var newA = document.createElement("a");
					newA.setAttribute("href",subMenuCont[1]);
				var newText = document.createTextNode(subMenuCont[0]);
					newA.appendChild(newText);
					newLI.appendChild(newA);
					newUL.appendChild(newLI);
			}
	}
	if(is.IE){
		submenutmp +="</ul>"
		this.subDiv.innerHTML += submenutmp;
	}else{
		this.subDiv.appendChild(newUL);
	}
}
MagicTab.prototype.Build=function(){
	if (is.Firefox) document.getElementById("tmenu").style.width="571px;"
	if (is.NS) document.getElementById("tmenu").style.width="571px;"
	var MenuDataLength=this.MenuData.length;
	var MenuCont;
	var menutmp="";
	var i;

	if(is.IE){
		menutmp += "<ul>";
	}else{
		var newUL = document.createElement("ul");
	}
	for (i=0;i<MenuDataLength;i++){
		var MenuCont=new Array();
			MenuCont=this.MenuData[i].split("|");
			
			if(is.IE){
				if(i>0)
					menutmp +='<li><a href="'+MenuCont[2]+'" onmouseover="'+this.menuObj+'.showSubMenu('+i+');"  onmouseout="'+this.menuObj+'.hideSubMenu('+i+');"><img id="'+this.tabImgPrefix+'0'+i+'" src="'+MenuCont[0]+'" alt="'+MenuCont[1]+'" /></a></li>';
				else
					menutmp +='<li><a onmouseover="'+this.menuObj+'.showSubMenu('+i+');"  onmouseout="'+this.menuObj+'.hideSubMenu('+i+');"><img id="'+this.tabImgPrefix+'0'+i+'" src="'+MenuCont[0]+'" alt="'+MenuCont[1]+'" /></a></li>';
			}
			else{
				var newLI = document.createElement("li");
				var newA = document.createElement("a");
				var newIMG = document.createElement("img");
				newIMG.setAttribute("src", MenuCont[0]);
				newIMG.setAttribute("alt", MenuCont[1]);
				newIMG.setAttribute("title", MenuCont[1]);
				newIMG.setAttribute("id", this.tabImgPrefix+"0"+i);
				newIMG.setAttribute("onmouseover", this.menuObj + ".showSubMenu("+i+")");
				newIMG.setAttribute("onmouseout", this.menuObj + ".hideSubMenu("+i+")");
				newA.appendChild(newIMG);
				if(i>0)
					newA.setAttribute("href",MenuCont[2]);
				newA.setAttribute("onmouseover", this.menuObj + ".showSubMenu("+i+")");
				newLI.appendChild(newA);
				newUL.appendChild(newLI);
			}
			this.buildSubmenu(i);
	}
	if(is.IE){
		menutmp +="</ul>"
		this.mainDiv.innerHTML += menutmp;
	}else{
		this.mainDiv.appendChild(newUL);
	}
	if( this.firstActive!=-1) this.ShowActiveTab(this.firstActive);
}
MagicTab.prototype.showSub=function(i){
	clearTimeout(this.timer);
	clearTimeout(this.TabTimer);
	if(i!=this.firstActive){
		this.ClearActiveTab();
	}
	this.getID((this.subdivID+'ul'+i)).className="show";
}
MagicTab.prototype.showSubMenu=function(i){
	clearTimeout(this.timer);
	if (this.subOldIndex>-1 && this.subOldIndex!=i) this.hideSub(this.subOldIndex);
	this.getID((this.tabImgPrefix+"0"+i)).src=this.iFolder+this.tabImgPrefix+'0'+(i+1)+'_02.png';
	this.showSub(i);
}
MagicTab.prototype.hideSub=function(i){
	this.getID((this.subdivID+"ul"+i)).className="";
	this.getID((this.tabImgPrefix+"0"+i)).src=this.iFolder+this.tabImgPrefix+'0'+(i+1)+'_01.png';
}
MagicTab.prototype.hideSubMenu=function(i){
	//this.timer=setTimeout(this.menuObj+".hideSub("+i+")",400);
	//this.SetActiveTab();
	this.subOldIndex=i;
}

window.onload = function() {
	preload();
	init();
	externalLinks();
}
