//
// CH 04/04/08 - V1719 SilentWorld ASP.NET AJAX Implementation 04/04/08
// CH 07/04/08 - Added Password, PasswordConfirmed, Email, EmailConfirmed in RegisterType enum
//
//VAIRBALES

var tempLeague;
var failedVal;
var tempItem;
var mSize;
var failedVer = false;
var lastValidatedObject;
var shrinkingDiv;

//CREATE ENUMS
RegisterType = function(){};
RegisterType.prototype = 
{
    TextBox:    	0,
    DropDown:   	1,
    DOB:        	2,
    Username:   	3,
    Email:   		4,
    EmailConfirmed: 	5,
    Password:	 	6,
    PasswordConfirmed: 	7
}
ModeSize = function(){};
ModeSize.prototype = 
{
    Big:    0,
    Small:  1,
    Icon:   2
}
LoaderSize = function(){};
LoaderSize.prototype = 
{
    Big:    0,
    Small:  1
}

window.onload=function()
{
	//SET ON LOAD , ADD EVENT HANDLERS FOR PAGE
    	RegisterType.registerEnum("RegisterType", true);
	ModeSize.registerEnum("ModeSize", true);
	LoaderSize.registerEnum("LoaderSize", true);

	//ADD HANDLERS FOR THE REGISTER PAGE
	try
	{
		if(document.URL.indexOf('register')!=-1)
		{	
			//ADD Register event handlers
        		$addHandler(Sys.UI.DomElement.getElementById(txtSWEmail), "blur", ValidateTextBox1);
			$addHandler(Sys.UI.DomElement.getElementById(txtSWEmailConfirmed), "blur", ValidateTextBox2);
        		$addHandler(Sys.UI.DomElement.getElementById(txtSWPassword), "blur", ValidateTextBox3);
			$addHandler(Sys.UI.DomElement.getElementById(txtSWPasswordConfirmed), "blur", ValidateTextBox4);
			$addHandler(Sys.UI.DomElement.getElementById(txtSWClub), "blur", ValidateDrop);
		}
	}
	catch(e){}

	//ADD HANDLERS FOR THE LEAGUE HIGHLIGHTS ON THE HOME PAGE
	try
	{
		if(document.URL.indexOf('default')!=-1 || document.URL.indexOf('.aspx')==-1)
		{
			//ATTACH HANDLES FOR THE LEAGUE TABLE
			try
			{
				$addHandler(Sys.UI.DomElement.getElementById("tab0head"), "click", LoadTab1);
			
				//CALL FIRST LEAGUE
				GenericHandler("tab0",0,"LeagueHighlight",LoaderSize.Small);
			}
			catch(e){}
			try
			{
				$addHandler(Sys.UI.DomElement.getElementById("tab1head"), "click", LoadTab2);
			}
			catch(e){}
	
			try
			{
				//CALL FIRST HOME HIGHLIGHT
				GenericHandler("divHomeHighlight",0,"HomeHighlight",LoaderSize.Big);
			}
			catch(e){}

		}
		else if(document.URL.indexOf('stats')!=-1)
		{
			//CALL FIRST STATS HIGHLIGHT
			GenericHandler("divStatsHighlight",0,"StatsHighlight",LoaderSize.Big);
		} 
		else if(document.URL.indexOf('matchresult')!=-1)
		{
			//CALL MATCH HIGHLIGHT
			GenericHandler("divMatchHighlight",0,"MatchHighlight",LoaderSize.Big);
		} 
	}
	catch(e){}
	
	// Add the AJAX calls
	try {
	
		// loop divs to find the ones we want		
		var containers = document.getElementsByTagName('div');
		
		for ( var i = 0; i < containers.length; i++ ) {
		
			// add another layer of security here for malformed elements or elements that may partially match but not contain all the data we need
			try {
			
				// verify that this is one of the elements we want
				if ( containers[i].id.indexOf('AjaxHolder') != -1 ) {
					// id should be formatted like so: swPortalAjaxHolder-type-customerid-gameid eg: swPortalAjaxHolder-PortalOurTeamInfo-3000000-POIN
					// update 05-02-09 Added gametype to the id eg: swPortalAjaxHolder-PortalOurTeamInfo-3000000-POIN-RUGB
					// break up into pieces
					var id = containers[i].id;
					var attributes = new Array();
					attributes = id.split('-');
					
					// finally set up the AJAX call						
					// Arguments:	Id of div,
					//			whatever value we want to pass (int)
					//			web method eg "TippingMatchStat"
					//			the size of the loading animation
					//attributes[1] = Ajax Method Type ie Rss
					//attributes[2] = Int paramter in
					//attributes[3] = Gameid
					//attributes[4] = GameType
					//attributes[5] = Extra param

					if(attributes.length<=5)
					{
					    GenericHandler(id, attributes[2], attributes[1], "2"); // i'm appending an extra argument onto the element id, I'll decouple them later
					}
					else
					{
					    //must switch on the id of the holder as News has 7 params, most items should have the old 5 or less
					    switch(attributes[1])
                       			{
			                            case "Rss":
                                			//RUNS INTO OLD METHOD AS RUNNING LIVE GAME BUT COULD BE SWITCHED TO NEW GH2 Handler.
			                                GenericHandler(id, attributes[2], attributes[1], "2");
                        			        break;
			                            default:
                        			        //run deafult bigger entry
					        	GenericHandler2(id, attributes[2], attributes[1], "2", attributes[3], attributes[4], attributes[5]);
						        break;
					    }
					}
				}
			} catch(e) {}
		}
	} catch(e) {}

	//INITIALIZE THE CLOCK OR CLOCKS
	try
	{
		if(multiClock=="true")
		{
			LC_InitializeClocks2();
		}
		else
		{
			LC_InitializeClocks();
		}
	}catch(e)
	{
		//THIS CATCHES GAMES THAT HAVNT UPDATED CODE AS multiClock variable is not at the top of page
		LC_InitializeClocks();
	}
	
	//SET FOCUS TO FIRST REG QUESTION
	try
	{
	if(document.URL.indexOf('register')!=-1)
	{
			$get(txtSWEmail).focus();
	}
	}catch(e){}
}

