﻿
var holder = "ctl00_ContentPlaceHolder1_";
var GameMode = new Array(3);
var GameModeIdx = 0;
var GameMap = new Array(34);
var GameMapIdx = 12; //Marien
var Channel = new Array(3);
var ChannelIdx = 0;
var Round = new Array(5);
var RoundIdx = 4; //9 rounds
var Server = new Array(2);
var ServerIdx = 0;
var KillPoint = new Array(6);
var KillPointIdx = 0;
var MaxPlayer = new Array(6);
var MaxPlayerIdx = 0;
var MatchDate = new String();
var MatchTime = new String();
var MatchDateTime;

var ChannelMap = new Array(3);
var GameModeMap = new Array(3);
var ChannelMaxPlayer = new Array(3);
var ChannelGameMode = new Array(3);

var ChannelMapIdx = 0;
var ChannelGameModeIdx = 0;
var ChannelMaxPlayerIdx = 0;

var Text;
var Value;


function loadDefault(){
    
    GameMode[0] = new Info("Explosives",0)
    GameMode[1] = new Info("Deathmatch",2)
    GameMode[2] = new Info("Conquest",3)  
    
    Channel[0] = new Info("Close Combat",1)
    Channel[1] = new Info("Urban Ops",2)
    Channel[2] = new Info("Battle Group",3)
    
    GameMap[0] = new Info("Montana",0)
    GameMap[1] = new Info("Harbor IDA",1)
    GameMap[2] = new Info("Emblem",2)
    GameMap[3] = new Info("Havana",3)
    GameMap[4] = new Info("Ohara",4)
    GameMap[5] = new Info("Ravello",5)
    GameMap[6] = new Info("Ravello 2nd St",6)
    GameMap[7] = new Info("Engrene",7)
    GameMap[8] = new Info("Pargona",8)
    GameMap[9] = new Info("Pargona East",9)
    GameMap[10] = new Info("Harbor Elia",10)
    GameMap[11] = new Info("Conturas",11)
    GameMap[12] = new Info("Marien",12)
    GameMap[13] = new Info("Cadoro",13)
    GameMap[14] = new Info("Velruf",14)
    GameMap[15] = new Info("Xauen",15)
    GameMap[16] = new Info("Cantumira",16)
    GameMap[17] = new Info("Khyber",17)
    GameMap[18] = new Info("Zakhar",18)
    GameMap[19] = new Info("Karaqum",19)
    GameMap[20] = new Info("Alberon",20)
    GameMap[21] = new Info("Nerbil",21)
    GameMap[22] = new Info("Bloc",22)
    GameMap[23] = new Info("Khali",23)
    GameMap[24] = new Info("Thamugadi",24)
    GameMap[25] = new Info("Bandar",25)    
    GameMap[26] = new Info("Vitious",26)    
    GameMap[27] = new Info("Odyssey",27)
    GameMap[28] = new Info("Red Clover",28)
    GameMap[29] = new Info("Cold Cave",29)
    GameMap[30] = new Info("Rusty Nails",30)
    GameMap[31] = new Info("Cloud Forest",31)
    GameMap[32] = new Info("Crater",32)
    GameMap[33] = new Info("Blue Storm",33)
    
    
    Round[0] = new Info("Single Round",0)
    Round[1] = new Info("3 Rounds",1)
    Round[2] = new Info("5 Rounds",2)
    Round[3] = new Info("7 Rounds",3)
    Round[4] = new Info("9 Rounds",4)
    
    KillPoint[0] = new Info("30 Points",0)
    KillPoint[1] = new Info("50 Points",1)
    KillPoint[2] = new Info("100 Points",2)
    KillPoint[3] = new Info("150 Points",3)
    KillPoint[4] = new Info("200 Points",4)
    KillPoint[5] = new Info("300 Points",5)
    
    Server[0] = new Info("US Clan",61)
    Server[1] = new Info("EU Clan",62)
    
    MaxPlayer[0] = new Info("8",0)
    MaxPlayer[1] = new Info("10",5)
    MaxPlayer[2] = new Info("16",1)
    MaxPlayer[3] = new Info("20",2)
    MaxPlayer[4] = new Info("24",3)
    MaxPlayer[5] = new Info("32",4)
    
    ChannelMap[0] = new Array(12)
    ChannelMap[1] = new Array(12)
    ChannelMap[2] = new Array(11)    
    ChannelMap[0][0] = 13
    ChannelMap[0][1] = 19
    ChannelMap[0][2] = 17
    ChannelMap[0][3] = 12
    ChannelMap[0][4] = 14
    ChannelMap[0][5] = 15    
    ChannelMap[0][6] = 22 
    ChannelMap[0][7] = 23
    ChannelMap[0][8] = 28
    ChannelMap[0][9] = 29
    ChannelMap[0][10] = 30
    ChannelMap[0][11] = 33
    
    ChannelMap[1][0] = 20
    ChannelMap[1][1] = 16
    ChannelMap[1][2] = 2
    ChannelMap[1][3] = 10
    ChannelMap[1][4] = 1
    ChannelMap[1][5] = 3
    ChannelMap[1][6] = 0
    ChannelMap[1][7] = 21
    ChannelMap[1][8] = 5
    ChannelMap[1][9] = 6
    ChannelMap[1][10] = 18
    ChannelMap[1][11] = 31
    
    ChannelMap[2][0] = 16
    ChannelMap[2][1] = 11
    ChannelMap[2][2] = 2
    ChannelMap[2][3] = 7
    ChannelMap[2][4] = 3
    ChannelMap[2][5] = 4
    ChannelMap[2][6] = 8
    ChannelMap[2][7] = 9
    ChannelMap[2][8] = 24
    ChannelMap[2][9] = 25
    ChannelMap[2][10] = 32
    
    GameModeMap[0] = new Array(8)
    GameModeMap[1] = new Array(11)
    GameModeMap[2] = new Array(10)
    GameModeMap[0][0] = 13
    GameModeMap[0][1] = 19
    GameModeMap[0][2] = 17
    GameModeMap[0][3] = 12
    GameModeMap[0][4] = 14
    GameModeMap[0][5] = 15    
    GameModeMap[0][6] = 22 
    GameModeMap[0][7] = 23
    GameModeMap[0][8] = 28
    GameModeMap[0][9] = 29
    GameModeMap[1][0] = 20
    GameModeMap[1][1] = 16
    GameModeMap[1][2] = 2
    GameModeMap[1][3] = 10
    GameModeMap[1][4] = 1
    GameModeMap[1][5] = 3
    GameModeMap[1][6] = 0
    GameModeMap[1][7] = 21
    GameModeMap[1][8] = 5
    GameModeMap[1][9] = 6
    GameModeMap[1][10] = 18    
    GameModeMap[2][0] = 16
    GameModeMap[2][1] = 11
    GameModeMap[2][2] = 2
    GameModeMap[2][3] = 7
    GameModeMap[2][4] = 3
    GameModeMap[2][5] = 4
    GameModeMap[2][6] = 8
    GameModeMap[2][7] = 9
    GameModeMap[2][8] = 24
    GameModeMap[2][9] = 25
   
    
    ChannelMaxPlayer[0] = new Array(2)
    ChannelMaxPlayer[1] = new Array(5)
    ChannelMaxPlayer[2] = new Array(6)    
    ChannelMaxPlayer[0][0] = 0
    ChannelMaxPlayer[0][1] = 5
    ChannelMaxPlayer[0][2] = 1
    ChannelMaxPlayer[1][0] = 0
    ChannelMaxPlayer[1][1] = 5
    ChannelMaxPlayer[1][2] = 1
    ChannelMaxPlayer[1][3] = 2
    ChannelMaxPlayer[1][4] = 3    
    ChannelMaxPlayer[2][0] = 0
    ChannelMaxPlayer[2][1] = 5
    ChannelMaxPlayer[2][2] = 1
    ChannelMaxPlayer[2][3] = 2
    ChannelMaxPlayer[2][4] = 3
    ChannelMaxPlayer[2][5] = 4
    
    ChannelGameMode[0] = new Array(2)
    ChannelGameMode[1] = new Array(2)
    ChannelGameMode[2] = new Array(2)    
    ChannelGameMode[0][0] = 0 
    ChannelGameMode[0][1] = 2
    ChannelGameMode[1][0] = 2
    ChannelGameMode[1][1] = 3    
    ChannelGameMode[2][0] = 2
    ChannelGameMode[2][1] = 3
        
    MatchDate = document.getElementById(holder + "txtMatchDate").value;
    MatchTime = document.getElementById(holder + "txtMatchTime").value;
        
    LoadControls();
}

