﻿function LoadCss(parMacCss,parCss)
{
     var fileref=document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        
        if(navigator.userAgent.indexOf("Macintosh") != -1)
        {
            fileref.setAttribute("href", parMacCss)
        }
        else
        {
            fileref.setAttribute("href", parCss)
        }
        if (typeof fileref!="undefined")
            document.getElementsByTagName("head")[0].appendChild(fileref)
}

window.onload = function ()
{
setInterval('blinkIt()',500);
}

 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 LoadMultiCss(parMacCss,parCssArray)
{ 
     var paramArray = parCssArray.split(",");  
     for(var i=0; i<paramArray.length; i++)
     {
        var fileref=document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        
        if(navigator.userAgent.indexOf("Macintosh") != -1)
        {
            fileref.setAttribute("href", parMacCss)
        }

        fileref.setAttribute("href", paramArray[i])
        if (typeof fileref!="undefined")
            document.getElementsByTagName("head")[0].appendChild(fileref)
     }
}



function OpenPopup(pageLink,width,height,positionTop,positionLeft,parUseScrollBar) 
{
    popupWin=window.open(pageLink,'myNewWin','menubar=1,resizable=1,width='+width+',height='+height+',top='+positionTop+',left='+positionLeft+',scrollbars='+parUseScrollBar)
    return popupWin;
}

function NewWindow(Sayfa,En,Boy) {
	window.open(Sayfa, 'Baslik', "height="+Boy+",width="+En+",top=200,left=200,status=yes,toolbar=no,menubar=no,location=no,scrollbars=no");
}
function ShowCompetitionBanner(parContainerName,parPoint,isMemberLogin,parUrl)
{
     htmlHolder = "<div class='MG_mB2 MG_okuKazan2'><div class='MG_oKBos'><a href='";
      if( isMemberLogin )
        htmlHolder += parUrl+"Member.aspx?hCase=EarnPoint";
        else
            htmlHolder += parUrl+"/Default.aspx?aType=Login";
    htmlHolder +="'><img src='/D/i/1/bos.gif' width='207' height='250' border='0' alt='' /></a></div><div style='position:absolute; margin:30px 0 0 13px; z-index:2'><p style='font-size:26px; font-weight:bold; color:#df0000; margin:0 0 0 -1px; text-align:center;'>"+parPoint+"</p></div><div style='clear:'></div></div>";
    document.getElementById(parContainerName).innerHTML = htmlHolder;
}
function ShowCompetitionPoint(parContainerName,parPoint)
{
    if(document.getElementById(parContainerName))
        document.getElementById(parContainerName).innerHTML = parPoint;
}
function IsMailValid(value)
{
    var x = value;
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(x))
        return false;
    else
        return true;
}