//
//CREATE FUNCTION HANDLERS THE Event Handlers CALLS
//
function LoadTab1() { GenericHandler("tab0",0,"LeagueHighlight",LoaderSize.Small); }
function LoadTab2() { GenericHandler("tab1",1,"LeagueHighlight",LoaderSize.Small); }

function ValidateTextBox1(evt){Validate(evt,txtSWEmail,"inEmail","Email",RegisterType.Email,ModeSize.Small);}
function ValidateTextBox2(evt){Validate(evt,txtSWEmailConfirmed,"inEmailConfirmed","Email Confirmed",RegisterType.EmailConfirmed,ModeSize.Small);}
function ValidateTextBox3(evt){Validate(evt,txtSWPassword,"inPassword","Password",RegisterType.Password,ModeSize.Small);}
function ValidateTextBox4(evt){Validate(evt,txtSWPasswordConfirmed,"inPasswordConfirmed","Password Confirm",RegisterType.PasswordConfirmed,ModeSize.Small);}
function ValidateDrop(evt){Validate(evt,txtSWClub,"ddlClub","Club Supported",RegisterType.DropDown,ModeSize.Small);}


function ValidateTextBox5(evt){Validate(evt,"txtSurname","Surname",RegisterType.TextBox,ModeSize.Big);}
function ValidateDOB(evt){Validate(evt,"txtDOB","Date Of Birth",RegisterType.DOB,ModeSize.Big);}


//Main Execute Method To Code
function GenericHandler(divId,leagueType,WebMethodType,LoaderS)
{
	//SET THE LOADER ONLY IF THE ID DOSNT CONTAIN img FOR GRAPHS
	if(WebMethodType=="AvatarSet")
	{
		var waiting = $get(divId);
		waiting.innerHTML = RenderLoading(LoaderS);
	}
	else if(WebMethodType=="TeamPointsBreakdown")
	{
		var waiting = $get(divId);
		waiting.innerHTML = RenderLoading2(LoaderS,850,450);
	}
	else if(WebMethodType=="WeekTeam")
	{
		var waiting = $get(divId);
		waiting.innerHTML = RenderLoading2(LoaderS,420,345);
	}
	else if(divId.indexOf('img')==-1)
	{
		var waiting = $get(divId);
		waiting.innerHTML = RenderLoading(LoaderS) + $get(divId).innerHTML;
	}
	//CALL PAGE METHOD
	PageMethods.AjaxEntryMethod(leagueType,WebMethodType,divId,OnSucceeded, OnFailed);

}
//Main Execute Method To Code v2 with gameType and Gameid split out for eass of access other end
function GenericHandler2(divId,leagueType,WebMethodType,LoaderS,gameId,gameType,param)
{
	//SET THE LOADER ONLY IF THE ID DOSNT CONTAIN img FOR GRAPHS
	if(WebMethodType=="AvatarSet")
	{
		var waiting = $get(divId);
		waiting.innerHTML = RenderLoading(LoaderS);
	}
	else if(divId.indexOf('img')==-1)
	{
		var waiting = $get(divId);
		waiting.innerHTML = RenderLoading(LoaderS) + $get(divId).innerHTML;
	}

	//CALL PAGE METHOD
	PageMethods.AjaxEntryMethod2(leagueType,WebMethodType,divId,gameId,gameType,param,OnSucceeded, OnFailed);
}

