function AJAX() {
   var ajax = false;
   try {
     ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
   } catch (e) {
      try {
        ajax = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        ajax = false;
      }
   }
   if ( !ajax && typeof XMLHttpRequest != 'undefined' ) {
     try{
        ajax = new XMLHttpRequest();
     }catch(e) {    
        ajax = false;
     }
   }
   if ( !ajax && window.createRequest ) {
	 try{
        ajax = window.createRequest();
     }catch(e) {  
        ajax = false;
     }
   }
	return ajax;
}

function GetRequest(showload, TargetLayer, dosya, Qprm, tip) {
	ajax = new AJAX();
	if ( ajax ) {
		ajax.onreadystatechange = function () {}
		ajax.abort()
	}
    ajax.onreadystatechange = function () {	Loading(showload, TargetLayer, dosya,tip) }
	ajax.open('POST', dosya, true)
	ajax.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8')
    ajax.setRequestHeader("Content-length", Qprm.length)
    ajax.setRequestHeader("Connection", "close")
	ajax.send(Qprm)	
}

function fc_(text) {
	var temp;
	
	temp = encodeURIComponent(text);
	
	return temp;
}

function Loading(showload, TargetLayer, dosya, tip) {
	if( showload == 1 && TargetLayer != 'no_id' ) {
		if( ajax.readyState == 1 || ajax.readyState == 2 || ajax.readyState == 3 ) {
			var loading = '<div style="text-align:center;margin-top:20px;"><img src="../images/loading.gif" width="16" height="16"/></div>'
			document.getElementById(TargetLayer).innerHTML = loading;
		}
	}

	if( ajax.readyState == 4 && TargetLayer != 'no_id' ) {
		if (ajax.status == 200) {
			if (tip=='innerhtml'){
            document.getElementById(TargetLayer).innerHTML = ajax.responseText;}
			else if (tip=='value')
			{document.getElementById(TargetLayer).value = ajax.responseText;}
			else {document.getElementById(TargetLayer).innerHTML = ajax.responseXML;}
        } else {
            document.getElementById(TargetLayer).innerHTML = '<strong>HATA:</strong> ' + ajax.statusText;
        }
		function AJAX() {};
    }
}
function SlideNext() {
	if (lcnt<2)
		{return;}
	else
		{
			if(thisleft<-lcnt-(lcnt-2)*160)
			{thisleft=160;}
			markaint=window.clearInterval(markaint);
			Animateleft(1);
		}
}
function SlidePrevious() {
	if (lcnt<4)
		{return;}
	else
		{
			if(thisleft>-160)
			{thisleft=-(lcnt-2)*160;}
			markaint=window.clearInterval(markaint);
			Animateleft(0);
		}
}
function Animateleft(direction) {
	if (acnt<160)
	{	
		if (direction==1){
			thisleft=thisleft-5;
		}
		else
		{
			thisleft=thisleft+5;
		}
		document.getElementById('slider_in_list').style.marginLeft=thisleft+'px';
		acnt=acnt+5;
		setTimeout("Animateleft("+direction+");",Math.ceil(5));
	}
	else
	{
		acnt=0;
		markaint=setInterval('SlideNext();', 5000)
	}
}
function SelectNews(id) {
	nextpict=id;
	bannerint=window.clearInterval(bannerint);
	if(thispict==nextpict){if(id==0){thispict=1;}else{thispict=0;}}
	document.getElementById(pictlist[thispict]).style.zIndex="1";
	document.getElementById(pictlist[nextpict]).style.zIndex="10";
	document.getElementById(pictlist[nextpict]).style.visibility="visible";
	document.getElementById(pictlist[thispict]).style.visibility="hidden";
	document.getElementById('haber_txt').innerHTML=txtlist[nextpict];
	thispict=id;
	bannerint=setInterval('processNext();', 10000);
}
function processNext() {
	if (thispict == ncnt-1){nextpict = 0;}else{nextpict=thispict+1;}
	document.getElementById(pictlist[thispict]).style.zIndex="100"
	document.getElementById(pictlist[nextpict]).style.zIndex="1"
	document.getElementById(pictlist[nextpict]).style.visibility="visible"
	FadeOpacity(pictlist[thispict],100,0,1000,12,1);
}

function FadeOpacity(elemId, fromOpacity, toOpacity, time, fps, optype){
     var steps = Math.ceil(fps * (time / 1000));
     var delta = (toOpacity - fromOpacity) / steps;
     FadeOpacityStep(elemId, 0, steps, fromOpacity, 
                     delta, (time / steps), optype);
}