function OpenGMTConv(){
    
    if (document.getElementById(holder + "txtMatchDate") != null){
        MatchDate = document.getElementById(holder + "txtMatchDate").value;    
    }
    
     if (document.getElementById(holder + "txtMatchTime") != null){
        MatchTime = document.getElementById(holder + "txtMatchTime").value;
    }
    
    if (document.getElementById(holder + "lblMatchDate") != null){
        MatchDate = document.getElementById(holder + "lblMatchDate").innerHTML;    
    }
    
     if (document.getElementById(holder + "lblMatchTime") != null){
        MatchTime = document.getElementById(holder + "lblMatchTime").innerHTML;
    }
    
    
    if (MatchDate != null && MatchTime != null){
        
        var winl = (screen.width-720)/2;
        var wint = (screen.height-140)/2;    
        settings='height=140,width=360,top=' + wint + ',left=' + winl + ',scrollbars=0,statusbars=0,toolbars=0,resize=1';
        
        now = new Date();
        var offset = (now.getTimezoneOffset() / 60)*-1;
        
        window.open('GMTConv.aspx?offset=' + offset + '&dt=' + MatchDate + ' ' + MatchTime,"",settings)
               
    }
        
}

function LoadControls(){
    
    var img = new String();
    img = GameMap[GameMapIdx].Text;
    
    document.getElementById("divGameMap").innerHTML = GameMap[GameMapIdx].Text;
    document.getElementById("divGameMode").innerHTML = GameMode[GameModeIdx].Text;    
    document.getElementById("divMapImage").src = "/images/maps/" + img.replace(" ","_") + ".jpg";    
        
    document.getElementById("divChannel").innerHTML = Channel[ChannelIdx].Text;    
     
    //document.getElementById("divServer").innerHTML = Server[ServerIdx].Text;    
    document.getElementById("divMaxPlayers").innerHTML = MaxPlayer[MaxPlayerIdx].Text;    
    document.getElementById(holder + "txtMatchDate").value = MatchDate;
    document.getElementById(holder + "txtMatchTime").value = MatchTime;
        
    
    var maxp = parseInt(MaxPlayer[MaxPlayerIdx].Text)/2;
    var maxplrs = parseInt(MaxPlayer[MaxPlayer.length-1].Text)/2;  
    
    for (i=1;i<=maxp;i++){
        if (document.getElementById(holder + "svNiuPlayer" + i).value == '')
        {
            document.getElementById("ScrimSetupNiuPlayer" + i).innerHTML = "<a onclick=\"FillPlayerNiu(" + i + ")\">Insert Player</a>";
            document.getElementById(holder + "svNiuPlayer" + i).value = '';
        }
    }
    for (i=maxp+1;i<=maxplrs;i++){
        document.getElementById("ScrimSetupNiuPlayer" + i).innerHTML = '';
        document.getElementById(holder + "svNiuPlayer" + i).value = '';
    }
    
    if (GameModeIdx==0){
        document.getElementById("divKillPoints").innerHTML = '------';    
        KillPointIdx = 0;
        document.getElementById("divRounds").innerHTML = Round[RoundIdx].Text; 
    }
    else if (GameModeIdx==1){
        document.getElementById("divRounds").innerHTML = '------';
        RoundIdx = 0;    
        document.getElementById("divKillPoints").innerHTML = KillPoint[KillPointIdx].Text;   
    }
    else{
        document.getElementById("divKillPoints").innerHTML = '------';    
        document.getElementById("divRounds").innerHTML = '------';   
        KillPointIdx = 0;
        RoundIdx = 0;
    }
    
    
    enableCreateButton();
    
}

