function parseFloat2(str){
    if (str.length==0)
        return 0;
    if (parseFloat("4,5")==4)
        str=str.replace(",",".");

    f=parseFloat(str);
    return f;
}

function popMatch(id) {
    window.open(APP_ROOT + '/Match/Default.aspx?id=' + id, 'match_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function iPopMatch(id){
    window.open(APP_ROOT + '/iMatch.aspx?id=' + id, 'match_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function iPopLeague(id){
    window.open(APP_ROOT +'/Standing.aspx?id=' + id);
}
function popBasketMatch(id) {
    window.open(APP_ROOT + '/Basketball/Match/BasketMatch.aspx?id=' + id, 'bmatch_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popTeam(id, season) {
    window.open(APP_ROOT + '/Team/Default.aspx?id=' + id + (season ? "&season=" + encodeURIComponent(season) : ""), 'team_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popTeamTab(id, season, tab) {
    window.open(APP_ROOT + '/Team/Default.aspx?id=' + id + (season ? "&season=" + encodeURIComponent(season) : "") + "&tab=" + tab, 'team_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popBasketTeam(id){
    window.open(APP_ROOT + '/Basketball/Team/Default.aspx?id=' + id, 'bteam_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popVolleyTeam(id){
    window.open(APP_ROOT + '/Volleyball/Team/Default.aspx?id=' + id, 'vteam_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popVolleyMatch(id) {
    window.open(APP_ROOT + '/Volleyball/Match/VolleyMatch.aspx?id=' + id, 'vmatch_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popLeague(id){
    window.open(APP_ROOT + '/National/Default.aspx?id=' + id, 'league_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
function popBasketLeague(id) {
    window.open(APP_ROOT + '/National/Default.aspx?id=' + id, 'bleague_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popLeagueSeason(id) {
    window.open(APP_ROOT + '/National/Default.aspx?sId=' + id, 'sleague_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popF1Driver(id) {
    window.open(APP_ROOT + '/F1/Driver/Default.aspx?id=' + id, 'f1D_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popF1Team(id) {
    window.open(APP_ROOT + '/F1/Team/Default.aspx?id=' + id, 'f1T_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popF1Race(id) {
    window.open(APP_ROOT + '/F1/Results/Default.aspx?id=' + id, 'f1R_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popAnket(id) {
    window.open(APP_ROOT + '/Anket/Default.aspx?id=' + id, 'poll_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}
 
function popLeagueNews(id) {
    window.open(APP_ROOT + '/National/Default.aspx?id=' + id + '&tab=5', 'league_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popLeagueForum(id) {
    window.open(USR_APP_ROOT + '/ForumDetails/Default.aspx?type=6&tId=' + id, 'league_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popStatistics(id) {
    window.open(APP_ROOT + '/National/Default.aspx?id=' + id + '&tab=3', 'league_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popPlayer(id){
    window.open(APP_ROOT + '/Player/Default.aspx?id=' + id, 'player_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popManager(id){
    window.open(APP_ROOT + '/Manager/Default.aspx?id=' + id, 'manager_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popComparison(id) {
    window.open(APP_ROOT + '/Comparison/Default.aspx?id=' + id, 'comparison_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popBasketComparison(id) {
    window.open(APP_ROOT + '/Basketball/Comparison/Default.aspx?id=' + id, 'bcomparison_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popReferee(id){
    window.open(APP_ROOT + '/Referee/Default.aspx?id=' + id, 'referee_' + id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popBasketLeague(id){
    window.open(APP_ROOT+'/Basketball/Standing/Default.aspx?id=' + id, 'bleague_'+id, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popBasketLeagueSeason(sid) {
    window.open(APP_ROOT + '/Basketball/Standing/Default.aspx?sId=' + sid, 'bleague_' + sid, 'width=1024,height=768,resizable=yes,scrollbars=yes');
}

function popVolleyLeagueSeason(sid) {
    window.open(APP_ROOT + '/Volleyball/Standing/Default.aspx?sId=' + sid);
}

function popCoupon(param, user, width, height) {
    window.open(USR_APP_ROOT+'/Bilyoner/CouponStats/Coupon.aspx?' + param, user, 'toolbar=0,menubar=0,resizable=1,scrollbars=1,width=' + width + ',height=' + height);
}

function popCouponDetail(param, user, width, height){
    window.open(USR_APP_ROOT+'/Bilyoner/CouponStats/CouponDetail.aspx?' + param, user, 'toolbar=0,menubar=0,resizable=1,scrollbars=1,width=' + width + ',height=' + height);
}

function  block(BlockDiv) {
    BlockDiv.style.border = "medium none";
    BlockDiv.style.margin = 0;
    BlockDiv.style.padding = 0;
    BlockDiv.style.zIndex = 1000;
    BlockDiv.style.cursor = "wait";
    BlockDiv.style.width = "100%"; 
    BlockDiv.style.height = "100%";
    BlockDiv.style.top = 0;
    BlockDiv.style.left = 0;
    BlockDiv.style.backgroundColor = "#000000";
    BlockDiv.style.opacity = 0.5;
}
function fadeIn(element) {
    //element.appendChild(BlockDiv);    
//    var iTime = setInterval ( opac, 50);
//    function opac() {
//        var wrapper = element;
//        if (parseFloat(wrapper.style.opacity) < 1.0) {
//            wrapper.style.opacity = parseFloat(wrapper.style.opacity) + 0.1;
//            wrapper.style.filter = "alpha(opacity="+ parseInt(parseFloat(wrapper.style.opacity) * 100) +");";
//        } else {
//            clearInterval (iTime);
//        }
//    }        
}

function fadeOut(element) {
//    element.style.opacity = 0;
//    element.style.filter ="alpha(opacity=0)";
}

var SortedColumn = {
    writeHTML : function(column, sort){
        document.write('<table><tr><td>'+column+'</td><td><table><tr><td><img height="5" width="9" src="/images/sort_up.gif" onclick="sortIt('+sort+',0);"/></td><td><img height="5" width="9" src="/images/sort_down.gif"/ onclick="sortIt('+sort+',1);"></td></tr></table></td></tr></table>');
    }
}

    function submitenter(myfield,e)
    {
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        else return true;

        if (keycode == 13) {
            myfield.form.submit();
            return false;
        } else
            return true;
    }
    //    var AjaxCallback=function(successFunction,argumentArray){this.success=function(response){if(successFunction){successFunction(response);}};this.failure=function(response){alert(response.responseText)};this.argument=argumentArray;}

    var StringBuilder = function() {
        this._strings = [];
        this.append = function(s) { this._strings.push(s); };
        this.toString = function() { return this._strings.join(''); };
        this.appendFormat = function(pattern) {
            var args = arguments;
            var s = pattern.replace(/\{(\d+)\}/g,
                function(pattern, index) {
                    return args[parseInt(index) + 1].toString();
                });
            this._strings.push(s);
        };
        return this;
    };
    
function getCookie(name) {
	var cname = name + "=";
	var dc = document.cookie;
	
	if (dc.length > 0) {
		begin = dc.indexOf(cname);
		if (begin != -1) {
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
				return unescape(dc.substring(begin, end));
		}
	}
	return null;
}
//Set Cookie Function
function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) + 
	((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
	((path == null) ? "" : "; path=" + path) +
	((domain == null) ? "" : "; domain=" + domain) +
	((secure == null) ? "" : "; secure");
}

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

Array.prototype.contains = function(obj) {
    var len = this.length;
    for (var i = 0; i < len; i++) {
        if (this[i] === obj) { return true; }
    }
    return false;
};

Array.prototype.containsProperty = function(obj, prop) {
    var len = this.length;
    for (var i = 0; i < len; i++) {
        if (this[i][prop] === obj) { return true; }
    }
    return false;
};


function highlight(obj) {
    var HIGH_COLOR = "#e7e77f";
    if (obj.style.backgroundColor == "") {
        obj.style.backgroundColor = HIGH_COLOR;
    } else {
        obj.style.backgroundColor = "";
    }
}

function blinkIt() {
    if (!document.all) return;
    else {
        var elements = document.getElementsByTagName('blink');
        for(i=0, n = elements.length; i < n; i++){
            s = elements[i];
            s.style.color=(s.style.color=='#090')?'#f0f0f4':'#090';
        }
    }
}

function replaceTurkish(str) {
    return str.replace("Ç", "C").replace("İ", "I").replace("Ü", "U").replace("Ö", "O").replace("Ş", "S");
}

String.ScriptFragment = '<script[^>]*>([\\S\\s]*?)<\/script>';

Array.prototype.map = function(fnc) {
    var a = new Array(this.length);
    for (var i = 0; i < this.length; i++) {
        a[i] = fnc(this[i]);
    }
    return a;
}

String.prototype.extractScripts = function() {
    var matchAll = new RegExp(String.ScriptFragment, 'img');
    var matchOne = new RegExp(String.ScriptFragment, 'im');
    return (this.match(matchAll) || []).map(function(scriptTag) {
      return (scriptTag.match(matchOne) || ['', ''])[1];
    });
};

String.prototype.evalScripts = function() {
    return this.extractScripts().map(function(script) { return eval(script) });
};

function isToday(strDate) {
    var dtToday = new Date();
    var dtCh = "/";
    var pos1 = strDate.indexOf(dtCh);
    var pos2 = strDate.indexOf(dtCh, pos1 + 1);
    var strDay = strDate.substring(0, pos1);
    var strMonth = strDate.substring(pos1 + 1, pos2);
    var strYear = strDate.substring(pos2 + 1);

    if (parseInt(strDay) != dtToday.getDate()) {
        return false;
    }
    if (parseInt(strMonth) != dtToday.getMonth() + 1) {
        return false;
    }
    if (parseInt(strYear) != dtToday.getFullYear()) {
        return false;
    }
    return true;
}