//Main Success Method
function OnSucceeded(data) 
{
	//THIS HANDLES ALL CALLBACKS FROM THE SERVER, SO WE PARSE THE ID OF
	//THE DIV WE WANT TO RENDER TO SERVER AND GET BACK BY |%|
	var items = data.split('|%|');
	//CHECK IF ITS DATA OR GRAPH
	if(items[0]=="imgTeamPlayerPoints")
	{
		//alert(items[0] + " " + items[1]);
		//var imgGraph = document.getElementById(items[0]);
		//imgGraph.style.background = "url(/" + items[1] + ")";
		$get(items[0]).style.background = "url(/" + items[1] + ")";
	}
	else if(items[0]=="scrollConfirmation")
	{
		if(items[1]!="null")
		{
	
			//RETURN TYPE NOT NULL
			$get(items[0]).innerHTML = items[1];
			$get(items[0]).style.display = 'BLOCK';	
		}
	}
	else
	{
		$get(items[0]).innerHTML = items[1];
	}
}

//Main Failure Method
function OnFailed(error) 
{
   // Alert user to the error.
   //alert("Error: " + error.get_message());
}

//CREATE THE LOADING DIALOG
function RenderLoading(LoaderS)
{
	//SWITCH ON TYPE OF LOADER
	if(LoaderS=="LoaderSize.Big" || LoaderS=="0")	
	{
		return "<div id=\"loaderBack\" class=\"loaderBack\"><div class=\"loader\" ><img src=\"image/ajax/blueFaster2.gif\"/><br/>" + loading + " ...</div></div>";
	}
	else
	{
		return "<img src=\"image/ajax/blueFaster2.gif\"/><br/>" + loading + " ...";
	}
}
function RenderLoading2(LoaderS,width,height)
{
	//SWITCH ON TYPE OF LOADER
	if(LoaderS=="LoaderSize.Big" || LoaderS=="0")	
	{
		return "<div id=\"loaderBack\" class=\"loaderBack\" style=\"left:" + ((width/2)-60) + ";top:" +  ((height/2)-40) + ";\"><div class=\"loader\" ><img src=\"image/ajax/blueFaster2.gif\"/><br/>" + loading + " ...</div></div>";
	}
	else
	{
		return "<img src=\"image/ajax/blueFaster2.gif\"/><br/>" + loading + " ...";
	}
}

