var user_agent = navigator.userAgent;
var isOpera = user_agent.indexOf("Opera") >= 0;
var isFirefox = user_agent.indexOf("Firefox") >= 0;
var isWin32up = user_agent.indexOf("Win32") >= 0 
	|| user_agent.indexOf("Win64") >= 0
	|| user_agent.indexOf("Windows NT") >= 0;

var isIE = !isOpera && user_agent.indexOf("MSIE") >= 0;
var isIE55up = isIE && isWin32up && user_agent.match(/MSIE ((5\.5)|[6789])/);
var isIE70up = isIE && isWin32up && user_agent.match(/MSIE ([789])/);
var isIE55dn = isIE && !isIE55up;
var browser = "other";

/* Site Ana Sayfam Yap & Favorilerime Ekle */

function add2Favorites(ths, url, title) {
	if (isIE && window.external != null) {
		window.external.AddFavorite(url,title);
	} else if (isFirefox && window.sidebar && window.sidebar.addPanel) {
		window.sidebar.addPanel(title, url, '');
	} else if (isOpera) {
		ths.rel = "sidebar";
		ths.title = title
		ths.href = url;
	}
}

function setHomePage2(ths, url) {
	this.style.behavior='url(#default#homepage)';
	this.setHomePage(url);
}

/* Manşet Göster */

function getCuff(index)
	{
		var n = 8;
		for(i=0 ; i<n ; i++)
		{
			
			if(i == index)
			{
				menuid="title"+i;
				document.getElementById(menuid).style.display = "block";
				menuid="image"+i;
				document.getElementById(menuid).style.display = "block";
				menuid="spot"+i;
				document.getElementById(menuid).style.display = "block";
			}
			else
			{
				menuid="title"+i;
				document.getElementById(menuid).style.display = "none";
				menuid="image"+i;
				document.getElementById(menuid).style.display = "none";
				menuid="spot"+i;
				document.getElementById(menuid).style.display = "none";
			}
		}
}

function textareaCounter(t, counterField, textLimit){ 
var textLength = t.value.length; 
var counterInput = document.getElementById(counterField); 
if(textLength > textLimit){ 
alert("En Fazla " + textLimit + " karakter girebilirsiniz."); 
t.value=t.value.substring(0,textLimit); 
} 
counterInput.value = (textLimit-parseInt(t.value.length)); 
}


/* Textarea Yazı Limiti */

function validateLength(el, word_left_field, len)
{
	document.all[word_left_field].value = len - el.value.length;
	if(document.all[word_left_field].value < 1)
	{
		alert("En Fazla " + len + " karakter girebilirsiniz.");
		el.value = el.value.substr(0, len);
		document.all[word_left_field].value = 0;
		return false;
	}
	return true;
}

/* Yazı Boyutu Değiştir */

function changeSize(elm, _size, class_name)
{
	document.getElementById(elm).className = class_name + ' ' + class_name + '_' + _size;
}

/**/

function changeTarget(elm)
{
	tmp = elm.getElementsByTagName("a");
	for(i=0; i<tmp.length; i++)
		tmp[i].target = "_blank";
}

/**/

function openPopUp_520x390(href, target)
{
	var winl = (screen.width - 520) / 2;
	var wint = (screen.height - 390) / 2;
	window.open(href, target, 'width=520, height=390, top=' + wint + ', left=' + winl + ', toolbar=0, location=0, directories=0, status=1, menuBar=0, scrollBars=1, resizable=0');
	return false;
}

/**/

function openPopUp(href, target)
{
	var winl = (screen.width - 600) / 2;
	var wint = (screen.height - 450) / 2;
	window.open(href, target, 'width=600, height=450, top=' + wint + ', left=' + winl + ', toolbar=0, location=0, directories=0, status=1, menuBar=0, scrollBars=1, resizable=0');
	return false;
}

/**/

function userPopup(href, target, width, height)
{
	var winl = (screen.width - width) / 2;
	var wint = (screen.height - height) / 2;
	window.open(href, target, 'width = '+width+', height=' + height +', top=' + wint + ',left=' + winl + ', toolbar=0, location=0, directories=0, status=1, menuBar=0, scrollBars=1, resizable=0');
	return false;
}

/**/

function goPage(idx)
{
	return window.location = "./page_detail.php?page_id=" + idx;
}

/**/

function changeArticle(idx)
{
	return window.location = "./author_article_detail.php?article_id=" + idx;
}

/**/

function blinkIt()
{
	if(!document.all)
		return;
	else
	{
		for(i=0; i<document.all.tags('blink').length; i++)
		{
			s=document.all.tags('blink')[i];
			s.style.visibility=(s.style.visibility=='visible')?'hidden':'visible';
		}
	}
}

function showError()
{
	return true;
}

function heightOptimizer()
{
	var _height = document.getElementById('middle_side').offsetHeight;
	
	if(_height < document.getElementById('left_side').offsetHeight)
		_height = document.getElementById('left_side').offsetHeight;
	
	if(_height < document.getElementById('right_side').offsetHeight)
		_height = document.getElementById('right_side').offsetHeight;
	
	document.getElementById('side').style.height = _height + "px";
	document.getElementById('left_side').style.height = _height + "px";
	document.getElementById('middle_side').style.height = _height + "px";
	document.getElementById('right_side').style.height = _height + "px";
}
