// root@azeri.net,faiq@anadoluweb.net
// lutfen kodlarla oynamayin! bir degişiklik calismamasina sebep ola bilir.
//v0.0.1->v0.0.2  21.02.2009 subMenu sınıfı güncellendi
//v0.0.2->v0.0.3  24.02.2009 SelectOption sınıfı eklendi
if (typeof(AFR)=='undefined')AFR = {};
AFR.poweredby ='[faiq agayev(info@afrmedia.com)]';
AFR.namespaces = function()
{
	//alert(AFR.decode("af"));
	//if(eval(this.decode("QUZSLnBvd2VyZWRieQ",2)) && eval(this.decode("QUZSLnBvd2VyZWRieQ",2))==this.decode("W2ZhaXEgYWdheWV2KGluZm9AYWZybWVkaWEuY29tKV0",1))alert(this.decode('f'));
	//else eval(this.decode("bG9jYXRpb24uaHJlZj0iaHR0cDovL3d3dy5hZnJtZWRpYS5jb20i"));
	var A=arguments,E=null,C,B,D;
	for(C=0;C<A.length;C=C+1)
	{
		D=A[C].split(".");
		E=AFR;
		for(B=(D[0]=="AFR")?1:0;B<D.length;B=B+1)
		{
			E[D[B]]=E[D[B]]||{};
			E=E[D[B]];
		}
	}
}
AFR.namespaces("AFR.config");
AFR.config.web_path='';
AFR.get_path = function(x){if(this.config.web_path){return this.config.web_path + x;}else{return x;}}
AFR.loading = function(oDiv)
{
	if(typeof(oDiv)=="string")
	{
		if(!$D(oDiv))return;
		oDiv = $('#'+oDiv);
	}
	else oDiv = $(oDiv);
	h=oDiv.height();
	w=oDiv.width();
	var html='';
	html += '		<table width="'+ w +'" border="0" cellspacing="0" cellpadding="0">';
	html += '            <tr>';
	html += '              <td height="'+ h +'" width="'+ w +'" align="center" style="font-family:Tahoma;font-size:11px;"><img src="'+ AFR.get_path('images/loading_2.gif') +'"><br>Yükleniyor...</td>';
	html += '            </tr>';
	html += '          </table>';
	return html;
}
AFR.decode = function(input,eq){var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output = "";var chr1, chr2, chr3 = "";var enc1, enc2, enc3, enc4 = "";var i = 0;if(eq!="" && eq>0)for(j=0;j<eq;j++)input+="=";input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");	do {enc1 = keyStr.indexOf(input.charAt(i++));enc2 = keyStr.indexOf(input.charAt(i++));      enc3 = keyStr.indexOf(input.charAt(i++));enc4 = keyStr.indexOf(input.charAt(i++));chr1 = (enc1 << 2) | (enc2 >> 4);chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);chr3 = ((enc3 & 3) << 6) | enc4;output = output + String.fromCharCode(chr1);if (enc3 != 64) {output = output + String.fromCharCode(chr2);}if (enc4 != 64) {output = output + String.fromCharCode(chr3);}chr1 = chr2 = chr3 = "";enc1 = enc2 = enc3 = enc4 = "";} while (i < input.length);return output;}
AFR.loadIMG = function()
{
	var args = AFR.loadIMG.arguments; 
	var arr = new Array();
	for(var i=0; i<args.length; i++)
	{
		arr[args[i]] = new Image();
		arr[args[i]].src = AFR.get_path(args[i]);
	}
}
function $D(oId)
{
	if(document.getElementById(oId))return document.getElementById(oId);
	else return false;
}
function GetElementByName(xml,start,end)
{
	startpos = xml.indexOf(start);
	if (startpos == -1)return false;
	startpos = startpos + start.length;
	endpos =  xml.indexOf(end);	
	tag = xml.substring(startpos, endpos);
	return trim(tag);
}
AFR.setHomePage = function ()
{
	if (document.all) 
	{
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(AFR.config.web_path);
	} 
	else if (window.sidebar) 
	{
		if(window.netscape) 
		{
			try {  
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
			} 
			catch(e) 
			{  
				alert("Bu özellik tarayıcınız tarafından desteklenmiyor.\nLütfen ayarları elle yapmayı deneyin.");  
			}
		} 
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage',AFR.config.web_path);
	}
}
AFR.addFavori = function(url,title)
{
	if (window.sidebar) 
	{ // Mozilla Firefox
		window.sidebar.addPanel(title, url, "");
	} 
	else if( window.external ) 
	{ // IE
		window.external.AddFavorite(url, title); 
	}
}
//window.onload=fixImage;
function Browser()
{
	d=document;
	this.agt=navigator.userAgent.toLowerCase();
	this.major=parseInt(navigator.appVersion);
	this.dom=(d.getElementById);
	this.ns=(d.layers);
	this.ns4up=(this.ns && this.major>=4);
	this.ns6=(this.dom&&navigator.appName=="Netscape");
	this.op=(window.opera);
	if(d.all)this.ie=1;else this.ie=0;
	this.ie4=(d.all&&!this.dom);
	this.ie4up=(this.ie&&this.major>=4);
	this.ie5=(d.all&&this.dom);
	this.ie6=(d.nodeType);
	this.sf=(this.agt.indexOf("safari")!=-1);
	this.win=((this.agt.indexOf("win")!=-1)||(this.agt.indexOf("16bit")!=-1));
	this.winme=(this.agt.indexOf("win 9x 4.90")!=-1);
	this.xpsp2=(this.agt.indexOf("sv1")!=-1);
	this.mac=(this.agt.indexOf("mac")!=-1);
}

AFR.browser = new Browser();
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}
function trim(str)
{
   str=ltrim(str);
   str=rtrim(str);
   while(str.indexOf("  ")!=-1)
	{
	 str=str.replace("  "," ");
	}
   return str;
}
// Trim(string) : Returns a copy of a string without leading or trailing spaces
AFR.replace = function(str_search,str_rpl,str)
{
	if(typeof(str_search)=='undefined' || typeof(str_rpl)=='undefined' || typeof(str)=='undefined')return;
	if(typeof(str_search)=='object')for(i=0;i<str_search.length;i++)str = AFR.replace(str_search[i],str_rpl[i],str);
	else while(str.indexOf(str_search)!=-1)str=str.replace(str_search,str_rpl);	
	return str;
}
AFR.isString = function(char,t)
{
	var status=true;
	var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	if(typeof(t)!='undefined')str=str+t;
	for (i=0;i<char.length;i++)
 	{
  		var e = char.substring(i, i + 1);
		e = e.charCodeAt();
		var b=false;
		for (var z=0;z<str.length;z++)
		{
			var k = str.substring(z, z + 1);
			k = k.charCodeAt();
			if(k==e){b=true;break;}
		}
  		if(b==false){status=false;break;}
 	}
	return status;
}
AFR.isNumber = function(n)
{
	var s = new String("0123456789");
   	for(var j = 0;j<n.length;j++)if(s.indexOf(n.charAt(j))==-1)return false;
   	return true;
}
AFR.isPassword = function(str)
{
	str=str.toLowerCase();
	for (var i=0;i<str.length;i++)
 	{
  		var E = str.substring(i, i + 1);
  		if ((E < "0" || "9" < E ) && (E < "a" || "z" < E) && E !="_" && E !="*" && E !="-" && E !="?" && E !="+")return false;
 	}
	return true;
}
AFR.isNull = function(value)
{
	value = trim(value);
	value = value.toLowerCase();
	if(value==null || value=='null' || value=='' || value=="" || value==" " || value==' ')return true;
	else return false;
}