function Validate(evt,val,divPopId,titleName,type,modeSize)
{   
    //val = element id
    //title = title of input 
    //type = what are we checking filled? date? username call?
    mSize = modeSize;

    //DONT VALIDATE ANYTHING IF FAILEDVER IS TRUE, EXIST AS WE ARE ESCAPING FOCUS BACK TO PREVIOUS CONTROL
    if(failedVer==true && lastValidatedObject!=divPopId)
    { return; }

    //VALIDATE TEXT BOX HAS DATA
    var e = $get(val);
    
    switch(type)
    {
        case RegisterType.TextBox:
            if(!e.value)
            {
                //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
                FailedVerification(divPopId,titleName,'',type);
		e.focus();
            }
            else
            {
                ParsedVerification(divPopId);
            }  
            break;
        case RegisterType.DropDown:
            //SELECT DROP MUST HAVE AN ITEM
            if(e.value=="" || e.value=="0")
            {
               //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
                FailedVerification(divPopId,titleName,'',type);
		e.focus();
            }
            else
            {
                ParsedVerification(divPopId);
            }
            break;
        case RegisterType.DOB:
            if(ValidateD("day","week","month",e.value,"18"))
            {
                ParsedVerification(divPopId);
            }
            else
            {
                FailedVerification(divPopId,titleName,e.value,type);
		e.focus();
            }
            break;
        case RegisterType.Email:
            if(!e.value)
            {
                //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
                FailedVerification(divPopId,titleName,'',type);
		e.focus();
            }
            else
            {
                //CHECK THERE IS EMAIL SPECIFIC DATA LIKE @
                if(ValidateEmail(e.value))
                {
                    ParsedVerification(divPopId);
                }
                else
                {
                    FailedVerification(divPopId,titleName,e.value,type);
	            e.focus();
                }
            }  
            break;
        case RegisterType.EmailConfirmed:
            if(!e.value)
            {
                //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
                FailedVerification(divPopId,titleName,'',type);
		e.focus();
            }
	    else if(e.value!=$get(txtSWEmail).value)
	    {
		//CONFIRMATION EMAIL IS NOT THE SAME ASORIGINAL
		FailedVerification(divPopId,titleName,'',type);
		e.focus();
	    }
            else
            {
                ParsedVerification(divPopId);
            }  
            break;
        case RegisterType.Password:
            if(!e.value)
            {
                //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
                FailedVerification(divPopId,titleName,'',type);
		e.focus();
            }
            else
            {
                ParsedVerification(divPopId);
            }  
            break;
        case RegisterType.PasswordConfirmed:
            if(!e.value)
            {
                //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
                FailedVerification(divPopId,titleName,'',type);
		e.focus();
            }
	    else if(e.value!=$get(txtSWPassword).value)
	    {
		//CONFIRMATION EMAIL IS NOT THE SAME ASORIGINAL
		FailedVerification(divPopId,titleName,'',type);
		e.focus();
	    }
            else
            {
                ParsedVerification(divPopId);
            }  
            break;
        default:
            break;
    }
}

function FailedVerification(object,titleName)
{
    //VALIDATION HAS FAILED
    //SHOW POPUP AS FAILED CHECK, SET FOCUS BACK
    //failedVal = true;
    //tempItem = val;
    var textBox = $get(object + "Pop");
    textBox.style.display = 'BLOCK';
    textBox.innerHTML = RenderHtml(titleName);
    /*
    textBox.innerHTML+= e.attributes["title"].name + "/" + e.attributes["title"].value + "<br/>";
    var i = 0;
    while(i!=109)
    {
        textBox.innerHTML+= e.attributes[i].name + "/" + e.attributes[i].value + "<br/>";
        i=i+1;
    }
    */
    //SET failedVer to TRUE SO NEXT ON LEAVE CAN BE IGNORED
    failedVer = true;
    lastValidatedObject = object; 
}

function FailedVerification(object,titleName,email,type)
{
    //VALIDATION HAS FAILED
    var textBox = $get(object + "Pop");
    textBox.style.display = 'inline';
    textBox.innerHTML = RenderHtml(titleName,email,type);
    failedVer = true;
    lastValidatedObject = object; 
}

function ParsedVerification(object)
{
    //CLOSE THE <div> FOR POPUP
    $get(object + "Pop").style.display = 'NONE';
    failedVer = false;
}

