function openPopUp_520x390(href, target)
{
	window.open(href, target, 'width=520, height=390, top=0, toolbar=0, location=0, directories=0, status=1, menuBar=0, scrollBars=1, resizable=0');
	return false;
}
function openPopUp_600x450(href, target)
{
	window.open(href, target, 'width=800, height=600, top=0, toolbar=0, location=0, directories=0, status=1, menuBar=0, scrollBars=1, resizable=0');
	return false;
}
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 SymError()
{
	return true;
}
function deleteConfirm()
{
	var restart = confirm("Bu Kayıtı Silmek İstediğinizden Emin misiniz?");
	if(restart)
		return true;
	else
		return false;
}
function onlyNumber()
{
	if (event.keyCode < 48 || event.keyCode> 57) event.returnValue = false;
}
function goGazette(idx)
{
	if(idx == "")
		return false;
	
	window.open("newspaper.php?newspaper=" + idx, "", "");
	return true;
}
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" + escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name )
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 )
		return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 )
		end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function Delete_Cookie( name, path, domain )
{
	if ( Get_Cookie( name ) )
		document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
function changeSize(elm, _size, class_name)
{
	document.getElementById(elm).className = class_name + ' ' + class_name + '_' + _size;
	Set_Cookie('text_size', _size, 30, '', '', '');
	heightOptimizer();
	window.location.reload();
}
function authorChange(author_id, article_id, _title, _date, gazette)
{
	document.all["author_img"].src = 'images/author/' + author_id + "_s.jpg";
	document.all["author_article_title"].innerHTML = '<a href="author_article_detail.php?id=' + article_id + '">' + _title + "</a>";
	document.all["author_article_date"].innerHTML = _date;
	document.all["author_article_gazette"].innerHTML = gazette;
}
function authorSelectChanged(authorId)
{
	if(authorId != "")
		window.location = "author_article_detail.php?authorId=" + authorId;
	return false;
}
function heightOptimizer()
{
	window.onresize = heightOptimizer;
	
	var _height = document.getElementById('base_left').offsetHeight;
	
	if(_height < document.getElementById('base_middle').offsetHeight)
		_height = document.getElementById('base_middle').offsetHeight;
	
	if(_height < document.getElementById('base_right').offsetHeight)
		_height = document.getElementById('base_right').offsetHeight;
	
	document.getElementById('base').style.height = _height + "px";
	document.getElementById('base_left').style.height = _height + "px";
	document.getElementById('base_middle').style.height = _height + "px";
	document.getElementById('base_right').style.height = _height + "px";
}



function mostlyPage(type, page)
{
    mostly_type = type;
	var xmlHttpReq = false;
    var self = this;
    var strURL = 'x_mostly.php?type=' + type + '&page=' + page;
    
    if (window.XMLHttpRequest)
    {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    self.xmlHttpReq.open('GET', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-javascript; charset=iso-8859-9');
    self.xmlHttpReq.onreadystatechange = function()
    {
        if (self.xmlHttpReq.readyState == 4)
        {
        	mostlyLoad(type, self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send('');
    return false;
}
function mostlyLoad(type, str)
{
	eval(str);
	
	document.getElementById("mostly_items_data").innerHTML = mostly_items;
	changeMostly(type, 0);
}
function changeMostly(type, idx)
{
	eval('elm = mostly_data_' + type);
	
	if(typeof(window['elm']) == "undefined")
		return;

	document.getElementById("mostly_image_1").src = './images/news/110x84/' + elm[idx]['image'] + '.jpg';
	document.getElementById("mostly_title_1").innerHTML = '<a href="news_detail.php?id=' + idx + '">' + elm[idx]['title'] + '</a>';
	document.getElementById("mostly_short_content_1").innerHTML = "<a href=\"news_detail.php?id=" + idx + "\">" + elm[idx]['short_content'] + "</a>";
}

function showGalleryItem(id, title)
{
document.getElementById('i_image').src = 'images/photo_gallery_cat/' + id + '.jpg';
document.getElementById('i_title').innerHTML = '<a href="image_gallery_detail.php?id=' + id + '">' + title + '</a>';
return false;
}


function changeNewsDetail(idx)
{
	if(previousItem != -1)
	{
		document.getElementById("news_headline_" + previousItem).style.display = 'none';
	}
	document.getElementById("news_headline_" + idx).style.display = 'block';
	
	document.getElementById("news_image").src = './images/news/' + imageArr[idx] + '.jpg';
	document.getElementById("news_spot").innerHTML = "<a href=\"" + linkArr[idx] + "\">" + spotArr[idx] + "</a>";
	document.getElementById("news_link").href = linkArr[idx];
	
	previousItem = idx;
	return false;
}
function getFlashMovie(flash)
{
	return (isIE) ? window[flash] : document[flash];
}
function changeNewsDetailFlash(idx)
{
	eval('elm = news_data');
	if(typeof(window['elm']) == "undefined")
		return;

	document.getElementById("news_image").src = './images/news/' + elm[idx]['image'] + '.jpg';
	//document.getElementById("news_date").innerHTML = elm[idx]['date'];
	document.getElementById("news_spot").innerHTML = '<a href="' + elm[idx]['link'] + '">' + elm[idx]['short_content'] + '</a>';
	document.getElementById("news_link").href = elm[idx]['link'];
	getFlashMovie("headlineFlashTitle").sendAUtoFlash(elm[idx]['headline']);

	return false;
}

function CM_Floating_changeStatus()
{
	elm.swapStatus()
}
function CM_Floating_Event()
{
	elm._paint();
}
function hideFloatingBanner()
{
	var elm = document.getElementById('CM_floatingElm');
	if (typeof(elm) == 'undefined')
		return;
	elm.style.display = "none";
}


function showBookmark() 
{
	var title = encodeURIComponent(document.title);
	var url = encodeURIComponent(document.location.href);
	
	while(title.indexOf("'") != -1)
	{
		title = title.replace("'", "");
	}
	
var data = 
{

75: 	{t: "", u: "http://www.google.com/bookmarks/mark?op=edit&bkmk=" + url + "&title="+ title},
241: 	{t: "", u: "http://twitter.com/home?status=" + url + "&title="+ title},
273: 	{t: "", u: "http://www.tumblr.com/share?v=3&u=" + url + "&title="+ title},
268: 	{t: "", u: "http://www.facebook.com/sharer.php?u=" + url + "&title="+ title},
141: 	{t: "", u: "http://www.mixx.com/submit/story?page_url=" + url + "&title="+ title},
131: 	{t: "", u: "http://www.newsvine.com/_tools/seed&save?u=" + url + "&title="+ title},
60: 	{t: "", u: "http://technorati.com/faves?add=" + url + "&title="+ title},
76: 	{t: "", u: "http://myweb2.search.yahoo.com/myresults/bookmarklet?&u=" + url + "&title="+ title},
184: 	{t: "", u: "http://www.stumbleupon.com/submit?url=" + url + "&title="+ title},
81: 	{t: "", u: "http://digg.com/submit?url=" + url + "&title="+ title},
64: 	{t: "", u: "http://del.icio.us/post?url=" + url + "&title="+ title},
258: 	{t: "", u: "http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=" + url + "&title="+ title},
143: 	{t: "", u: "http://digg.com/submit?url=" + url + "&title="+ title},
140: 	{t: "", u: "http://del.icio.us/post?url=" + url + "&title="+ title},
67: 	{t: "", u: "http://www.oyyla.com/gonder?phase=2&url=" + url},
116: 	{t: "", u: "http://www.blogger.com/blog_this.pyra?u=" + url + "&t="+ title},
36: 	{t: "", u: "http://www.tumblr.com/share?v=3&u=" + url + "&t="+ title},
184: 	{t: "", u: "http://www.stumbleupon.com/submit?url=" + url + "&title="+ title},


};
	document.write('<div style="border: 1px solid #E0E0E0; padding: 5px 0px; margin-bottom: 10px;"><center><table cellpadding="0" cellspacing="0" style="font: 100 12px/16px Tahoma; height: 16px;"><tr><td><b>Bu Haberi Paylaş :&nbsp;</b></td>');
	for (var item in data)
	{
		document.write('<td style="background: url(../images/icons_share.png) no-repeat 0px ' + (item*-16) + 'px; width: 16px; line-height: 16px; padding: 0px 3px 0px 3px; margin: 0px; cursor: pointer;" title="' + data[item]['t'] + '" onclick="javascript:window.open(\'' + data[item]['u'] + '\', \'\', \'\')">' + data[item]['t'] + '</td>');
	}
	document.write('</tr></table></center></div>');
}






function showBookmark_author() 
{
	var title = encodeURIComponent(document.title);
	var url = encodeURIComponent(document.location.href);
	
	while(title.indexOf("'") != -1)
	{
		title = title.replace("'", "");
	}
	
var data = 
{

75: 	{t: "", u: "http://www.google.com/bookmarks/mark?op=edit&bkmk=" + url + "&title="+ title},
241: 	{t: "", u: "http://twitter.com/home?status=" + url + "&title="+ title},
273: 	{t: "", u: "http://www.tumblr.com/share?v=3&u=" + url + "&title="+ title},
268: 	{t: "", u: "http://www.facebook.com/sharer.php?u=" + url + "&title="+ title},
141: 	{t: "", u: "http://www.mixx.com/submit/story?page_url=" + url + "&title="+ title},
131: 	{t: "", u: "http://www.newsvine.com/_tools/seed&save?u=" + url + "&title="+ title},
60: 	{t: "", u: "http://technorati.com/faves?add=" + url + "&title="+ title},
76: 	{t: "", u: "http://myweb2.search.yahoo.com/myresults/bookmarklet?&u=" + url + "&title="+ title},
184: 	{t: "", u: "http://www.stumbleupon.com/submit?url=" + url + "&title="+ title},
81: 	{t: "", u: "http://digg.com/submit?url=" + url + "&title="+ title},
64: 	{t: "", u: "http://del.icio.us/post?url=" + url + "&title="+ title},
258: 	{t: "", u: "http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=" + url + "&title="+ title},
143: 	{t: "", u: "http://digg.com/submit?url=" + url + "&title="+ title},
140: 	{t: "", u: "http://del.icio.us/post?url=" + url + "&title="+ title},
67: 	{t: "", u: "http://www.oyyla.com/gonder?phase=2&url=" + url},
116: 	{t: "", u: "http://www.blogger.com/blog_this.pyra?u=" + url + "&t="+ title},
36: 	{t: "", u: "http://www.tumblr.com/share?v=3&u=" + url + "&t="+ title},
184: 	{t: "", u: "http://www.stumbleupon.com/submit?url=" + url + "&title="+ title},


};
	document.write('<div style="border: 1px solid #E0E0E0; padding: 5px 0px; margin-bottom: 10px;"><center><table cellpadding="0" cellspacing="0" style="font: 100 12px/16px Tahoma; height: 16px;"><tr><td><b>Bu Makaleyi Paylaş :&nbsp;</b></td>');
	for (var item in data)
	{
		document.write('<td style="background: url(../images/icons_share.png) no-repeat 0px ' + (item*-16) + 'px; width: 16px; line-height: 16px; padding: 0px 3px 0px 3px; margin: 0px; cursor: pointer;" title="' + data[item]['t'] + '" onclick="javascript:window.open(\'' + data[item]['u'] + '\', \'\', \'\')">' + data[item]['t'] + '</td>');
	}
	document.write('</tr></table></center></div>');
}


function Accelimation(from, to, time, zip) 
{
	if (typeof zip  == "undefined") zip  = 0;
	if (typeof unit == "undefined") unit = "px";

	this.x0	 = from;
	this.x1		= to;
	this.dt		= time;
	this.zip	= -zip;
	this.unit	= unit;
	this.timer	= null;
	this.onend	= new Function();
	this.onframe    = new Function();
}

Accelimation.prototype.start = function() {
	this.t0 = new Date().getTime();
	this.t1 = this.t0 + this.dt;
	var dx	= this.x1 - this.x0;
	this.c1 = this.x0 + ((1 + this.zip) * dx / 3);
	this.c2 = this.x0 + ((2 + this.zip) * dx / 3);
	Accelimation._add(this);
}

// and if you need to stop it early for some reason...
Accelimation.prototype.stop = function() {
	Accelimation._remove(this);
}

Accelimation.prototype._paint = function(time) {
	if (time < this.t1) {
		var elapsed = time - this.t0;
		this.onframe(Accelimation._getBezier(elapsed/this.dt,this.x0,this.x1,this.c1,this.c2));
	}
	else this._end();
}

// ends the animation
Accelimation.prototype._end = function() {
	Accelimation._remove(this);
	this.onframe(this.x1);
	this.onend();
}

Accelimation._add = function(o) {
	var index = this.instances.length;
	this.instances[index] = o;
	// if this is the first one, start the engine
	if (this.instances.length == 1) {
		this.timerID = window.setInterval("Accelimation._paintAll()", this.targetRes);
	}
}


Accelimation._remove = function(o) {
	for (var i = 0; i < this.instances.length; i++) {
		if (o == this.instances[i]) {
			this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) );
			break;
		}
	}
	// if that was the last one, stop the engine
	if (this.instances.length == 0) {
		window.clearInterval(this.timerID);
		this.timerID = null;
	}
}

// "engine" - call each function in the list every so often
Accelimation._paintAll = function() {
	var now = new Date().getTime();
	for (var i = 0; i < this.instances.length; i++) {
		this.instances[i]._paint(now);
	}
}


// Bezier functions:
Accelimation._B1 = function(t) { return t*t*t }
Accelimation._B2 = function(t) { return 3*t*t*(1-t) }
Accelimation._B3 = function(t) { return 3*t*(1-t)*(1-t) }
Accelimation._B4 = function(t) { return (1-t)*(1-t)*(1-t) }


//Finds the coordinates of a point at a certain stage through a bezier curve
Accelimation._getBezier = function(percent,startPos,endPos,control1,control2) {
	return endPos * this._B1(percent) + control2 * this._B2(percent) + control1 * this._B3(percent) + startPos * this._B4(percent);
}

Accelimation.instances = [];
Accelimation.targetRes = 10;
Accelimation.timerID = null;


if (window.attachEvent) {
	var cearElementProps = [
		'data',
		'onmouseover',
		'onmouseout',
		'onmousedown',
		'onmouseup',
		'ondblclick',
		'onclick',
		'onselectstart',
		'oncontextmenu'
	];

	window.attachEvent("onunload", function() {
	var el;
	for(var d = document.all.length;d--;){
	    el = document.all[d];
	    for(var c = cearElementProps.length;c--;){
		el[cearElementProps[c]] = null;
	    }
	}
	});
}