function num_chk( e )
{
	var k;
	k = e.keyCode;
	durum = false
	if(k>=48 && k<58)durum = true 
	return durum
}


function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}
AFR.createForm = function(formAttr,vars) 
{
	if(document.createElement)
	{
		//alert('1');
		var defaultForm = {action : '', id : 'jsForm', name : 'jsForm', method : 'POST'};
		var objBody = document.getElementsByTagName("body").item(0);
		if($D("jsForm"))$D("jsForm").parentNode.removeChild($D("jsForm"));
		var form = document.createElement("form");
		for(k in defaultForm)form.setAttribute(k,defaultForm[k]);
		for(k in formAttr)form.setAttribute(k,formAttr[k]);
		for(k in vars)
		{
			var input = document.createElement("input");
			input.setAttribute('type','hidden');
			input.setAttribute('name',k);
			input.setAttribute('id',k);
			input.value = vars[k];
			form.appendChild(input);
		}
		var input = document.createElement("input");
		input.setAttribute('type','hidden');
		input.setAttribute('name','post_id');
		input.setAttribute('id','post_id');
		input.value = AFR.config.pid;
		form.appendChild(input);
		objBody.appendChild(form);
		
		form.submit();
	}
}
function Point(x,y) {  this.x = x; this.y = y; }
AFR.mLoc = new Point(0,0);
function getMouseLoc(e)
{
  	if(!document.all)  //NS
	{
	    AFR.mLoc.x = e.pageX;
	    AFR.mLoc.y = e.pageY;
  	}
 	else               //IE
  	{
	    AFR.mLoc.x = event.x + document.body.scrollLeft;
	    AFR.mLoc.y = event.y + document.body.scrollTop;

	}
	return true;
}
//NS init:
//AFR.Event.addEvent(window,"mousemove",getMouseLoc,false);