function RenderHtml(title,email,type)
{
    //RENDERS THE HTML POPUP BOX
    var output ="";
    switch(mSize)
    {
        case ModeSize.Big:
        //OUTPUT LARGE INFO BOX
        output +="<div style=\"width:100%;text-align:right;\"><div class=\"PopUpBox\"><div style=\"width:100%;float:left;margin:0px;font-size:14px;\">";
        output +="<div style=\"float:left;width:50px;border-bottom:1px solid #B9DCE8;\"></div>";
        output +="<div style=\"float:left;width:31px;\"><img src=\"U/PopUpError/top1.jpg\" height=\"17\" width=\"31\" /></div>";
        output +="<div style=\"float:left;width:400px;border-bottom:1px solid #B9DCE8;\"></div></div>";
        output +="<div class=\"PopUpBoxBottom\">";
	output +="<div class=\"PopUpBoxTitle\">";
	output +="<img src=\"U/PopUpError/Exclamation.gif\" /> &nbsp; " + title + " Failed :</div>";
	output +="<div class=\"PopUpBoxText\">";
	    break;
	    case ModeSize.Small:
	//OUTPUT SMALL BOX
	output +="<div style=\"width:100%;text-align:right;\"><div class=\"PopUpBox\"><div style=\"width:100%;float:left;margin:0px;font-size:11px;\">";
        output +="<div style=\"float:left;width:50px;border-bottom:1px solid #B9DCE8;\"></div>";
        output +="<div style=\"float:left;width:14px;\"><img src=\"U/PopUpError/topY.gif\" height=\"14\" width=\"14\" /></div>";
        output +="<div style=\"float:left;width:269px;border-bottom:1px solid #B9DCE8;\"></div></div>";
        output +="<div class=\"PopUpBoxBottom\">";
	output +="<div STYLE=\"float:left;width:17px;\"><img src=\"U/PopUpError/iconError.ico\" /></div><div style=\"float:right;width:300px;text-align:left;\">";
	    break;
    	case ModeSize.Icon:
    	    //OUTPUT SMALL BOX
	        output +="&nbsp;<img src=\"U/PopUpError/iconError.ico\" />";
	        break;
	    default:
    	        break;
	}
	    
	    //DECIDE WHAT MESSAGE TO OUTPUT TO USER
	    if(mSize!=ModeSize.Icon)
	    {
	        switch(type)
	        {
	        case RegisterType.TextBox:
	                output +="You have failed to fill in the " + title.toString().toLowerCase() + " textbox. Please enter a " + title + " to continue.";
	                break;
	        case RegisterType.Email:
    	            output +="You have failed to fill in the " + title.toString().toLowerCase() + " textbox correctly. Make sure the email address is spelt correctly and it includes an @ character. <br/><br/>You entered <b>" + email + "</b><br/><br/>Please enter an " + title + " address to continue.";
    	            break;
	        case RegisterType.EmailConfirmed:
    	            output +="The confirmed email address does not match the first email address you entered. Please try again.";
    	            break;
	        case RegisterType.DOB:
    	            output +="You have to be 18 to enter this game. Please update the " + title.toString().toLowerCase() + " textbox.<br/><br/>You entered a year of <b>" + email + "</b>";
    	            break;
    	        case RegisterType.DropDown:
    	            output +="You have failed to select an item from the " + title.toString().toLowerCase() + " drop down. Please select a " + title + " item to continue.";
    	            break;
		case RegisterType.Password:
	            output +="You have failed to fill in the " + title.toString().toLowerCase() + " textbox. Please enter a " + title + " to continue.";
	            break;
		case RegisterType.PasswordConfirmed:
	             output +="The confirmed password does not match the first password you entered. Please try again.";
	            break;
    	        default:
    	            break;
            }
	    output +="</div></div></div></div><div style=\"clear:both;\"><br/></div>";
        }

    return output;
}

function ValidateEmail(email)
{
    if(email.toString().indexOf('@',0)==-1)
    {
        return false;
    }
    else
    {
        return true;
    }
}

function ValidateD(day,week,month,yearIn,checkAge)
{
    var d1 = new Date();
    var year = d1.getFullYear();
    var yearLimit  = parseFloat(year) - parseFloat(checkAge);
    //NOW CHECK IF THERE YEAR IS GREATER THAN yearLimit
    if(yearLimit>=yearIn)
    {
        return true;
    }
    else
    {
        return false;
    }
}


///
/// CH JUNE 08 TEAM PAGE ADDITIONS
///

function CallRightTeamPanel()
{

	var posId = document.getElementById('teamPopUpPlayer').tag;
    
    //MAKE DIVS SHOW + HIDE ON RIGHT HAND SIDE
	Hide('teamHighlights');
	document.getElementById('divTeamHighlight').innerHTML = "<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>";
	Show('teamHighlightedPlayerInfo');
	//document.getElementById('teamHighlightedPlayerInfo').style.height = "550px"

	//POPULATE DATA
	GenericHandler("divTeamHighlight",posId,"TeamHighlight",LoaderSize.Big);

	//POPULATE PLAYER LINE GRAPH
	//GenericHandler("imgTeamPlayerPoints",posId,"Graph",LoaderSize.Big);
}

var tempD;
function CloseRightTeamPanel()
{
	//CLOSES THE RIGHT HAND TEAM PANEL
	Hide('teamHighlightedPlayerInfo');
	//tempD = 'teamHighlightedPlayerInfo';
	//shrinkingDiv = document.getElementById('teamHighlightedPlayerInfo');
	//shrink();
	Show('teamHighlights');
}

function shrink() 
{
	//if(shrinkingDiv.innerHTML!="")
	//{	
	//	shrinkingDiv.innerHTML="<div class=\"extSimpleHolderDropTitle\"><b>Player statistics</b></div><div class=\"extSimpleHolderContent\"><div id=\"divTeamHighlight\" class=\"divTeamHighlight\"></div></div>";
	//}
	//FIRST CHECK IF ITS HEIGHT IS 0
	if(parseInt(shrinkingDiv.style.height) <= 35)
	{
		//END close the dive completely
		Hide(tempD);
		return;
	}
	else
	{
		//CONTINUE THE LOOP
		shrinkingDiv.style.height =  parseInt(shrinkingDiv.style.height) - 20 + 'px';
		setTimeout("shrink()",0);
	}
}