function FadeOpacityStep(elemId, stepNum, steps, fromOpacity, delta, timePerStep, optype){
    SetOpacity(document.getElementById(elemId), 
               Math.round(parseInt(fromOpacity) + (delta * stepNum)));
    if (stepNum < steps)
        {setTimeout("FadeOpacityStep('" + elemId + "', " + (stepNum+1) 
                 + ", " + steps + ", " + fromOpacity + ", "
                 + delta + ", " + timePerStep + "," +optype+");", 
                   timePerStep);}
		else
		{ResetPicture();
			}
	
}
function ResetPicture(){
	if (thispict == ncnt-1){nextpict = 0;}else{nextpict=thispict+1;}
	document.getElementById(pictlist[thispict]).style.visibility="hidden"
	SetOpacity(document.getElementById(pictlist[thispict]),101);
	document.getElementById(pictlist[thispict]).style.zIndex="100"
	document.getElementById(pictlist[nextpict]).style.visibility="visible"
	document.getElementById(pictlist[nextpict]).style.zIndex="1"
	document.getElementById('haber_secim_buton'+thispict).style.background="url(images/h2.jpg) center no-repeat"
	if (thispict == ncnt-1){thispict = 0;}else{thispict++;}
	document.getElementById('haber_txt').innerHTML=txtlist[nextpict];
	document.getElementById('haber_secim_buton'+nextpict).style.background="url(images/rakam.jpg) center no-repeat"
}


function SetOpacity(elem, opacityAsInt){
    var opacityAsDecimal = opacityAsInt;
    
    if (opacityAsInt > 100)
        opacityAsInt = opacityAsDecimal = 100; 
    else if (opacityAsInt < 0)
        opacityAsInt = opacityAsDecimal = 0; 
    
    opacityAsDecimal /= 100;
    if (opacityAsInt < 1)
        opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
    
    elem.style.opacity = (opacityAsDecimal);
    elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}
function SubSelect(obj,sitelanguage,tobj,site){
	if (document.getElementById(obj).value==""){return};
	if (obj.substr(0,3)=="Cat")
		{
		var lval = document.getElementById(obj).value;
		var postprm ='lval='+fc_(lval)+'&sitelanguage='+fc_(sitelanguage);
  		GetRequest(1, tobj, site+'Submenu.asp', postprm,'innerhtml');
		}
		else
		{
			MM_jumpMenu('parent',document.getElementById(obj),0);
		}
}
function SubMenu(id,sitelanguage){
		document.getElementById('submenu').style.display="block";
		var postprm ='id='+fc_(id)+'&sitelanguage='+fc_(sitelanguage);
  		GetRequest(1, 'submenu', 'Submenu.asp', postprm,'innerhtml');
}
function RemoveSubMenu(event){
	var el = document.elementFromPoint(event.screenX,event.screenY)
		if (el.id!='urunmenu' && el.id!='urunmenulist' && el.id!='submenu_in' && el.id!='')
		{
		document.getElementById('submenu').style.display="none";}
}
function ShowPage(obj,id,site){
		if(Vtab==obj){document.getElementById(obj).innerHTML=Vstr;}
		if(navigator.appName != "Microsoft Internet Explorer")
		{var subindex=3;}else{var subindex=1;}
		document.getElementById(activepage).style.display="none";
		if (document.getElementById(activepage).innerHTML.toUpperCase().indexOf("OBJECT")>0)
		{Vstr=document.getElementById(activepage).innerHTML;
		Vtab=activepage;
		document.getElementById(activepage).innerHTML="";}
		document.getElementById(obj).style.display="inline";
		activepage=obj;
		if (obj!="contentsubfoto" && obj!="contentsubReferans")
		{
		if (document.getElementById(obj).childNodes[subindex])
		{
			if (document.getElementById(obj).childNodes[subindex].id.substr(0,13)=="contentsubsub")
			{
				if (document.getElementById(activesubpage))
				{
					document.getElementById(activesubpage).style.display="none";
				}
				document.getElementById(obj).childNodes[subindex].style.display="inline";
				activesubpage=document.getElementById(obj).childNodes[subindex].id;
			}
		}
		}
		else
		{
			var postprm ='id='+fc_(id)+'&siteadres='+fc_(site);
  			GetRequest(1, 'contentsubfoto', site+'incresim.asp', postprm,'innerhtml');
		}
}
function ShowSubPage(obj,objg){
		if (document.getElementById(activesubpage)){
		document.getElementById(activesubpage).style.display="none";
		document.getElementById(objg).style.display="none";
		}
		document.getElementById(obj).style.display="inline";
		activesubpage=obj;
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function popup(a) {
yeni=window.open(a,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,dependent=no,resizable=no,width=400,height=280,top="+((screen.height/2)-140)+",left="+((screen.width/2)-200)+"");
if(navigator.appName == "Microsoft Internet Explorer" &&
  parseInt(navigator.appVersion) >= 4) {
      yeni.focus();
      } else {
      if(navigator.appName != "Microsoft Internet Explorer")
      yeni.focus(); }
}
function set_hover(r,c) {
	document.all(r).style.backgroundColor="Red";
}
function get_hover(r,c) {
	document.all(r).style.backgroundColor=c;
}
function popup_ac(a,b,c) {
yeni=window.open(a,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,dependent=no,resizable=no,width="+b+",height="+c+",top="+((screen.height/2)-(c/2))+",left="+((screen.width/2)-(b/2))+"");
if(navigator.appName == "Microsoft Internet Explorer" &&
  parseInt(navigator.appVersion) >= 4) {
      yeni.focus();
      } else {
      if(navigator.appName != "Microsoft Internet Explorer")
      yeni.focus(); }
}