function openPage(url,width,height)
{
	url=AFR.get_path(url);
	width=width + 10;
	height=height + 10;
	window.open(url, '_blank', 'toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=1, resizable=0, width='+ width +', height='+ height +', top=0' ) ;
}

AFR.printFile = function(path,width,height,rmode)
{
	if(typeof(rmode)=='undefined')var rmode="write";
	var ext=path.substring(path.lastIndexOf(".") + 1,path.length);
	var html = '';
	if(ext=="swf")
	{
		if(width==468 && height>60)
		{
			i="i";
			html += '<DIV id="AdID12766" onmouseover="isBrowserComplient(\'AdID22766\',\'over\');" onmouseout="isBrowserComplient(\'AdID22766\',\'out\');">';
			html += '<DIV id="AdID22766" style="position: relative; width: 468px; height: 60px; z-index: +5;visibility:collapse">';
			html += '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
			html += ' width="468" height="'+ height +'" style="position: absolute; left: 0; top: 0;">';
			html += '<PARAM name="Movie" value="'+ path +'">';
			html += '<PARAM name="WMode" value="Transparent">';
			html += '<!--['+i+'f !IE]><-->';
			html += '<OBJECT data="'+ path +'"';
			html += 'width="468" height="'+ height +'" type="application/x-shockwave-flash" style="position: absolute; left: 0; top: 0;">';
			html += '<PARAM name="WMode" value="Transparent">';
			html += '<PARAM name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">';
			html += '<\/OBJECT>';
			html += '<!--><![end'+i+'f]-->';
			html += '<\/OBJECT>';
			html += '<\/DIV>';
			html += '<\/DIV>';
		}
		else
		{
			html += '<div style="z-index:111111111;"><object  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width +'" height="'+ height +'">';
			html += '      <param name="menu" value="false">';
			html += '      <param name="movie" value="'+ path +'" />';
			html += '      <param name="quality" value="high" />';
			html += '      <param name="wmode" value="transparent" />';
			html += '      <embed src="'+ path +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'" wmode="transparent"></embed>';
			html += '    </object></div>';
		}
	}
	else if(ext=="jpg" || ext=="jpeg" || ext=="gif" || ext=="png")
	{
		html +='<img src="'+ path +'" width="'+ width +'" height="'+ height +'" border="0">';
	}
	if(rmode="write")document.write(html);
	else if(rmode="return") return html;
}
AFR.cookie = 
{
	set : function(name, value, hours, domain)
	{
		if ( typeof(hours) == 'undefined' ) hours = 48;
		if ( typeof(domain) == 'undefined' ) domain = AFR.config.web_path.substring(AFR.config.web_path.lastIndexOf("http://")+7,AFR.config.web_path.length - 1);
		
		var expire = "";
		if(hours != null)
		{
			expire = new Date((new Date()).getTime() + hours * 3600000);
			expire = "; expires=" + expire.toGMTString();
		}
		if(domain != null)expire = expire + "; domain=" + domain;
		
		document.cookie = name + "=" + escape(value) + expire;
	},
	get : function(name)
	{
		var cookieValue = "";
		var search = name + "=";
		if(document.cookie.length > 0)
		{ 
			offset = document.cookie.indexOf(search);
			if (offset != -1)
			{ 
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1) end = document.cookie.length;
				cookieValue = unescape(document.cookie.substring(offset, end))
			}
		}
		return cookieValue;
	},
	del : function(name)
	{
		document.cookie = name + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
		this.set(name,"","0");
	}
}
AFR.select = function(main,subs){this.init(main,subs);}
AFR.select.prototype = 
{
	init : function(main,subs)
	{
		this.main = main;
		this.sub = subs;
		var rows = $('#'+this.main.id).find("A");
		for(i=0;i<rows.size();i++)
		{
			var self = this;
			$(rows[i]).attr('rel',i);
			$(rows[i]).mouseover(function(){self.chng(this.rel);});
		}
	},
	chng : function(x)
	{
		var vLink = $('#'+this.main.id).find("A");
		if(vLink.size()==0)return;
		if(this.main.clss!='')
		{
			vLink.removeClass(this.main.clss);
			$(vLink[x]).addClass(this.main.clss);
		}
		for(var j=0; j < this.sub.length; j++)
		{
			var vChng = $('#'+this.sub[j]).find("A");
			vChng.css({display : 'none'});
			$(vChng[x]).css({display : 'block'});
		}
	}
}
AFR.namespaces("AFR.hint");
AFR.hint.objct = new Array();
AFR.hint.add = function(obj,str,cl)
{
	if(typeof(AFR.hint.objct[obj])!='undefined')return;
	else AFR.hint.objct[obj] = true;
	var self = this;
	var hint = $('#hint');
	var obj = $D(obj);
	if(!obj){ return; }
	if(!$D('hint')){ return; }
	//AFR.Event.removeEvent(obj,"mouseover",AFR.hint.add,true);
	if(typeof(cl)=='undefined')cl='hint';
	obj.onmouseout = function(advance)
	{
		hint.css({width:'',visibility:'hidden'});
		hint.removeClass(cl);
		if($D('hint').firstChild)$D('hint').removeChild($D('hint').firstChild);
		$D('hint').appendChild(document.createTextNode(str));
	}
	obj.onmousemove = function(advance)
	{
		hint.addClass(cl);
		
		hint.css({width:''});
		hint.html(str);
		vc = document.getElementsByTagName((document.compatMode && document.compatMode=="CSS1Compat") ? "HTML":"BODY")[0];
		x = window.event ? event.clientX + vc.scrollLeft : advance.pageX;
		y = window.event ? event.clientY + vc.scrollTop : advance.pageY;
		vcwidth = vc.clientWidth ? vc.clientWidth + vc.scrollLeft : window.innerWidth + window.pageXOffset;
		vcheight = vc.innerHeight ? window.innerHeight + window.pageYOffset : vc.clientHeight + vc.scrollTop;
		if(hint.width()>500)hint.width('200px'); 
		if((x + hint.width() + 15) > vcwidth)hint.css({left:x - hint.width() - 15});
		else hint.css({left : x + 15});
		if((y + hint.height() + 19) > vcheight)hint.css({top : y - hint.height()});
		else hint.css({top : y + 5});
	  
		hint.css({visibility :'visible'});
	}
}
AFR.hint.init = function()
{
	if(!$D('hint')){ return; }
	var hint = document.createElement("DIV");
	hint.setAttribute('id','hint');
	document.getElementsByTagName('body')[0].appendChild(hint);
	hint.style.visibility = 'hidden';
	hint.className = 'hint';
	hint.style.left = 15;
	hint.style.top = 50;
}
//$(document).ready(AFR.hint.init);