function GetbyAttr ( name, tag ) {
    var results = new Array();
    var elems = document.getElementsByTagName("*");
    var len = elems.length;

    if (name == "class") {
        for (var i = 0; i < len; i++) {
            if (elems[i].className) {                  
                results.push(elems[i]);
            }
        }
        return results;
    } else if (name == "for" && document.all) {
        name = "htmlFor";
    }

    for (var i = 0; i < len; i++) {
        if (elems[i].getAttribute(name)) {
            results.push(elems[i]);
        }
    }
    return results;
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
function wordwrap(parString,parCharAmount)
{
    html = "";
	pointer = 0;
	index = -1;
	TotalCharAmount = parString.length;
	    while (pointer < TotalCharAmount )
	    {
		    index = (parString.substring(pointer,parCharAmount+pointer)).indexOf(' ');
		    if(index != -1 || parString.substring(pointer,parCharAmount+pointer).length != parCharAmount)// boşluk varsa
		    {
                if(parString.substring(pointer,parCharAmount+pointer).length != parCharAmount)
                {
                    html += parString.substring(pointer,parCharAmount+pointer);
                    pointer = TotalCharAmount;
                }
                else
                {
                    html += parString.substring(pointer,index+1+pointer);
		            pointer = pointer+index+1;
		        }
		        
	        }
	        else
	        {
		        html+= "<div>";
		        html+= parString.substring(pointer,parCharAmount+pointer);
		        html += "</div>";
		        pointer = pointer+parCharAmount;
	        }
	}
	    return html;
}

function ModalAc(Sayfa,En,Boy) {
	window.showModalDialog(Sayfa, "", "dialogHeight:"+Boy+"px; dialogWidth:"+En+"px;help:no;scroll:yes");
}

function SetCookie(name,value,minute)
{
var expire = "";
expire = new Date((new Date()).getTime() + minute * 60000);
expire = "; expires=" + expire.toGMTString();
document.cookie = name + "=" + escape(value) + expire;
return true;
}

function GetCookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;

	for ( i = 0; i < a_all_cookies.length; i++ )
	{   a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{return null;}
}

function Delete_Cookie( name, path, domain ) 
{
if ( GetCookie( name ) ) 
    document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function GetOldAuthorsList()
{
    var requestUrl = "/D/Api/GenericList.ashx";
    CreateXmlHttp();
     
    // If browser supports XMLHTTPRequest object
    if(XmlHttp)
    {
        //Setting the event handler for the response
        XmlHttp.onreadystatechange = WriteToPage;

        //Initializes the request object with GET (METHOD of posting), 
        //Request URL and sets the request as asynchronous.
        XmlHttp.open("GET", requestUrl,  true);

        //Sends the request to server
        XmlHttp.send(null);  
    }
}

 function WriteToPage()
 {
    if(XmlHttp.readyState == 4)
     {
        // To make sure valid response is received from the server, 
        // 200 means response received is OK
        if(XmlHttp.status == 200)
        {  
            document.getElementById('HiddenComp').value = XmlHttp.responseText;
            
            $(document).ready (function()
                {
                       dhtmlLoadScript("/D/scripts/v_newsticker_3.js"); 
                }
            );
        }
        else
        {
            alert("There was a problem retrieving data from the server." );
        }
     }
 }

//Creating and setting the instance of appropriate XMLHTTP Request object to 
//a "XmlHttp" variable  
function CreateXmlHttp()
{
    //Creating object of XMLHTTP in IE
    try
    {
        XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch(oc)
        {
            XmlHttp = null;
        }
    }
    //Creating object of XMLHTTP in Mozilla and Safari 
    if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
    {
        XmlHttp = new XMLHttpRequest();
    }
}

function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e); 
}

function ArticleRating(ArticleID,RatingType)
{
    x='True';
    if(RatingType==0){
        x='False';
    }
    $.post('/D/Handler.aspx?hCase=Article'+x+'&ArticleID='+ArticleID,function(resp){
        var data = JSON.parse(resp);
        //alert(data.data);
        dataSplit= data.data.split("|")
        //debugger;

        $('#RatingTrueValue')[0].innerHTML='0';
        $('#RatingFalseValue')[0].innerHTML='0';

        $('#RatingTrueValue')[0].innerHTML=dataSplit[1];
        $('#RatingFalseValue')[0].innerHTML=dataSplit[2];

        if(dataSplit[0]==1){
            //$('#pVideoMessage').hidden();
            $('#pVideoMessage')[0].innerHTML="Oyunuzu kullandınız";
            $('#pVideoMessage').show();
        }else{
            $('#pVideoMessage')[0].innerHTML="Bir haber için sadece bir kez oy kullanabilirsiniz";
            $('#pVideoMessage').show();
        }
    });
}

function CommentRating(commentID, isPositive, position) {

    $.getJSON("/D/Handler.aspx",
        { hCase: 'VoteComment',
            CommentID: commentID,
            IsPositive: isPositive
        },
        function(data) {
            if (data != null) {
                $('#aVotePositive' + position).text(data.pvote);
                $('#aVoteNegative' + position).text(data.nvote);
                $('#pVoteMessage' + position).text(data.msg);
                $('#pVoteMessage' + position).show();
            }
        });
    return false;
}

/*+ Date functions  +*/
Date.prototype.toStringTr = function() {
    var strDate = '0' + this.getDate().toString();
    var strMonth = '0' + (this.getMonth() + 1).toString();
    return strDate.substr(strDate.length - 2) + '.' + strMonth.slice(strMonth.length - 2) + '.' + this.getFullYear().toString();
};

Date.prototype.toStringPath = function() {
    return this.getFullYear().toString() + '/' + (this.getMonth() + 1).toString() + '/' + this.getDate().toString();
};

function CreateDate(dateStr) {
    var objDate = null;
    var dateformat = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
    if (dateformat.test(dateStr) == true) {
        var parts = dateStr.split(RegExp.$1);
        var dd = parts[0];
        var mm = parts[1];
        var yy = parts[2];
        var dt = new Date(parseFloat(yy), parseFloat(mm) - 1, parseFloat(dd), 0, 0, 0, 0);
        if (parseFloat(dd) == dt.getDate() && parseFloat(mm) - 1 == dt.getMonth())
        { objDate = dt; }
    }
    return objDate;
}
/*- Date functions  -*/