///
/// CH CAPTAINS CALL BACK
///
function CallCaptainsPoints()
{
	//POPULATE DATA
	GenericHandler("divCaptainHighlight",0,"CaptainsPoints",LoaderSize.Small);
}

function CloseCaptainsPoints()
{
	$get("divCaptainHighlight").innerHTML = "";
}

// CH Avatar Call BACK
function SelectAvitar(id,name,description)
{
	//SELECTS THE CHOOSEN AVITAR
	GenericHandler("scrollConfirmation",id,"AvatarSet",LoaderSize.Small);
	//CHANGE IMG ONCE CALL HAS BEEN MADE
	var filename = "image/avatar/Av" + id + ".jpg";
	document.getElementById('chosenAvitar').src = filename;
	tempTitle = name;
	tempDescription = description;

}
// CH Avatar Call BACK
function SelectAvitarCustom(id,name,description)
{
	//SELECTS THE CHOOSEN AVITAR
	GenericHandler("scrollConfirmation",id,"AvatarSet",LoaderSize.Small);
	//CHANGE IMG ONCE CALL HAS BEEN MADE
	var filename = "u/avatar/Av" + id + ".jpg";
	document.getElementById('chosenAvitar').src = filename;
	tempTitle = name;
	tempDescription = description;
}
// CH Avatar Call BACK V2
function SelectAvitar(id,name,description,gameType)
{
	//SELECTS THE CHOOSEN AVITAR
	$get("scrollConfirmation").style.display = 'BLOCK';
	GenericHandler("scrollConfirmation",id,"AvatarSet",LoaderSize.Small);
	//CHANGE IMG ONCE CALL HAS BEEN MADE
	var filename = "image/avatar/" + gameType + "/Av" + id + ".jpg";
	document.getElementById('chosenAvitar').src = filename;
	tempTitle = name;
	tempDescription = description;

}
// CH Avatar Call BACK V2
function SelectAvitarCustom(id,name,description,gameType)
{
	//SELECTS THE CHOOSEN AVITAR
	$get("scrollConfirmation").style.display = 'BLOCK';
	GenericHandler("scrollConfirmation",id,"AvatarSet",LoaderSize.Small);
	//CHANGE IMG ONCE CALL HAS BEEN MADE
	var filename = "u/avatar/" + gameType + "/Av" + id + ".jpg";
	document.getElementById('chosenAvitar').src = filename;
	tempTitle = name;
	tempDescription = description;
}
// CH Avatar Call BACK V3
function SelectAvitar3(id,name,description,gameType,param)
{
	//SELECTS THE CHOOSEN AVITAR
	$get("scrollConfirmation").style.display = 'BLOCK';
	GenericHandler("scrollConfirmation",id,"AvatarSet",LoaderSize.Small);
	//CHANGE IMG ONCE CALL HAS BEEN MADE
	var subFolder = "";
	if(param!=""){subFolder="/" + param;}
	var filename = "image/avatar/" + gameType + subFolder + "/Av" + id + ".jpg";
	document.getElementById('chosenAvitar').src = filename;
	tempTitle = name;
	tempDescription = description;

}
// CH Avatar Call BACK V3
function SelectAvitarCustom3(id,name,description,gameType,param)
{
	//SELECTS THE CHOOSEN AVITAR
	$get("scrollConfirmation").style.display = 'BLOCK';
	GenericHandler("scrollConfirmation",id,"AvatarSet",LoaderSize.Small);
	//CHANGE IMG ONCE CALL HAS BEEN MADE
	var subFolder = "";
	if(param!=""){subFolder="/" + param;}
	var filename = "u/avatar/" + gameType + subFolder + "/Av" + id + ".jpg";
	document.getElementById('chosenAvitar').src = filename;
	tempTitle = name;
	tempDescription = description;
}

function LuachTeamPopUp()
{
    //REPOS THE DIV BEFORE POPPING
    RePositionPop('divPointsPop',850);
    //SHOW
    $("#divPointsPop").slideDown();
    //ATTACH THE LOAD EVENT
    GenericHandler("divPointsPopIn",0,"TeamPointsBreakdown",LoaderSize.Big);
}