// Güvenlik kodu fonksiyonları
function reloadImage(){
	theDate=new Date()
	document["captcha_resim"].src="app/captcha/captcha.asp?"+theDate.getTime()
}

// Müşteri hizmetleri
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
function openMessenger() {
lt=getCookie('lhtop')-30;
ll=getCookie('lhleft')-4;
lh=getCookie('lhheight');
lw=getCookie('lhwidth');
 window.open('livehelp/messenger.asp','messenger','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=250,height=500,top='+lt+',left='+ll);
}

function openChat(varUrl){
	var winleft=(screen.width-700)/2;
	var wintop=(screen.height-450)/2;
	window.open(varUrl,'chat','toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=1,width=700,height=450,top='+wintop+',left='+winleft);
	}

// Form zıpla
function zipla(URL) {	
	if (URL.options[URL.selectedIndex].value != "") self.location.href = URL.options[URL.selectedIndex].value;	
	return true;
}

// Sadece rakam
RegExp.prototype.harfRakam=function(str){
	return (this.test(str)) ? str.replace(this,"") : str ;
}

// TAB FONKSİYONLARI
function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a")
	this.enabletabpersistence=true
	this.hottabspositions=[]
	this.currentTabIndex=0
	this.subcontentids=[]
	this.revcontentids=[]
	this.selectedClassTarget="link"
}

ddtabcontent.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i");
	if (document.cookie.match(re))
		return document.cookie.match(re)[0].split("=")[1]
	return ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/"
}

ddtabcontent.prototype={

	expandit:function(tabid_or_position){
		this.cancelautorun()
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel"))
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel"))
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="")
			this.expandtab(tabref)
	},

	cycleit:function(dir, autorun){
		if (dir=="next"){
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
		}
		else if (dir=="prev"){
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
		}
		if (typeof autorun=="undefined")
			this.cancelautorun()
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
	},

	setpersist:function(bool){
			this.enabletabpersistence=bool
	},

	setselectedClassTarget:function(objstr){
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	urlparamselect:function(tabinterfaceid){
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i"))
		return (result==null)? null : parseInt(RegExp.$1)
	},

	expandtab:function(tabref){
		var subcontentid=tabref.getAttribute("rel")
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.expandsubcontent(subcontentid)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
		}
		if (this.enabletabpersistence)
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
		this.setcurrenttabindex(tabref.tabposition)
	},

	expandsubcontent:function(subcontentid){
		for (var i=0; i<this.subcontentids.length; i++){
			var subcontent=document.getElementById(this.subcontentids[i])
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none"
		}
	},

	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	setcurrenttabindex:function(tabposition){
		for (var i=0; i<this.hottabspositions.length; i++){
			if (tabposition==this.hottabspositions[i]){
				this.currentTabIndex=i
				break
			}
		}
	},

	autorun:function(){
		this.cycleit('next', true)
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid)
		var selectedtab=-1
		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid)
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel")
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun()
					return false
				}
				if (this.tabs[i].getAttribute("rev")){
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					selectedtab=i
				}
			}
		}
		if (selectedtab!=-1)
			this.expandtab(this.tabs[selectedtab])
		else
			this.expandtab(this.tabs[this.hottabspositions[0]])
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	}
}

// ******************* JXP YENİLEME *********************
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 JXP(yukleniyor, yer, dosya, sc) {
	ajax = new AJAX();
	
	if ( ajax ) {
		ajax.onreadystatechange = function () {}
		ajax.abort()
	}

    ajax.onreadystatechange = function () {	Loading(yukleniyor, yer) }
	
	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=windows-1254')
    ajax.setRequestHeader("Content-length", sc.length)
    ajax.setRequestHeader("Connection", "close")
	ajax.send(sc)		
}

function JXG(yukleniyor, yer, dosya, sc) {
	ajax = new AJAX();
	
	if ( ajax ) {
		ajax.onreadystatechange = function () {};
		ajax.abort();
	}

	if(sc) {
		dosya = dosya +'?'+ sc;
	}

    ajax.onreadystatechange = function () {	Loading(yukleniyor, yer); }
	
	ajax.open('GET', dosya, true);
	ajax.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	ajax.setRequestHeader("Connection", "close");
	ajax.send(null);	
}

function Loading(yukleniyor, yer) {
	if( yukleniyor == 1 && yer != 'no_id' ) {
		if( ajax.readyState == 1 || ajax.readyState == 2 || ajax.readyState == 3 ) {
			var loading = '<br /><center><img src="lib/img/yukle.gif" /></center><br />'
			document.getElementById(yer).innerHTML = loading;
		}
	}

	if( ajax.readyState == 4 && yer != 'no_id' ) {
		if (ajax.status == 200) {
            document.getElementById(yer).innerHTML = ajax.responseText;
        } else {
            document.getElementById(yer).innerHTML = '<strong>HATA:</strong> ' + ajax.statusText;
        }
		function AJAX() {};
    }
}

function fc_(text) {
	var temp;
	
	temp = encodeURIComponent(text);
	
	return temp;
}

// Önizleme
var w=1
var h=1

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:-1000px;width:1px;height:1px;border:1px solid #888888;background:#DDDDDD;"><img id="ttimg" src="/resource/image/loading.gif" /></div>')

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail()
{
	document.onmousemove=""
	document.getElementById('ttimg').src='/resource/image/loading.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-1000
	gettrailobj().top=0
}


function showtrail(width,height,file)
{
	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		w=width
		h=height
		
		// followmouse()
	
		document.getElementById('ttimg').src=file
		document.onmousemove=followmouse
		gettrailobj().visibility="visible"
		gettrailobj().width=w+"px"
		gettrailobj().height=h+"px"


	}
}


function followmouse(e)
{

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{

		var xcoord=20
		var ycoord=20

		if (typeof e != "undefined")
		{
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined")
		{
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

		if (xcoord+w+3>docwidth)
		xcoord=xcoord-w-(20*2)

		if (ycoord-truebody().scrollTop+h>truebody().clientHeight)
		ycoord=ycoord-h-20;

		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"

	}

}