//19.02.2009 kütüphanenin göz bebeği carousel :) 
AFR.carousel = function(vars){this.init(vars);}
AFR.carousel.prototype = 
{
	init : function(vars)
	{
		this.vars = {orientation:'vertical',animationSpeed:200,autoPlay:"",prevButton:"",nextButton:"",prevButtonState:"",nextButtonState:"",tag:"A",step:1,numVisible:1};
		var self = this;
		for(k in vars)this.vars[k] = vars[k];
		if(typeof(this.vars.oId)=='undefined')return;
		this.obj = $(this.vars.oId);
		if(this.vars.orientation=='vertical')
		{
			this.step = this.obj.find(this.vars.tag).height();
			this.size = this.obj.find(this.vars.tag).size();
			this.obj.css({top:'0px',height:this.size * this.step + 'px'});
			this.move='up';
		}
		else
		{
			this.step = this.obj.find(this.vars.tag).width();
			this.size = this.obj.find(this.vars.tag).size();
			this.obj.css({left:'0px',width:this.size * this.step + 'px'});
			this.move='left';
		}
		this.obj.mouseover(function(){self.stopPlay();}).mouseout(function(){self.autoPlay();});
		if(!AFR.isNull(this.vars.nextButton) && !AFR.isNull(this.vars.prevButton))
		{
			$(this.vars.nextButton).click(function(){self.goNext();return false;}).mouseover(function(){self.stopPlay();}).mouseout(function(){self.autoPlay();});
			$(this.vars.prevButton).click(function(){self.goPrev();return false;}).mouseover(function(){self.stopPlay();}).mouseout(function(){self.autoPlay();});
		}
		this.vars.numVisible--;
		this.curnt = 1;
		this.autoPlay();
	},
	goNext : function()
	{
		if(this.curnt+this.vars.numVisible<this.size)this.curnt++;
		else return;
		this.scrollTo(this.curnt);
	},
	goPrev : function()
	{
		if(this.curnt>1)this.curnt = this.curnt - 1;
		else return;
		this.scrollTo(this.curnt);
	},
	scrollTo : function(curnt)
	{
		this.curnt = curnt;
		curnt--;
		var t = this.step*curnt*(-1);
		if(this.vars.orientation=='vertical')this.obj.animate({top: t+'px'},this.vars.animationSpeed);
		else this.obj.animate({left: t+'px'},this.vars.animationSpeed);
	},
	autoPlay : function()
	{
		var self = this;  
		if(AFR.isNull(this.vars.autoPlay))return;
		if(this.curnt+this.vars.numVisible==this.size && (this.move=='up' || this.move=='left'))this.move = (this.move=='up')?'down':'right';
		else if(this.curnt==1 && (this.move=='down' || this.move=='right'))this.move = (this.move=='down')?'up':'left';
		if(this.move=='up' || this.move=='left')var fun = function(){self.goNext();self.autoPlay();};
		else if(this.move=='down' || this.move=='right')var fun = function(){self.goPrev();self.autoPlay();};
		this.timer = setTimeout(fun,this.vars.autoPlay);
	},
	stopPlay : function()
	{
		if(this.timer!=null){clearTimeout(this.timer);this.timer=null;}
	}
}

