function doTooltip(e, ar) {
    if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
    var cntnt = wrapTipContent(ar);
    var tip = document.getElementById( Tooltip.tipID );
    Tooltip.show(e, cntnt);
}

function hideTip() {
    if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
    Tooltip.hide();
}

function wrapTipContent(ar) {
    var cntnt = "";
    if ( ar[0] ) cntnt += '<div class="img"><img src="' + ar[0] + '"></div>';
    if ( ar[1] ) cntnt += '<div class="txt">' + ar[1] + '</div>';
    return cntnt;
}

function isInternetExplorer()
{
	if (navigator.appName == "Microsoft Internet Explorer")
		return true;
	else
		return false;
}

function OpenURL(theURL, winName, features) 
{ 
	if (isInternetExplorer())
		wnd = window.open(theURL, winName, features);
	else
	{
		if (theURL.indexOf("http") < 0 )
		{
			base = location.href.substring(0,location.href.lastIndexOf('\/'));
			wnd = window.open(base + "/" + theURL, winName, features);
		}
		else
			wnd = window.open(theURL, winName, features);
	}
		
    if (wnd != null)
    {
		try{wnd.focus();}catch(ex){}		
	}
	else
		alert('Görüntüleme penceresi açılamadı. Lütfen pop-up engelleyicilerinizin ayarlarını kontrol ediniz.');
}

function OpenURL_Photo(theURL) 
{ 
    OpenURL(theURL, 'photo', 'status=0,scrollbars=1,menubar=0,resizable=1,width=950,height=650');
}

function OpenExternalURL(url)
{
    window.open(url);
}

function gotoURL(url)
{
    document.location.href = url;
}

function gotoURL_Delayed(url, secs)
{
    var timer=setTimeout("gotoURL('" + url + "')",secs*1000);
}

function OpenLegalWindow(url)
{
    OpenURL(url, 'legal', 'status=0,scrollbars=1,menubar=0,resizable=1,width=800,height=600');
}

function elementPosition(obj) {
        var curleft = 0, curtop = 0;

        if (obj.offsetParent) {
            curleft = obj.offsetLeft;
            curtop = obj.offsetTop;

            while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
            }
        }

        //return { x: curleft - document.documentElement.scrollLeft , y: curtop - document.documentElement.scrollTop };
        return { x: curleft , y: curtop };
    }
    
function DecodeTurkishCharacters(str)
{
	str = replaceAll(str, "&#305;", String.fromCharCode(305)); //str = replaceAll(str, 'ı', '~0');
	str = replaceAll(str, "&#351;", String.fromCharCode(351)); //str = replaceAll(str, 'ş', '~1');
	str = replaceAll(str, "&#231;", String.fromCharCode(231)); //'ç'
	str = replaceAll(str, "&#287;", String.fromCharCode(287)); ////str = replaceAll(str, 'ğ', '~3');
	str = replaceAll(str, "&#246;", String.fromCharCode(246)); ////str = replaceAll(str, 'ö', '~4');
	str = replaceAll(str, "&#252;", String.fromCharCode(252)); ////str = replaceAll(str, 'ü', '~5');
	str = replaceAll(str, "&#304;", String.fromCharCode(304)); ////str = replaceAll(str, 'İ', '~6');
	str = replaceAll(str, "&#350;", String.fromCharCode(350)); ////str = replaceAll(str, 'Ş', '~7');
	str = replaceAll(str, "&#199;", String.fromCharCode(199)); ////str = replaceAll(str, 'Ç', '~8');
	str = replaceAll(str, "&#286;", String.fromCharCode(286)); ////str = replaceAll(str, 'Ğ', '~9');
	str = replaceAll(str, "&#214;", String.fromCharCode(214)); ////str = replaceAll(str, 'Ö', '~A~');
	str = replaceAll(str, "&#220;", String.fromCharCode(220)); ////str = replaceAll(str, 'Ü', '~B~');
	
	return str;
}

function replaceAll(oldStr,findStr,repStr) 
{
	try
	{
		var srchNdx = 0;  
		var newStr = "";  
		while (oldStr.indexOf(findStr,srchNdx) != -1)  
		{
		newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
		newStr += repStr;
		srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
		}
		newStr += oldStr.substring(srchNdx,oldStr.length);
		return newStr;
	}
	catch(ex)
	{
		return oldStr;
	}
}

function createCookie (name, value, days) 
{
	try
	{
		var expires = new Date();
		expires.setTime(expires.getTime()+(days*24*60*60*1000));
		var secure = true;
		document.cookie = name + "=" + (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) ;
	}
	catch(ex) {}
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
