﻿function $(id)
{
    return document.getElementById(id);
}

var statics = {
    newsImageURLPrefix : null,
    imageURL : null,
    appRoot : null,
    loadReferees : null
};

function openWin(strURL, arg1, arg2, arg3)
{
		var argLen = arguments.length;
		var intX,intY,strUrl;
		if(argLen < 3){
			intX = '780';
			intY = '550';
		}else{
			intX = arg2;
			intY = arg3;
		}

		oWin = window.open ( strURL, arg1, "toolbar=no, menubar=no, location=no, status=no, width=" + intX + ", height=" + intY + ",left=0, top=0, scrollbars=yes, resizable=yes");
		if(oWin){
		    oWin.focus();
		}
}


function validateNum(Num) {
	var CharSet = "0123456789"
	var temp = ""
	for (var i=0; i<Num.length; i++) {
			temp = "" + Num.substring(i, i+1)
			if (CharSet.indexOf(temp) == "-1") OK = "0"
	}
}

	

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;
}

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");
}


function radioIsChecked(obj){
	for(var i=0;i<obj.length;i++)
	{
		if(obj[i].checked){
   			return true;
		}
	}
	return false;
}
function getRadioValue(obj){
	for(var i=0;i<obj.length;i++)
	{
		if(obj[i].checked){
   			return obj[i].value;
		}
	}
	return null;
}
function showPlayer(playerId)
{
    openWin("Player.aspx?id=" + playerId, "Player" + playerId, '410', '350' );
}

function doVote(){
    var f = document.forms.aspnetForm;
    if(!radioIsChecked(f.rdPollChoices)){
        alert("Önce seçim yapınız!");
    }else{
        if(f.hdnPollType.value == "1"){
            if(getCookie("TSLPOLL-"+f.hdnPollID.value)){
                alert("Bu ankete daha önce katılmışsınız. Tekrar oy kullanamazsınız.")
                openWin(statics.appRoot + "/UI/UpdatePoll.aspx?P="+f.hdnPollID.value,'vr',270,400);
            }else{
                var expiration = new Date();
	            expiration.setTime(expiration.getTime() + (  365 * 24 * 60 * 60 * 1000)); 
	            setCookie("TSLPOLL-" + f.hdnPollID.value,f.hdnPollID.value,expiration);					            
	            openWin(statics.appRoot + "/UI/UpdatePoll.aspx?C="+getRadioValue(f.rdPollChoices)+"&P="+f.hdnPollID.value,'vr',270,400);
            }
        }else{
            openWin(statics.appRoot + "/UI/UpdatePoll.aspx?C="+getRadioValue(f.rdPollChoices)+"&P="+f.hdnPollID.value,'vr',270,400);
        }
        
    }
}

function Void(i) {
}

function openSFWin(id)
{
		oWin = window.open ( "SendToFriend.aspx?id="+id, "sm", "toolbar=no, menubar=no, location=no, status=no, width=300, height=200,left=0, top=0, scrollbars=no, resizable=yes");
		if(oWin){
		    oWin.focus();
		}
}