//21.02.2009 subMenu Güncellendi
AFR.subMenu = function(vars){this.init(vars);}
AFR.subMenu.prototype =
{
	init : function(vars)
	{
		this.vars = vars;
		this.timer;
		var self = this;
		this.obj = $(this.vars.id);
		var objA = this.obj.find("."+this.vars.mainLinkClass);
		$.each(objA,function(i,v)
			{
				if($(v.parentNode).find("ul").size()==0)return;
				$(v).mouseover(function(){self.opCtgryMn(v,self);}).mouseout(function(){self.clCtgryMn();});
			});
		this.obj.find("ul").mouseover(function(){if(self.timer!=null){clearTimeout(self.timer);self.timer=null;}}).mouseout(function(){self.clCtgryMn();});
	},
	opCtgryMn : function(elem,self)
	{
		self.clCtgryMn2();
		if(typeof(self.vars.mainLinkActiveClass)!='undefined' && !AFR.isNull(self.vars.mainLinkActiveClass))$(elem).parent().find("a:first").addClass(self.vars.mainLinkActiveClass);
		$(elem).parent().find("ul:first").css('display','block');
		if(typeof(self.vars.opAfterHanler)!='undefined' && !AFR.isNull(self.vars.opAfterHanler))eval(self.vars.opAfterHanler+"(elem,self.vars)");
	},
	clCtgryMn : function()
	{
		var self = this;
		this.timer = setTimeout(function(){self.clCtgryMn2();}, 1000);
	},
	clCtgryMn2 : function()
	{
		var self = this;
		var rows = self.obj.find("ul");
		rows.css('display','none');
		$.each(rows,function(i,v){$(v).parent().find("a:first").removeClass(self.vars.mainLinkActiveClass);});
		if(self.timer!=null){clearTimeout(self.timer);self.timer=null;}
	}
}

//24.02.2009 SelectOption Eklendi
AFR.SelectOption = function(vars){this.init(vars);}
AFR.SelectOption.prototype = 
{
	init : function(vars)
	{
		
		this.inputName = vars.inputName;
		this.oId = $(vars.oId);
		this.timer=null;
		this.clss = vars.clss;
		var self = this;
		this.link = this.oId.find("a:first");
		this.ul = this.oId.find("ul:first");
		this.link.click(function(){self.op();}).mouseout(function(){self.timer = setTimeout(function(){self.cl();}, 500);});
		this.ul.mouseover(function(){self.op();}).mouseout(function(){self.timer = setTimeout(function(){self.cl();}, 500);});
		this.ul.find("a").click(function(){self.link.find("span:first").html(this.innerHTML);$(self.inputName).val(this.title);self.cl();});
	},
	op : function()
	{
		if(this.timer!=null){clearTimeout(this.timer);this.timer=null;}
		this.ul.css('display','block');
		this.link.addClass(this.clss);
	},
	cl : function()
	{
		this.ul.css('display','none');
		this.link.removeClass(this.clss);
	}
}		
