function htmlspecialchars_decode (string, quote_style) {
    var optTemp = 0,
        i = 0,
        noquotes = false;
    if (typeof quote_style === 'undefined') {
        quote_style = 2;
    }
    string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    var OPTS = {
        'ENT_NOQUOTES': 0,
        'ENT_HTML_QUOTE_SINGLE': 1,
        'ENT_HTML_QUOTE_DOUBLE': 2,
        'ENT_COMPAT': 2,
        'ENT_QUOTES': 3,
        'ENT_IGNORE': 4
    };
    if (quote_style === 0) {
        noquotes = true;
    }
    if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
        quote_style = [].concat(quote_style);
        for (i = 0; i < quote_style.length; i++) {
            // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
            if (OPTS[quote_style[i]] === 0) {
                noquotes = true;
            } else if (OPTS[quote_style[i]]) {
                optTemp = optTemp | OPTS[quote_style[i]];
            }
        }
        quote_style = optTemp;
    }
    if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
        string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
        // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
    }
    if (!noquotes) {
        string = string.replace(/&quot;/g, '"');
    }
    // Put this in last place to avoid escape being double-decoded
    string = string.replace(/&amp;/g, '&');

    return string;
}

function getArchiveDate( varsayilan_dil ){
	var gDate = document.getElementById('tcalNewsDate').value;
	var gYear = gDate.substring(0,4)+"&";
	var gMonth = gDate.substring(5,7)+"&";
	var gDay = gDate.substring(8,10)+"&";
	window.location ='arsiv.php?gun='+gDay+'ay='+gMonth+'yil='+gYear+'lang='+varsayilan_dil;
}


function kayan_haberler(haberler)
{
	$('#kayan_haberler').html('<marquee style="height:24px;" scrolldelay="21" truespeed="" scrollamount="1" onmouseout="this.start()" onmouseover="this.stop()">'+htmlspecialchars_decode ( haberler ) +'</marquee>');
}

function footer_links(links)
{
	$('#footer_links').html( htmlspecialchars_decode ( links ) );
	$('#pa_div').html( '<label for="password">password</label><input name="password" id="password" type="password" size="10"/>' );
	
}

function face_tweet(id,dil){

	$('#face_tweet').html('<a name="fb_share"></a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script><div style="display:block;clear:both;margin-bottom:5px;"></div><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.qha.com.ua/haber.php?id='+ id +'&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=tahoma&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px;height:35px;"></iframe><div style="display:block;clear:both;"></div><a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-url="http://qha.com.ua/haber.php?id='+ id +'">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script><g:plusone size="medium" annotation="inline"></g:plusone>');


}


var date = new Date();
var d  = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var full_date = year + '-' + month + '-' + day;


function archive_input(e)
{
	if (window.event) { e = window.event; }
	if (e.keyCode == 13)
    {
		return false;
	}
}


$(document).ready(function(){

    $('a[rel*=external]').attr('target','_blank');

	$('#calendar_div').html('<script type="text/javascript" src="calendar/tcal.js"></script><form action="" style="margin:0  !important;padding:0 !important"><div style="float:left;margin-left:10px;"><input type="text" name="date" class="tcal" id="tcalNewsDate" onkeypress="return archive_input(event)" size="28" value="'+full_date+'" /></div><div style="float:left"><img src="calendar/img/search.png" class="tcalIcon" id="archive_search_btn" onclick="getArchiveDate( \'' + varsayilan_dil + '\' )" alt="Ara" /></div><div style="display:block;clear:both"></div></form>')


});