function enableCreateButton(){
 document.getElementById("btnCreateMatch").disabled = false;
}

function CreateMatch(){


    var url;
    var svNiuPlayers = '';
    var val;
    var scrimtype;
    var scrimtypevalue;
    var createconfirm = true;
    
    for (i=1;i<=32;i++){        
        val = document.getElementById(holder + "svNiuPlayer" + i);
        if (val != null && val.value != ''){
            svNiuPlayers += val.value + ",";
        }
    }
    
    
    scrimtype = document.getElementById("rdScrimTypeUnOff");
    
    if (scrimtype.checked)
        scrimtypevalue = "0";
    else
    {
        scrimtypevalue = "1";
        
    }
        LeftPosition = screen.width/2 - 80;
        TopPosition = screen.height/2 - 80;

        var newWin = window.open("","","top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=20,height=20");
                
        newWin.document.write("<html>");    
        newWin.document.write("<body style='margin:0'>");
        newWin.document.write("<form name=cm id=cm method=post action='CreateMatch.aspx'>");
        newWin.document.write("<input type=hidden name='svServer' value=\"" + Server[ServerIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svChannel' value=\"" + Channel[ChannelIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svGameMode' value=\"" + GameMode[GameModeIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svKillPoints' value=\"" + KillPoint[KillPointIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svRounds' value=\"" + Round[RoundIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svGameMap' value=\"" + GameMap[GameMapIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svMaxPlayers' value=\"" + MaxPlayer[MaxPlayerIdx].Value + "\">");
        newWin.document.write("<input type=hidden name='svMaxPlayerCount' value=\"" + MaxPlayer[MaxPlayerIdx].Text + "\">");
        newWin.document.write("<input type=hidden name='svDate' value=\"" + MatchDate + "\">");
        newWin.document.write("<input type=hidden name='svTime' value=\"" + MatchTime + "\">");
        newWin.document.write("<input type=hidden name='svAnsClanID' value=\"" + document.getElementById(holder + "svDerbaranClanID").value + "\">");    
        newWin.document.write("<input type=hidden name='svComments' value=\"" + document.getElementById("txtComments").value + "\">");
        newWin.document.write("<input type=hidden name='svMatchTitle' value=\"" + document.getElementById("txtMatchTitle").value + "\">");
        newWin.document.write("<input type=hidden name='svAutoConfirm' value=\"" + document.getElementById("chkAutoConfirm").checked + "\">");    
        newWin.document.write("<input type=hidden name='svScrimType' value=\"" + scrimtypevalue + "\">");
        newWin.document.write("<input type=hidden name='svNiuPlayers' value=\"" + svNiuPlayers + "\">");
        newWin.document.write("</form><script language='javascript'>document.cm.submit()</script></body></html>"); 
          
        if (!newWin) 
            alert("please allow pop up on this website");        
        
    
}

function AcceptMatch(){
    var url;
    var svDerbaranPlayers = '';
    var val;
    
    for (i=1;i<=32;i++){        
        val = document.getElementById(holder + "svDerbaranPlayer" + i);
        if (val != null && val.value != ''){
            svDerbaranPlayers += val.value + ",";
        }
    }
    
    
    LeftPosition = screen.width/2 - 20;
    TopPosition = screen.height/2 - 20;

    var newWin = window.open("","","top=" + TopPosition + ",left=" + LeftPosition + ",toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=20,height=20");
                 
    newWin.document.write("<html>");    
    newWin.document.write("<body>");
    newWin.document.write("<form name=cm id=cm method=post action='CreateMatch.aspx'>");      
    newWin.document.write("<input type=hidden name='svComments' value=\"" + document.getElementById("txtComments").value + "\">");    
    newWin.document.write("<input type=hidden name='svDerbaranPlayers' value=\"" + svDerbaranPlayers + "\">");    
    newWin.document.write("<input type=hidden name='svMaxPlayerCount' value=\"" + document.getElementById(holder + "lblMaxPlayer").innerHTML + "\">");
    newWin.document.write("<input type=hidden name='svScrimID' value='" + document.getElementById(holder + "svScrimID").value + "'>");
    newWin.document.write("</form><script language='javascript'>document.cm.submit();</script></body></html>");      
    
    if (!newWin) 
    alert("please allow pop up on this website");
}

function ChangeServer(action){
    
    ServerIdx = ServerIdx + action;
    
    if (ServerIdx >= Server.length)
        ServerIdx = 0;
    else if (ServerIdx < 0)
        ServerIdx = Server.length - 1;  
        
    LoadControls()    
}

function ChangeChannel(action){
    
    ChannelIdx = ChannelIdx + action;
    
    if (ChannelIdx >= Channel.length)
        ChannelIdx = 0;
    else if (ChannelIdx < 0)
        ChannelIdx = Channel.length - 1;  
    
    
    for (i=0;i<MaxPlayer.length;i++)
        if (MaxPlayer[i].Value == ChannelMaxPlayer[ChannelIdx][0])
            MaxPlayerIdx = i;    
    
    for (i=0;i<GameMode.length;i++){        
    if (GameMode[i].Value == ChannelGameMode[ChannelIdx][0])
            GameModeIdx = i; 
    }
        
            
     for (i=0;i<GameMap.length;i++)
        if (GameMap[i].Value == ChannelMap[ChannelIdx][0])
            GameMapIdx = i;         
    
    
    ChannelMapIdx = 0
    ChannelGameModeIdx = 0
    ChannelMaxPlayerIdx = 0
            
    LoadControls()    
}

function ChangeGameMode(action){
    
    ChannelGameModeIdx = ChannelGameModeIdx + action;    
        
    if (ChannelGameModeIdx >= ChannelGameMode[ChannelIdx].length)
        ChannelGameModeIdx = 0;
    else if (ChannelGameModeIdx < 0)
        ChannelGameModeIdx = ChannelGameMode[ChannelIdx].length - 1;  
    
    for (i=0;i<GameMode.length;i++){        
        if (GameMode[i].Value == ChannelGameMode[ChannelIdx][ChannelGameModeIdx]){
            GameModeIdx = i;    
        }      
    }
            
    LoadControls()    
}

function ChangeGameMap(action){
        
    ChannelMapIdx = ChannelMapIdx + action;    
        
    if (ChannelMapIdx >= ChannelMap[ChannelIdx].length)
        ChannelMapIdx = 0;
    else if (ChannelMapIdx < 0)
        ChannelMapIdx = ChannelMap[ChannelIdx].length - 1;  
    
    for (i=0;i<GameMap.length;i++){        
        if (GameMap[i].Value == ChannelMap[ChannelIdx][ChannelMapIdx]){
            GameMapIdx = i;    
        }
    }   
   
    
    LoadControls()    
    
}


function ChangeRound(action){
    
    RoundIdx = RoundIdx + action;
    
    if (RoundIdx >= Round.length)
        RoundIdx = 0;
    else if (ChannelIdx < 0)
        RoundIdx = Round.length - 1;  
        
    LoadControls()    
}

function ChangeKillPoint(action){
    
    KillPointIdx = KillPointIdx + action;
    
    if (KillPointIdx >= KillPoint.length)
        KillPointIdx = 0;
    else if (KillPointIdx < 0)
        KillPointIdx = KillPoint.length - 1;  
        
    LoadControls()    
}

function ChangeMaxPlayer(action){
    
    ChannelMaxPlayerIdx = ChannelMaxPlayerIdx + action;    
        
    if (ChannelMaxPlayerIdx >= ChannelMaxPlayer[ChannelIdx].length)
        ChannelMaxPlayerIdx = 0;
    else if (ChannelMaxPlayerIdx < 0)
        ChannelMaxPlayerIdx = ChannelMaxPlayer[ChannelIdx].length - 1;  
    
    for (i=0;i<MaxPlayer.length;i++){        
        if (MaxPlayer[i].Value == ChannelMaxPlayer[ChannelIdx][ChannelMaxPlayerIdx]){
            MaxPlayerIdx = i;    
        }
    }
        
    LoadControls()    
}

function ChangeMatchTime(action){
    
    var hour;
    var minute;
    var ampm;
    var day;
    var month;
    var year;
    
    var imin = action * 30
    
    MatchDateTime = new Date(MatchDate + ' ' + MatchTime);
        
    MatchDateTime.setMinutes(MatchDateTime.getMinutes() + imin);
    
    
    hour = MatchDateTime.getHours();
        
    if (hour >= 12 )
    {   
        if (hour > 12)
            hour = hour - 12
        ampm = 'PM';
        }    
    else
    {        
        ampm = 'AM';
    }   
    
    minute = MatchDateTime.getMinutes();
    
    
    if (minute == 0)
        minute = "00";
    else
        minute = "30";
    
    if (hour < 10)
        hour = "0" + hour;
    
    day = MatchDateTime.getDate();
    month = MatchDateTime.getMonth()+1;
    year = MatchDateTime.getFullYear();
    
    MatchDate = month + "/" + day + "/" + year;
    MatchTime = hour + ":" + minute + " " + ampm;
        
    
    LoadControls();    
        
}

function ChangeMatchDate(action){
    
    var day;
    var month;
    var year;
    
    MatchDateTime = new Date(MatchDate + ' ' + MatchTime);
    
    MatchDateTime.setDate(MatchDateTime.getDate() + action);
    
    day = MatchDateTime.getDate();
    month = MatchDateTime.getMonth()+1;
    year = MatchDateTime.getFullYear();
    MatchDate = month + "/" + day + "/" + year;
    
    LoadControls();
}


function ChangeGuestClan(){
        
   var c = document.getElementById(holder + "svDerbaranClanID").value;
   var cn = document.getElementById(holder + "lblDerbaranClan").innerHTML;
   var pop = false;
   
   if (c != ''){
        pop = confirm('Do you want to remove ' + cn + '?');
        if (pop){
            document.getElementById(holder + "imgDebaranAvatar").src = "/images/openchallenge.jpg";    
            document.getElementById(holder + "svDerbaranClanID").value = '';
            document.getElementById(holder + "lblDerbaranClan").innerHTML = '';
        }
   }
   
       
        
   if (!pop){
       var newWin = window.open("ClanDirectory.aspx?fcl=1","Search","width=950,height=570,toolbars=0,status=1,scrollbars=1,resizable=1");
            
            if (!newWin) 
                alert("please allow pop up on this website");
   }
   
        
   
    
}

function ChallengeClan(clanID,clanName){

        opener.document.getElementById(holder + "imgDebaranAvatar").src = "http://avatar.warrock.net/" + clanID + ".jpg";    
        opener.document.getElementById(holder + "svDerbaranClanID").value = clanID;
        opener.document.getElementById(holder + "lblDerbaranClan").innerHTML = clanName;
        self.close();
    } 



var PlayerDivx;

function FillPlayerNiu(div){
    PlayerDivx = div;
    document.getElementById("ScrimSetupRoster").style.display = "block";
    
}

function FillPlayerDerbaran(div){
    PlayerDivx = div;
    document.getElementById("ScrimSetupRoster").style.display = "block";
    
}

function FillPlayer(div){
    PlayerDivx = div;
    document.getElementById("ScrimSetupRoster").style.display = "block";
    
}

function LoadDerbaranSpots(){

    var maxp = parseInt(document.getElementById(holder + "lblMaxPlayer").innerHTML)/2;
    
    for (i=1;i<=maxp;i++){
        if (document.getElementById(holder + "svDerbaranPlayer" + i).value == '')
        {
            document.getElementById("ScrimSetupDerbaranPlayer" + i).innerHTML = "<a onclick=\"FillPlayerDerbaran(" + i + ")\">Insert Player</a>";
            document.getElementById(holder + "svDerbaranPlayer" + i).value = '';
        }
    }
}

function ChoosePlayerDerbaran(id,name,level){
    var cname;
    var valid = 1;
    var maxps = 16;
    
    var extid;
    
     if (level < 0)
    {
        alert(name + ' needs to be level 11 or higher');
        return false;
    }
    
    for (i = 1;i<=maxps;i++){
        
        extid = document.getElementById(holder + "svDerbaranPlayer" + i).value
        
        if (extid == id){
            valid = 0;
            alert(name + ' is already in the list');
        }
    }
    
    if (valid == 1){
        cname = "<a onclick=\"FillPlayerDerbaran('" + PlayerDivx + "')\"><font color=yellow>" + name + "</font></a>";
        document.getElementById('ScrimSetupDerbaranPlayer' + PlayerDivx).innerHTML = cname;
        
        document.getElementById(holder + "svDerbaranPlayer" + PlayerDivx).value = id;
        CloseDiv('ScrimSetupRoster');
    }
    
}

function ChoosePlayer(id,name,level){
    var cname;
    var valid = 1;
    var maxps = 16;    
    var extid;
        
    if (level < 0)
    {
        alert(name + ' needs to be level 11 or higher');
        return false;
    }
    
    for (i = 1;i<=maxps;i++){
        
        extid = document.getElementById("svPlayer" + i).value
        
        if (extid == id){
            valid = 0;
            alert(name + ' is already in the list');
        }
    }
    
    if (valid == 1){
        cname = "<a onclick=\"FillPlayer('" + PlayerDivx + "')\"><font color=yellow>" + name + "</font></a>";
        document.getElementById('ScrimSetupPlayer' + PlayerDivx).innerHTML = cname;
        
        document.getElementById(holder + "svPlayer" + PlayerDivx).value = id;
        CloseDiv('ScrimSetupRoster');
    }
    
}

function ChoosePlayerNiu(id,name,level){
    var cname;
    var valid = 1;
    var maxps = parseInt(MaxPlayer[MaxPlayer.length-1].Text) / 2;
    
    var extid;
    
     if (level < 0)
    {
        alert(name + ' needs to be level 11 or higher');
        return false;
    }
    
    for (i = 1;i<=maxps;i++){
        
        extid = document.getElementById(holder + "svNiuPlayer" + i).value
        
        if (extid == id){
            valid = 0;
            alert(name + ' is already in the list');
        }
    }
    
    if (valid == 1){
        cname = "<a onclick=\"FillPlayerNiu('" + PlayerDivx + "')\"><font color=yellow>" + name + "</font></a>";
        document.getElementById('ScrimSetupNiuPlayer' + PlayerDivx).innerHTML = cname;
        
        document.getElementById(holder + "svNiuPlayer" + PlayerDivx).value = id;
        CloseDiv('ScrimSetupRoster');
    }
    
}

function Info(t, v){ 
 this.Text = t; 
 this.Value = v; 
}

function setCalendar2(){
Calendar.setup({inputField:'ctl00_ContentPlaceHolder1_txtDateMatch',ifFormat: '%m/%d/%Y',button:''});
}

function GetScrimResponse(){
     
    var Ajax = new GetScrimMatchResponse('clanid=' + this.clanID);
    Ajax.SendRequest();
	
	setTimeout("GetScrimResponse()",5000);
	
}
var clanID;

function GetScrimMatchResponse(querystring)
{
    
    this.querystring = querystring;
    var me = this;    
    this.SendRequest = function()
    {
		var xmlHttpReq = false;
        var ajaxcall = new BaseAjaxUpdater();        
        // Mozilla/Safari
        if (window.XMLHttpRequest) {
            ajaxcall.xmlHttpReq = new XMLHttpRequest();
        }
        // IE
        else if (window.ActiveXObject) {
            ajaxcall.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
        ajaxcall.xmlHttpReq.open('POST', "ScrimAlert.aspx", true);
        ajaxcall.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        ajaxcall.xmlHttpReq.onreadystatechange = function() {
            if (ajaxcall.xmlHttpReq.readyState == 4) {
                if (ajaxcall.xmlHttpReq.status == 200)
                {                    
                    document.getElementById("MatchContent").innerHTML = ajaxcall.xmlHttpReq.responseText;
                }
            }
        }
        
        ajaxcall.xmlHttpReq.send(me.querystring);
    }
    
}

function BaseAjaxUpdater() 
 { 
     this.xmlHttpReq = null; 
 }
 
