// JavaScript Document

var aylar = new Array ('Ocak', '&#350;ubat', 'Mart', 'Nisan', 'May&#305;s', 'Haziran', 'Temmuz', 'A&#287;ustos', 'Eyl&uuml;l', 'Ekim', 'Kas&#305;m', 'Aral&#305;k');
var gunler = new Array ('Pazartesi', 'Sali', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi', 'Pazar');

function FixDate (DateTime, Format) 
{
	/*
		Mysql'in DateTime formatindaki (YYYY-AA-GG SA:DK:SN) Tarihi, 
		Türkiyede kullanilan tarih formatina çevirmek için bir fonksiyon.
	*/
	DateTime = DateTime.split(' ');
	Temp = DateTime[0].split('-');
	Year = Temp [0]; Month = Temp [1]; Day = Temp [2];
	Temp = DateTime[1].split(':');
	Hour = Temp [0]; Minute = Temp [1]; Second = Temp [2];
	
	if (Format == undefined) {Format = 1;}
	
	if (Format == 1) { 
		return Day + " " + aylar[Month*1] + " " + Year + " " + Hour + ":" + Minute;
	} else if (Format == 2) { 
		return Day + " " + aylar[Month*1] + " " + Year;
	}
}
function Simdi(Format)
{
	/*
		Şuanki tarihi;
		Format 1, Mysql'in DateTime formatindaki (YYYY-AA-GG SA:DK:SN) şekle,
		Format 2 ve 3, Türkiyede kullanilan tarih formatina
		çevirmek için bir fonksiyon
	*/
	if (Format == undefined) {Format = 2;}
	var today = new Date();
	DateTime  = today.getFullYear() + '-' + today.getMonth() + '-' + today.getDate() + ' ' + today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds();
	if (Format == 1)
		return DateTime;
	else if (Format == 2)
		return FixDate(DateTime,Format = 1);
	else if (Format == 3)
		return FixDate(DateTime,Format = 2);
	else if (Format == 4)
		return today.getDate() + ' ' + aylar[today.getMonth()] + ' ' + today.getFullYear() + '<br />' + gunler[today.getDay()] + '<br />' + today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds();

}

function ZamanFarki(Basla,Bitir,Tur)
{
	/*
		Başlangiç ve Bitiş Tarihleri arasindaki 
		zaman farkini bulan bir fonksiyon.
		
		Eger Tur;
			"sn" ise Saniye olarak
			"dk" ise Dakika olarak
			"gn" ise Gün olarak
			"yl" ise Yil olarak
			"tum" ise, zaman farkini " XX yil, XX gün, XX saat, XX dakika, XX saniye " olarak
		deger üretir.
		
		başlangiç ve bitiş degerleri unix zaman damgasi olarak verilecegi gibi,
		mysql DateTime Zaman formati olarakta verilebilir.
	*/
	if (Basla.indexOf("-")>-1 || Basla.indexOf(":")>-1)
	{
		DateTime = Basla.split(' ');
		Temp = DateTime[0].split('-');
		Year = Temp [0]; Month = Temp [1]; Day = Temp [2];
		Temp = DateTime[1].split(':');
		Hour = Temp [0]; Minute = Temp [1]; Second = Temp [2];
		
		var gecmis_unix = Date.UTC(Year,Month,Day,Hour,Minute,Second/1000);
	}
	else
	{
		var gecmis_unix = Basla; 
	}
	if (Bitir.indexOf("-")>-1 || Bitir.indexOf(":")>-1)
	{
		DateTime = Bitir.split(' ');
		Temp = DateTime[0].split('-');
		Year = Temp [0]; Month = Temp [1]; Day = Temp [2];
		Temp = DateTime[1].split(':');
		Hour = Temp [0]; Minute = Temp [1]; Second = Temp [2];
	
		var simdiki_unix = Date.UTC(Year,Month-1,Day,Hour-3,Minute,Second)/1000;
	}
	else
	{
		var simdiki_unix = Bitir; 
	}

	var today = new Date();
	Year = today.getFullYear();
	Month = today.getMonth();
	Day = today.getDate();
	now = Date.UTC(Year,Month,Day, today.getHours()-3,today.getMinutes(),today.getSeconds())/1000;

	// alert(simdiki_unix+ ' \n\r' + gecmis_unix + ' \n\r' + now);

	var fark_unix = simdiki_unix - gecmis_unix; // Farki Bul
	Gecen_Sure = '';
	if (Tur == "sn") Gecen_Sure = floor(fark_unix); // SN Dönüştür...
	else if (Tur == "dk") Gecen_Sure = floor(fark_unix / 60); // DK Dönüştür...
	else if (Tur == "sa") Gecen_Sure = floor(fark_unix / (60 * 60)); // SAAT Dönüştür...
	else if (Tur == "gn") Gecen_Sure = floor(fark_unix / (60 * 60 * 24)); // GÜN Dönüştür...
	else if (Tur == "yl") Gecen_Sure = floor(fark_unix / (60 * 60 * 24 * 365)); // YIL Dönüştür...
	else if (Tur == "tum") { // Tüm dönüşümleri yaparak yaz.
		YIL = (fark_unix / (60 * 60 * 24 * 365)).floor(); // Yila Dönüştür...
		if (YIL > 0) {
			fark_unix -= YIL * (60 * 60 * 24 * 365);
			Gecen_Sure += YIL + ' yil, ';
		}
		
		GUN  = (fark_unix / (60 * 60 * 24)).floor(); // Güne Dönüştür...
		if (GUN > 0) {
			fark_unix -= GUN * (60 * 60 * 24);
			Gecen_Sure += GUN + ' gün, ';
		}
	
		SAAT = (fark_unix / (60 * 60)).floor(); // Saate Dönüştür...
		if (SAAT > 0) {
			fark_unix -= SAAT * (60 * 60);
			Gecen_Sure += SAAT + ' saat, ';
		}
		
		DAK  = (fark_unix / 60).floor(); // Dakikaya Dönüştür...
		if (DAK > 0) {
			fark_unix -= DAK * (60);
			Gecen_Sure += DAK + ' dakika, ';
		}

		SAN  = (fark_unix).floor(); // Saniyeye Dönüştür...
		if (SAN >= 0) {
			Gecen_Sure += SAN + ' saniye';
		} else {
			Gecen_Sure += ' 0 saniye';
		}
		
		if (YIL+GUN+SAAT+DAK+SAN <= 0) window.location.reload();
	}
	return Gecen_Sure;
}
function ac(element){ // ------	------	------	------	------	ELEMENTI AÇMA
	$(element).style.display = 'block';
}
function kapa(element){ // ------	------	------	------	------	ELEMENTI KAPAMA
	$(element).style.display = 'none';
}
function ackapa(element){ // ------	------	------	------	------	ELEMENTI AÇMA
	if ($(element).style.display == 'none' ) $(element).style.display = 'block';
	else if ($(element).style.display == 'block' ) $(element).style.display = 'none';
}
function flu(element,miktar){ // --------	------	------	------	BLUR VERME
	element.filters.blur.strength = miktar;
	element.style.filter = 'blur(strength=' + miktar + ')';
}
function fligran(element,miktar){ // --------	------	------	------	BLUR VERME
	element.style.opacity = miktar;
	element.style.filter = 'alpha(opacity=' + miktar + ')';
}
function gizle(element){ // ------	------	------	------	------	ELEMENTI Gizle
	$(element).style.visibility = 'hidden';
}
function goster(element){ // ------	------	------	------	------	ELEMENTI Göster
	$(element).style.visibility = 'visible';
}
function PopSayfaAc(url,name,w,h) 
{ 
//	alert(url+" "+name+" "+w+" "+h);
   newwindow=window.open(url,name,'height='+h+',width='+w+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'); 
   if (window.focus) {newwindow.focus()} 
} 
function bookmarksite(title, url){
	if (document.all)
	window.external.AddFavorite(url, title);
	else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}


function HighlightEffect(element,basla,bitir,sure){ // ----	------	------	------	Highligh EFEKTI
	if (!(basla)) basla = "#FFFFCC";
	if (!(bitir)) bitir = "#DFE7EC";
	if (!(sure)) sure = 1;
   new Effect.Highlight(element, 
				  {
					startcolor: basla,//"#FFFFCC",
					endcolor: bitir,//"#ebf2f6",
					restorecolor: bitir,//"#ebf2f6",
					duration: sure
				  });
	try{
		element.style.cursor='pointer'; 
	}catch(err){
	}
}

function Highlight(element,basla,bitir,sure){ // ----	------	------	------	Highligh EFEKTI
	if (!(basla)) basla = "#FFFFCC";
	if (!(bitir)) bitir = "none";

	element.style.cursor='pointer'; 
	element.style.background = basla;
	element.onmouseout = function(){element.style.background = bitir;};
}
function HighlightUP(element){ // ------	------	------	------	SARI YANMASI
	$(element).style.background = "#FFD100";
	$(element).style.cursor='pointer'; 
}
function HighlightDOWN(element,renk){ // ------	------	------	------	SARI SÖNMESI
	if (!(renk)) basla = "#DFE7EC";
	$(element).style.background = 'none';
	$(element).style.cursor='pointer'; 
}

function addLoadEvent(func)
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
	window.onload = function()
	{
      if (oldonload)
	  {
        oldonload();
      }
      try {func();} catch(e){};
    }
  }
}


//  check for valid numeric strings	
function is_numeric(strString)
{
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;
	
	if (strString.length == 0) return false;
	
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


	function documentSize(neresi) 
	{
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		if (neresi == 'H') return myHeight;
		else return myWidth;
		/*
		window.alert( 'Width = ' + myWidth );
		window.alert( 'Height = ' + myHeight );
		*/
	}


	function SignINSubmit(myfield,e, form)
	{
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		if (keycode == 13)
	   {
		   $(form).submit();
		   return false;
	   }
		else
		   return true;
	}


