currentHandler=null;
centeredObjectId="";
expandObj=new Array();
expandObjHeight=null;
expandObjWidth=null;
expandTimer=null;
collapseObj=new Array();
collapseObjHeight=null;
collapseObjWidth=null;
collapseTimer=null;
openObj=new Array();
openObjHeight=null;
openTimer=null;
closeObj=new Array();
closeObjHeight=null;
closeTimer=null;
resizeObj=new Array();
resizeObjHeight=null;
resizeObjCurrentHeight=null;
resizeObjWidth=null;
resizeTimer=null;
resizeObjContents=new Array();
fullresizeObj=new Array();
fullresizeObjHeight=null;
fullresizeObjWidth=null;
fullresizeTimer=null;
maxResizeStep=30;
fullresizeObjContents=new Array();
fullresizeContainer=new Array();
currentRequests=new Array();
currentHandlers=new Array();
var countryCode="";
var clubCode="";
var countyCode="";
var selectingCourses=false;
var selectedPictureHandler=null;
var richTextPrefix="";

Array.prototype.find = function(searchStr) {
    var index = -1;
    var i=0;
    while(index<0 && i<this.length) {
        if (this[i]===searchStr) index=i;
        i++;
    }
    return index;
}
function sendRequest(docUrl,returnHandler) {
    now=new Date();
    docUrl+="&rand="+now.valueOf();
    if(typeof(FacebookUserID) != 'undefined') {
        if (FacebookUserID!="" && FacebookUserID!=null) docUrl+="&FacebookUserID="+FacebookUserID+"&f=1";
    }
    if (window.XMLHttpRequest){
        thisRequest=new XMLHttpRequest();
        currentHandlers.push(returnHandler);
        thisRequest.onreadystatechange=requestReceived;
        thisRequest.open("GET",docUrl,true);
        thisRequest.send(null);
        currentRequests.push(thisRequest);
    }else if (window.ActiveXObject){
        thisRequest=new ActiveXObject("Microsoft.XMLHTTP");
        currentRequests.push(thisRequest);
        currentHandlers.push(returnHandler);
        if (thisRequest){
            thisRequest.onreadystatechange=requestReceived;
            thisRequest.open("GET",docUrl,true);
            thisRequest.send();
        }
    }
    if (document.getElementById("messageSendButton")!=null) {
        document.getElementById('messageSendButton').src="/skin/wait.gif";
    }
}
function sendPostRequest(docUrl,parameters,returnHandler) {
    now=new Date();
    docUrl+="?rand="+now.valueOf();
    if(typeof(FacebookUserID) != 'undefined') {
        if (FacebookUserID!="" && FacebookUserID!=null) docUrl+="&FacebookUserID="+FacebookUserID+"&f=1";
    }
    if (window.XMLHttpRequest){
        thisRequest=new XMLHttpRequest();
        currentHandlers.push(returnHandler);
        thisRequest.onreadystatechange=requestReceived;
        thisRequest.open("POST",docUrl,true);
        thisRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        thisRequest.setRequestHeader("Content-length", parameters.length);
        thisRequest.setRequestHeader("Connection", "close");
        thisRequest.send(parameters);
        currentRequests.push(thisRequest);
    }else if (window.ActiveXObject){
        thisRequest=new ActiveXObject("Microsoft.XMLHTTP");
        currentRequests.push(thisRequest);
        currentHandlers.push(returnHandler);
        if (thisRequest){
            thisRequest.onreadystatechange=requestReceived;
            thisRequest.open("POST",docUrl,true);
            thisRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            thisRequest.setRequestHeader("Content-length", parameters.length);
            thisRequest.setRequestHeader("Connection", "close");
            thisRequest.send(parameters);
        }
    }
    if (document.getElementById("messageSendButton")!=null) {
        document.getElementById('messageSendButton').src="/skin/wait.gif";
    }
}
function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function noReturn(e)
{
    var rval=true;
    if (window.event) keycode=window.event.keyCode;
    else if (e) keycode=e.which;
    if (keycode==13)
    {
        rval=false;
    }
    return rval;
} 
function gotoUrl(url) {
    if(typeof(FacebookUserID) != 'undefined') {
        if (!url.match(/\?/)) {
            url+="?";
            url+="facebook_session_key="+FacebookSessionKey;
        }else{
            url+="&facebook_session_key="+FacebookSessionKey;
        }
        url+="&facebook_userId="+FacebookUserID;
        url+="&auth_token="+FacebookAuthToken;
        url+="&f=1";
    }
    window.location=url;
}
function requestReceived() {
    reply="";
    for (requestIndex=currentRequests.length-1;requestIndex>=0;requestIndex--) {
        if (currentRequests[requestIndex].readyState==4) {
            reply=currentRequests[requestIndex].responseText;
            if (currentRequests[requestIndex].status==200) {
                reply=currentRequests[requestIndex].responseText;
            }
            currentRequests[requestIndex]=null;
            currentRequests.splice(requestIndex,1);
            thisHandler=currentHandlers[requestIndex];
            currentHandlers.splice(requestIndex,1);
            if(typeof(FacebookUserID) != 'undefined') {
                reply=checkFacebookLinks(reply);
            }
            thisHandler(reply);
        }
    }
}
function checkFacebookLinks(ip) {
    var regex="<a href=\"([^\"]*)\"";
    var re = new RegExp(regex,"gim");
    var rehttp = new RegExp("^http","i");
    var remail = new RegExp("^mailto","i");
    var withVars = new RegExp("\\?","");
    matches=ip.match(re);
    if (matches!=null) {
        for (m=0;m<matches.length;m++) {
            comp=matches[m].split("\"");
            if(!rehttp.test(comp[1]) && !remail.test(comp[1])) {
                replacement=comp[1];
                if (withVars.test(comp[1])) {
                    replacement+="&f=1";
                }else{
                    replacement+="?f=1";
                }
                ip=ip.replace(comp[1],replacement);                
            }
        }
    }
    return ip;
}
function returnRoundedBox(id,title,content,centerText,zindex,removeWhichArray,withClose,withoutFadeDown) {
    removeThese="";
    if (removeWhichArray!=null) {
        rems=removeWhichArray.split(",");
        if (removeWhichArray!=null) for(i=0;i<rems.length;i++) removeThese+=";removeTheNode('"+rems[i]+"')";
    }
    output = "<table id=\""+id+"\" cellpadding=\"0\" cellspacing=\"0\" style=\"position:absolute;z-index:"+zindex+"\">";
    output += "<tr><td style=\"width:8px;height:8px;\"><img src=\"/skin/floattl.png\" /></td>";
    output += "<td style=\"height:8px;background-image:url(/skin/floatt.png);background-repeat: repeat-x;\" /></td>";
    output += "<td style=\"width:8px;height:8px\"><img src=\"/skin/floattr.png\" /></td></tr>";
    output += "<tr><td style=\"width:8px;background-image:url(/skin/floatl.png);background-repeat: repeat-y;\" /></td>";
    output += "<td class=\"defaultDialog\" style=\"background-color:#fff;text-align:"+(centerText?"center":"left")+"\">";
    output += "<div>";
    if (withClose) {
        output+="<img src=\"/skin/close.png\" onmouseout=\"javascript:this.src='/skin/close.png'\" onmouseover=\"javascript:this.src='/skin/closeOver.png'\" style=\"cursor:pointer;float:right;margin:2px;\" alt=\"Close\" onclick=\"";
        if (!withoutFadeDown || withoutFadeDown==null) {
            output+="startFadeDown();";
        }
        output+="removeTheNode('"+id+"');"+removeThese+"\" />";
    }
    output+=title+"</div>"+content;
    output += "<td style=\"width:8px;background-image:url(/skin/floatr.png);background-repeat: repeat-y;\" /></td></tr>";
    output += "<tr><td style=\"width:5px;height:5px\"><img src=\"/skin/floatbl.png\" /></td>";
    output += "<td style=\"height:8px;background-image:url(/skin/floatb.png);background-repeat: repeat-x;\" /></td>";
    output += "<td style=\"width:5px;height:5px\"><img src=\"/skin/floatbr.png\" /></td></tr>";
    output += "</table>";
    return output;
}
function toggleClubDetails(srcObj,cid)
{
    var re=new RegExp("Expand");
    if (srcObj.src.match(re))
    {
        srcObj.src="/skin/Collapse.png";
        openDiv("information"+cid);
    }else{
        srcObj.src="/skin/Expand.png";
        closeDiv("information"+cid);
    }
}
function hexColourFromRGB(r,g,b)
{
    var hexr=r.toString(16);
    if (hexr.length==1) hexr="0"+hexr;
    var hexg=g.toString(16);
    if (hexg.length==1) hexg="0"+hexg;
    var hexb=b.toString(16);
    if (hexb.length==1) hexb="0"+hexb;
    return hexr+hexg+hexb;
}
function removeTheNode(idname)
{
    if (document.getElementById(idname)!=null)
    {
        if (fullresizeContainer[0]==document.getElementById(idname)) {
            cancelResize();
        }
        thisNode=document.getElementById(idname);
        thisNode.parentNode.removeChild(thisNode);
    }
    sizeFader();
}
function pasteRawHTML(theHTML,destinationObj)
{
    var hiddenArea=null;
    if (document.getElementById("ParseArea")==null)
    {
        hiddenArea=document.createElement("div");
        hiddenArea.style.display="none";
        hiddenArea.ID="ParseArea";
    }
    else
    {
        hiddenArea = document.getElementById("ParseArea");
    }
    hiddenArea.innerHTML=theHTML;
    for (c=0;c<hiddenArea.childNodes.length;c++)
    {
        destinationObj.appendChild(hiddenArea.childNodes[c]);
    }
    hiddenArea.innerHTML="";
}
function theSrcElement(e)
{
    if (!e) var e = window.event;
    if (e.target) target = e.target
    else if (e.srcElement) target = e.srcElement
    return target;
}
function getFlashEmbed(flashfile,flashWidth,flashHeight,alignment,title,flashvars)
{
    var toembed="";
    toembed="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\""+flashWidth+"\" height=\""+flashHeight+"\" name=\""+title+"\" id=\""+title+"\" align=\""+alignment+"\">";
    toembed+="<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
    fv="";
    if (flashvars!=null) {
        toembed+="<param name=\"FlashVars\" value=\"javacommand="+flashvars+"\" />";
        fv=" FlashVars=\"javacommand="+flashvars+"\"";
    }
    toembed+="<param name=\"movie\" value=\""+flashfile+"\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"opaque\" /><param name=\"bgcolor\" value=\"#ffffff\" />";
    toembed+="<embed src=\""+flashfile+"\" quality=\"high\" wmode=\"opaque\" bgcolor=\"#ffffff\""+fv+" width=\""+flashWidth+"\" height=\""+flashHeight+"\" name=\""+title+"\" align=\""+alignment+"\" swLiveConnect=\"true\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
    toembed+="</object>";
    return toembed;
}
function showBarGraph(GraphFunction) {
    content=getFlashEmbed("/skin/ClubGraph.swf",500,400,"center",GraphFunction+"id",GraphFunction);
    startFadeUp();
    pasteRawHTML(returnRoundedBox("BarGraph","Click and drag to rotate...",content,true,60,null,true,false),document.body);
    centerObject(document.getElementById("BarGraph"));
}
function showRadialGraph(GraphFunction) {
    content=getFlashEmbed("/skin/holeAverages.swf",500,400,"center",GraphFunction+"id",GraphFunction);
    startFadeUp();
    pasteRawHTML(returnRoundedBox("holeAverages","",content,true,60,null,true,false),document.body);
    centerObject(document.getElementById("holeAverages"));
}
function getWindowHeight()
{
    var myHeight = ( typeof( window.innerWidth ) == 'number' )?window.innerHeight:( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )?document.documentElement.clientHeight:document.body.clientHeight;
    return myHeight;
}
function getWindowWidth()
{
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return myWidth;
} 
function centerObject(obj)
{
    var st = (window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;
    var scrolls=getScrollXY();
    st=scrolls[1];
    var wh = getWindowHeight();
    var t=(obj.clientHeight>wh)?st:((wh-obj.clientHeight)/2)+st;
    if (t<10) t=10;
    l=((document.body.offsetWidth-obj.clientWidth)/2);
    if (l<0) l=0;
    obj.style.left=l+"px";
    obj.style.top=t+"px";
}
function alignObjectWithTarget(obj,objright,objbottom,target,targetright,targetbottom,offsetx,offsety) {
    src=target;
	var curleft = curtop = curright = curbottom = 0;
	    
	if (target.offsetParent) {
	    do {
			curleft += target.offsetLeft;
			curtop += target.offsetTop;
        } while (target = target.offsetParent);
    }
    x=curleft+offsetx;
	if (targetright) x+=src.offsetWidth;
	y=curtop+offsety;
	if (targetbottom) y+=src.offsetHeight;
	if (objright) x-=obj.offsetWidth;
	if (objbottom) y-=obj.offsetHeight;
	obj.style.top=y+"px";
	obj.style.left=x+"px";
	
	
}
function checkChars(e)
{
    rv=true;
    if (window.event)
    {
        e=window.event;
        keycode=window.event.keyCode;
    }
    else
    {
        keycode=e.which;
    }
    if (e.shiftKey)
    {
        if (keycode==188 || keycode==190)
        {
            rv=false;
        }
    }
    if (window.event)
    {
        e.returnValue=rv;
    }
    else
    {
        if (!rv)
        {
            e.preventDefault();
        }
    }
}
function hexify(ip)
{
    op="";
    for (c=0;c<ip.length;c++)
    {
        theChar=ip.substr(c,1);
        val=theChar.charCodeAt(0);
        hex=val.toString(16);
        if (hex.length<2)
        {
            hex="0"+hex.toString();
        }
        op+=hex;
    }
    return op;
}
function getOffsetXY(obj)
{
    var curleft = curtop = 0;
    if (obj.offsetParent)
    {
        curleft = obj.offsetLeft;
        curtop = obj.offsetTop;
        while (obj = obj.offsetParent)
        {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        }
    }
    return new Array(curleft,curtop);
}
function getScrollXY()
{
    var scrOfX = 0, scrOfY = 0;
    if( typeof( window.pageYOffset ) == 'number' )
    {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    }
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
    {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    }
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
    {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    //pasteRawHTML(scrOfY+"<br />",document.body);
    return [ scrOfX, scrOfY ];
}
function checkAlphaNumeric(toTest)
{
    alpharegex=new RegExp(/[a-zA-Z0-9]/);
    return alpharegex.test(toTest);
}
function validateOverLength(srcObj,theLength)
{
    if (srcObj.value.length>=theLength)
    {
        srcObj.style.backgroundImage="url(/skin/inputValid.gif)";
    }
    else
    {
        srcObj.style.backgroundImage="url(/skin/inputRequired.gif)";
    }
}
function checkEmail(srcObj)
{
    email=srcObj.value;
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email))
    {
        checkEmailWithDatabase(email);
    }
    else
    {
        srcObj.style.backgroundImage="url(/skin/inputRequired.gif)";
        srcObj.title="Enter the email address of your friend!";
    }
}
function checkEmailWithDatabase(emailToCheck)
{
    url="/checkEmail.ashx?email="+emailToCheck+"&invited=true";
    sendRequest(url,emailCheckReceived);
}
function emailCheckReceived(reply)
{
    if (reply=="ok")
    {
        document.getElementById("inviteEmail").style.backgroundImage="url(/skin/inputValid.gif)";
        document.getElementById("inviteEmail").title="This email address is valid";
    }
    else
    {
        document.getElementById("inviteEmail").style.backgroundImage="url(/skin/inputError.gif)";
        document.getElementById("inviteEmail").title="This email address is "+res;
    }
} 
function removeShortlist(e)
{
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
    if (targ.tagName!="INPUT") removeTheNode("shortlist");
}
function displayPhoto(photoid) {
    startFadeUp();
    insert="<img src=\"/skin/loading.gif\" id=\"loading\" />";
    insert+="<img src=\"/photo.ashx?id="+photoid+"\" onload=\"removeTheNode('loading');centerObject(document.getElementById('photoFrame'))\" style=\"margin:5px\" />";
    insert=returnRoundedBox("photoFrame","",insert,true,34,null,true)
    pasteRawHTML(insert,document.body);
    centerObject(document.getElementById("photoFrame"));
    sizeFader();
}
function toggleExpandable(obj,toCollapse){
    collapseThese(toCollapse);
    if (document.getElementById(obj).style.display=="block") {
        collapseDiv(obj);
    }else{
        expandDiv(obj);
    }
    return false;
}
function collapseThese(toCollapse) {
    if (toCollapse!=null) {
        cols=toCollapse.split(",");
        for (i=0;i<cols.length;i++) {
            if (document.getElementById(cols[i]).style.display=="block") {
                collapseDiv(cols[i]);
            }
        }
    }
}
function expandDiv(obj) {
    if (obj!="") expandObj.push(document.getElementById(obj));
    if (expandTimer==null) {
        expandObj[0].style.overflow='visible';
        expandObj[0].style.display='block';
        expandObj[0].style.height="";
        expandObj[0].style.width="";
        expandObjWidth=expandObj[0].offsetWidth;
        expandObjHeight=expandObj[0].offsetHeight;
        currentexpandObjWidth=1;
        currentexpandObjHeight=1;
        expandObj[0].style.overflow='hidden';
        expandObj[0].style.height=1+"px";
        expandObj[0].style.width=1+"px";
        expandTimer = setTimeout("expandTheObj()",2);
    }
}
function expandTheObj(){
    thisObj=expandObj[0];
    dw=(expandObjWidth-currentexpandObjWidth)/2;
    if (dw>maxResizeStep) dw=maxResizeStep;
    if (dw<-maxResizeStep) dw=-maxResizeStep;
    dh=(expandObjHeight-currentexpandObjHeight)/2;
    if (dh>maxResizeStep) dh=maxResizeStep;
    if (dh<-maxResizeStep) dh=-maxResizeStep;
    if (dh<1 && dh>-1 && dw<1 && dw>-1) {
        currentexpandObjHeight=expandObjHeight;
        currentexpandObjWidth=expandObjWidth;
        expandObj[0].style.overflow='visible';
        clearTimeout(expandTimer);
        expandTimer=null;
        expandObj.shift();
        if (expandObj.length>0) expandDiv("");
    }else{
        expandTimer = setTimeout("expandTheObj()",2);
        currentexpandObjHeight+=dh;
        currentexpandObjWidth+=dw;
    }
    thisObj.style.height=(currentexpandObjHeight)+"px";
    thisObj.style.width=(currentexpandObjWidth)+"px";
}
function collapseDiv(obj) {
    if (obj!="") collapseObj.push(document.getElementById(obj));
    if (collapseTimer==null) {
        currentcollapseObjHeight=collapseObj[0].offsetHeight;
        currentcollapseObjWidth=collapseObj[0].offsetWidth;
        collapseObj[0].style.overflow='hidden';
        collapseTimer = setTimeout("collapseTheObj()",2);
    }
}
function collapseTheObj(){
    thisObj=collapseObj[0];
    dw=currentcollapseObjWidth/2;
    if (dw>maxResizeStep) dw=maxResizeStep;
    if (dw<-maxResizeStep) dw=-maxResizeStep;
    dh=currentcollapseObjHeight/2;
    if (dh>maxResizeStep) dh=maxResizeStep;
    if (dh<-maxResizeStep) dh=-maxResizeStep;
    currentcollapseObjHeight-=dh;
    currentcollapseObjWidth-=dw;
    if (currentcollapseObjWidth<1) currentcollapseObjWidth=1;
    if (currentcollapseObjHeight<1) currentcollapseObjHeight=1;
    if (currentcollapseObjHeight<=1 || currentcollapseObjWidth<=1) {
        clearTimeout(collapseTimer);
        collapseTimer=null;
        thisObj.style.display='none';   
        collapseObj.shift();
        if (collapseObj.length>0) collapseDiv(""); 
    }else{
        collapseTimer = setTimeout("collapseTheObj()",2);
    } 
    
    thisObj.style.height=currentcollapseObjHeight+"px";
    thisObj.style.width=currentcollapseObjWidth+"px";
}
function openDiv(obj) {
    if (obj!="") openObj.push(document.getElementById(obj));
    if (openTimer==null) {
        openObj[0].style.overflow='visible';
        openObj[0].style.display='block';
        openObj[0].style.height="";
        openObjHeight=openObj[0].offsetHeight;
        openObj[0].style.overflow='hidden';
        openObj[0].style.height=1+"px";
        openTimer = setTimeout("openTheObj()",2);
    }
}
function openTheObj(){
    thisObj=openObj[0];
    h=thisObj.offsetHeight;
    dh=(openObjHeight-h)/2;
    if (dh<1 && dh>-1) {
        dh=openObjHeight-h;
        clearTimeout(openTimer);
        openTimer=null;
        openObj.shift();
        if (openObj.length>0) openDiv("");
    }else{
        openTimer = setTimeout("openTheObj()",2);
    }
    thisObj.style.height=(h+dh)+"px";
}
function closeDiv(obj) {
    if (obj!="") closeObj.push(document.getElementById(obj));
    if (closeTimer==null) {
        closeObj[0].style.overflow='hidden';
        closeTimer = setTimeout("closeTheObj()",2);
    }
}
function closeTheObj(){
    thisObj=closeObj[0];
    h=thisObj.offsetHeight;
    dh=h/2;
    if (dh<1) dh=1;
    if (dh==1) {
        clearTimeout(closeTimer);
        closeTimer=null;
        thisObj.style.display='none';   
        closeObj.shift();
        if (closeObj.length>0) closeDiv("");    
    }else{
        closeTimer = setTimeout("closeTheObj()",2);
    }
    thisObj.style.height=dh+"px";
}
function setInnerHTML(obj,content) {
    thisresize=document.getElementById(obj);
    if (thisresize.tagName=="DIV" || thisresize.tagName=="TD") {
        resizeObj.push(thisresize);
        resizeObjContents.push(content);
        if (resizeObj.length==1) startResize();
    }else{
        thisresize.innerHTML=content;
    }
}
function startResize() {
    if (resizeObj.length>0) {
    
        thisresize=resizeObj[0];
        resizeObjCurrentHeight=thisresize.offsetHeight;
        testContent="<div id=\"textContent\">"+resizeObjContents[0]+"</div>";
        thisresize.style.height=resizeObjCurrentHeight+"px";
        thisresize.style.overflow='hidden';
        thisresize.style.display='block';
        if (resizeObjContents[0]=="") {
            resizeObjHeight=1;
        }else{
            thisresize.innerHTML=testContent;
            resizeObjHeight=thisresize.childNodes[0].offsetHeight;
        }
        thisresize.innerHTML=resizeObjContents[0];
        resizeTimer = setTimeout("resizeTheObj()",2);
    }
}
function resizeTheObj(){
    maxMovement=50;
    thisObj=resizeObj[0];
    dh=(resizeObjHeight-resizeObjCurrentHeight)/2;
    if (dh>maxMovement) dh=maxMovement;
    if (dh<-maxMovement) dh=-maxMovement;
    dw=0;
    if (dh<1 && dh>-1 && dw<1 && dw>-1) {
        clearTimeout(resizeTimer);
        resizeTimer=null;
        if (thisObj.innerHTML=="") thisObj.style.display="none";
        thisObj.style.overflow="visible";
        thisObj.style.height="";
        resizeObj.shift();
        resizeObjContents.shift();
        if (resizeObj.length>0) startResize();
    }else{
        resizeObjCurrentHeight+=dh;
        thisObj.style.height=resizeObjCurrentHeight+"px";
        resizeTimer = setTimeout("resizeTheObj()",2);
    }
}
function setInnerHTMLCentered(obj,content,container) {
    thisresize=document.getElementById(obj);
    if (thisresize.tagName=="DIV" || thisresize.tagName=="TD") {
        //thisresize.innerHTML=fullresizeObj.length+" in queue";
        fullresizeContainer.push(document.getElementById(container));
        fullresizeObj.push(thisresize);
        fullresizeObjContents.push(content);
        if (fullresizeObj.length==1) startResizeCentered();
    }else{
        thisresize.innerHTML=content;
    }
    //pasteRawHTML(fullresizeObj.length+" setInnerHTML of "+obj+" to "+content+" - ",document.body);
}
function startResizeCentered() {
    if (fullresizeObj.length>0) {
        thisresize=fullresizeObj[0];
        currentHeight=thisresize.offsetHeight;
        currentWidth=thisresize.offsetWidth;
        thisresize.style.overflow='visible';
        thisresize.style.display='block';
        thisresize.style.height="";
        thisresize.style.width="";
        thisresize.innerHTML=fullresizeObjContents[0];
        fullresizeObjWidth=thisresize.offsetWidth;
        fullresizeObjHeight=thisresize.offsetHeight;
        if (fullresizeObjContents[0]=="") {
            fullresizeObjHeight=1;
            fullresizeObjWidth=1;
        }
        thisresize.style.overflow='hidden';
        thisresize.style.height=currentHeight+"px";
        thisresize.style.width=currentWidth+"px";
        fullresizeTimer = setTimeout("resizeTheObjCentered()",2);
    }
}
function resizeTheObjCentered(){
    if (fullresizeObj.length>0) {
        thisObj=fullresizeObj[0];
        if (thisObj==null) {
            clearTimeout(fullresizeTimer);
            fullresizeTimer=null;
            fullresizeObj.shift();
            fullresizeObjContents.shift();
            fullresizeContainer.shift();
            if (fullresizeObj.length>0) startResizeCentered();
        }else{
            h=thisObj.offsetHeight;
            w=thisObj.offsetWidth;
            dh=(fullresizeObjHeight-h)/2;
            dw=(fullresizeObjWidth-w)/2;
            if (dh<1 && dh>-1 && dw<1 && dw>-1) {
                clearTimeout(fullresizeTimer);
                fullresizeTimer=null;
                if (thisObj.innerHTML=="") thisObj.style.display="none";
                thisObj.style.overflow="visible";
                thisObj.style.height="";
                thisObj.style.width="";
                fullresizeObj.shift();
                fullresizeObjContents.shift();
                fullresizeContainer.shift();
                if (fullresizeObj.length>0) startResizeCentered();
            }else{
                thisObj.style.height=(h+dh)+"px";
                thisObj.style.width=(w+dw)+"px";
                centerObject(fullresizeContainer[0]);
                fullresizeTimer = setTimeout("resizeTheObjCentered()",2);
            }
        }
    //pasteRawHTML(fullresizeObj.length+" "+thisObj.id+" resizing - ",document.body);
    }else{
        clearTimeout(fullresizeTimer);
        fullresizeTimer=null;
    }
    
}
function cancelResize() {
    //pasteRawHTML(" "+fullresizeObj.length+" cancelled - ",document.body);
    fullresizeObj[0].innerHTML="Cancelling";
    clearTimeout(fullresizeTimer);
    fullresizeTimer=null;
    fullresizeObj.shift();
    fullresizeObjContents.shift();
    fullresizeContainer.shift();
    if (fullresizeObj.length>0) startResizeCentered();
}
function alert(comment) {
    drawAlertBlock();
    fader(document.getElementById("alertBack"),80);
    if (!comment.match("/img src/")) {
        comment+="<br /><br /><img src=\"/skin/ok.png\" style=\"cursor:pointer\" onmouseover=\"this.src='/skin/okOver.png'\" onmouseout=\"this.src='/skin/ok.png'\" onclick=\"removeTheNode('alertBack');removeTheNode('alerter')\" />";
    }
    pasteRawHTML(returnRoundedBox("alerter","",comment,true,91,null,false,true),document.body);
    centerObject(document.getElementById("alerter"));
}
function drawAlertBlock()
{
    pasteRawHTML("<div id=\"alertBack\" style=\"visibility:visible;position:absolute;z-index:90;background-color:#94a0b3;padding:0px;margin:0px;top:0px;left:0px;width:100%;height:100%\" onmouseover=\"removeTheNode('shortlist')\">&nbsp;</div>",document.body);
    var docHeight=(typeof document.height != 'undefined')?document.height:(document.compatMode && document.compatMode != 'BackCompat')?document.documentElement.scrollHeight:document.body.scrollHeight;
    var wh=getWindowHeight();
    if (docHeight<wh) docHeight=wh;
    obj=document.getElementById("alertBack");
    obj.style.height=docHeight+"px";
}
function showClubStars(clubid,star) {
    for (i=1;i<6;i++) {
        thisStar=document.getElementById("club"+clubid+"star"+i);
        if (i<=star) {
            thisStar.src="/skin/star.png";
        }else{
            thisStar.src="/skin/staroff.png";
        }
    }
}
function saveClubRating(clubid,star) {
    if (star==0) {
        document.getElementById("clubrating"+clubid).innerHTML="Clearing...";
    }else{
        thisStar=document.getElementById("club"+clubid+"star"+star);
        thisStar.parentNode.innerHTML="Saving...";
    }
    url="/inside/Admin.ashx";
    params="cmd=rateclub&club="+clubid+"&rating="+star;
    sendPostRequest(url,params,clubRated);
}
function clubRated(reply) {
    if (reply=="OK") {
        if (!checkAlphaNumeric(document.getElementById("coursesContainer").innerHTML))
        {
            setInnerHTML("coursesContainer","<img src=\"/skin/loading.gif\"><br>Loading courses...");
            refreshPlayed(true);
        }
        else
        {
            setInnerHTML("coursesContainer","<img src=\"/skin/loading.gif\"><br>Loading courses...");
            refreshPlayed(false);
        }
    }else{
        alert("An error has occurred");
    }
}
function showCourseStars(courseid,star) {
    for (i=1;i<6;i++) {
        thisStar=document.getElementById("course"+courseid+"star"+i);
        if (i<=star) {
            thisStar.src="/skin/star.png";
        }else{
            thisStar.src="/skin/staroff.png";
        }
    }
}
function saveCourseRating(courseid,star) {
    if (star==0) {
        document.getElementById("courserating"+courseid).innerHTML="Clearing...";
    }else{
        thisStar=document.getElementById("course"+courseid+"star"+star);
        thisStar.parentNode.innerHTML="Saving...";
    }
    url="/inside/Admin.ashx";
    params="cmd=ratecourse&course="+courseid+"&rating="+star;
    sendPostRequest(url,params,courseRated);
}
function courseRated(reply) {
    if (reply=="OK") {
        
        if (!checkAlphaNumeric(document.getElementById("coursesContainer").innerHTML))
        {
            setInnerHTML("coursesContainer","<img src=\"/skin/loading.gif\"><br>Loading courses...");
            refreshPlayed(true);
        }
        else
        {
            setInnerHTML("coursesContainer","<img src=\"/skin/loading.gif\"><br>Loading courses...");
            refreshPlayed(false);
        }
    }else{
        alert("An error has occurred");
    }
}
function writeClubReview(clubname,clubid) {
    content="<textarea id=\"reviewArea\" class=\"reviewBox\"></textarea>";
    content+="<img src=\"/skin/editSave.jpg\" style=\"cursor:pointer\" onmouseover=\"this.src='/skin/editSaveOver.jpg'\" onmouseout=\"this.src='/skin/editSave.jpg'\" onclick=\"saveClubReview("+clubid+")\" />";
    startFadeUp();
    pasteRawHTML(returnRoundedBox("review","Your review of "+clubname,content,true,10,null,true,false),document.body);
    centerObject(document.getElementById("review"));
}
function saveClubReview(clubid) {
    url="/inside/Admin.ashx";
    value=encodeSafe(document.getElementById("reviewarea").value);
    params="cmd=commentclub&club="+clubid+"&comment="+value;
    document.getElementById("reviewarea").parentNode.innerHTML="<img src=\"/skin/loading.gif\" />";
    sendPostRequest(url,params,reviewSaved);
}
function writeCourseReview(coursename,courseid) {
    content="<textarea id=\"reviewArea\" class=\"reviewBox\"></textarea>";
    content+="<img src=\"/skin/editSave.jpg\" style=\"cursor:pointer\" onmouseover=\"this.src='/skin/editSaveOver.jpg'\" onmouseout=\"this.src='/skin/editSave.jpg'\" onclick=\"saveCourseReview("+courseid+")\" />";
    startFadeUp();
    pasteRawHTML(returnRoundedBox("review",coursename,content,true,10,null,true,false),document.body);
    centerObject(document.getElementById("review"));
}
function saveCourseReview(courseid) {
    url="/inside/Admin.ashx";
    value=encodeSafe(document.getElementById("reviewarea").value);
    params="cmd=commentcourse&course="+courseid+"&comment="+value;
    document.getElementById("reviewarea").parentNode.innerHTML="<img src=\"/skin/loading.gif\" />";
    sendPostRequest(url,params,reviewSaved);
}
function reviewSaved(reply) {
    removeTheNode("review");
    startFadeDown();
    if (reply=="OK") {
        
        if (!checkAlphaNumeric(document.getElementById("coursesContainer").innerHTML))
        {
            setInnerHTML("coursesContainer","<img src=\"/skin/loading.gif\"><br>Loading courses...");
            refreshPlayed(true);
        }
        else
        {
            setInnerHTML("coursesContainer","<img src=\"/skin/loading.gif\"><br>Loading courses...");
            refreshPlayed(false);
        }
    }else{
        alert("An error has occurred");
    }
}
function encodeSafe(ip) {
    value=encodeURI(ip);
    //value=value.replace("'","#39");
    value=value.replace("&","(amp)");
    return value;
}
function clearCourseComment(courseid) {
    url="/inside/Admin.ashx";
    params="cmd=commentcourse&course="+courseid+"&comment=";
    document.getElementById("courseComment"+courseid).innerHTML="Clearing...";
    sendPostRequest(url,params,reviewSaved);
}
function clearClubComment(clubid) {
    url="/inside/Admin.ashx";
    params="cmd=commentclub&club="+clubid+"&comment=";
    document.getElementById("clubComment"+clubid).innerHTML="Clearing...";
    sendPostRequest(url,params,reviewSaved);
}
function findClubs()
{
    if (document.getElementById("clubSearchField")!=null)
    {
        if (document.getElementById("shortlist")==null)
        {
            var floater="<div id=\"shortlist\" class=\"shortlist\">Searching...</div>";
            pasteRawHTML(floater,document.body);
        }
        else
        {
            document.getElementById("shortlist").innerHTML="Searching...";
        }
        alignObjectUnderTarget(document.getElementById("shortlist"),document.getElementById("clubSearchField"),3);
        var searchField=document.getElementById("clubSearchField").value;
        lastClubSearch=searchField;
        var docUrl="/shortlistClubs.ashx?q="+searchField+"&cc="+countryCode+"&state="+countyCode;
        if (selectingCourses)
        {
            docUrl+="&withCourses=1";
        }
        sendRequest(docUrl,foundClubs);
    }
}
function foundClubs(reply)
{
    if (document.getElementById("shortlist")==null)
    {
        var floater="<div id=\"shortlist\" class=\"shortlist\">"+reply+"</div>";
        pasteRawHTML(floater,document.body);
    }
    else
    {
        document.getElementById("shortlist").innerHTML=reply;
    }
    alignObjectUnderTarget(document.getElementById("shortlist"),document.getElementById("clubSearchField"),3);
}
function getClubCard(clubID,withControls)
{
    var docUrl="/clubCard.ashx?cid="+clubID;
    if (withControls) docUrl+="&withControls=1"
    removeTheNode('shortlist');
    document.getElementById("clubBusinessCard").innerHTML="<img src=\"/skin/loading.gif\"><br>Loading Club...";
    sendRequest(docUrl,gotClubCard);
}
function gotClubCard(reply)
{
    setInnerHTML("clubBusinessCard",reply);
}
function searchClubs(srcObj,e,withControls)
{
    var searchField=srcObj.value;
    lastClubSearch=searchField;
    var docUrl="/shortlistClubs.ashx?q="+searchField+"&cc="+countryCode+"&state="+countyCode;
    if (selectingCourses)
    {
        docUrl+="&withCourses=1";
    }
    if (withControls) {
        checkShortlistKeys(srcObj,e,searchClubwithControls,docUrl,false);
    }else{
        checkShortlistKeys(srcObj,e,searchClub,docUrl,false);
    }
}
function searchClubwithControls(id) {
    if (id!=null) {
        getClubCard(id,true);
    }
}
function searchClub(id) {
    if (id!=null) {
        getClubCard(id,false);
    }
}
function searchCountries(srcObj,e)
{
    var searchField=srcObj.value;
    var docUrl="/shortlistCountries.ashx?q="+searchField;
    checkShortlistKeys(srcObj,e,countrySelect,docUrl,true);
}
function countrySelect(reply) {
    if (reply==null) {
        countryCode="";
        countyCode="";
        setInputSelected(document.getElementById("countyClubSearch"),false);
    }else{
        var data=reply.split("^");
        if (countryCode!=data[0]) {
            setInputSelected(document.getElementById("countyClubSearch"),false);
            countyCode="";
        }
        countryCode=data[0];
        document.getElementById("countryClubSearch").value=data[1];
        document.getElementById("countyType").innerHTML=data[2];
    }
}
function searchCounties(srcObj,e)
{
    if (countryCode!=null && countryCode!="") {
        var searchField=srcObj.value;
        var docUrl="/shortlistCounties.ashx?q="+searchField+"&country="+countryCode;
        checkShortlistKeys(srcObj,e,countySelect,docUrl,true);
    }
}
function countySelect(reply) {
    if (reply==null) {
        countyCode="";
    }else{
        var data=reply.split("^");
        countyCode=data[0];
        document.getElementById("countyClubSearch").value=data[1];
    }
}
function checkKey(e) {
    var rval=true;
    if (window.event) keycode=window.event.keyCode;
    else if (e) keycode=e.which;
    if (keycode>105 || keycode==9 || keycode==11) {
        rval=false;
    }
    if (keycode==9 || keycode==11) {
        closeShortlist();
        rval=true;
    }
    return rval;   
}
function embeduploader(theCommand,completedHandler) {
//    var embedded="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\"120\" height=\"100\" name=\"uploader\" id=\"uploader\" align=\"middle\">";
//    embedded+="<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
//    embedded+="<param name=FlashVars value=\"sendCommand="+theCommand+"&completeHandler="+completedHandler+"\" />";
//    embedded+="<param name=\"movie\" value=\"/skin/uploader.swf\" />";
//    embedded+="<param name=\"quality\" value=\"high\" />";
//    embedded+="<param name=\"wmode\" value=\"opaque\" />";
//    embedded+="<param name=\"bgcolor\" value=\"#ffffff\" />";
//    embedded+="<embed src=\"/skin/uploader.swf\" quality=\"high\"";
//    embedded+=" wmode=\"opaque\"";
//    embedded+=" bgcolor=\"#ffffff\" width=\"120\" height=\"100\" name=\"uploader\" id=\"uploader\" align=\"middle\" swLiveConnect=\"true\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
//    embedded+="</object>";

    params=new Array();
    vars=new Array();
    params.push("width");
    vars.push("120");
    params.push("height");
    vars.push("100");
    params.push("src");
    vars.push("/skin/uploader.swf");
    params.push("quality");
    vars.push("high");
    params.push("align");
    vars.push("middle");
    params.push("play");
    vars.push("true");
    params.push("loop");
    vars.push("true");
    params.push("scale");
    vars.push("showall");
    //params.push("wmode");
    //vars.push("opaque");
    params.push("devicefont");
    vars.push("false");
    params.push("id");
    vars.push("uploader");
    params.push("name");
    vars.push("uploader");
    params.push("bgcolor");
    vars.push("#ffffff");
    params.push("menu");
    vars.push("false");
    params.push("allowFullScreen");
    vars.push("false");
    params.push("allowScriptAccess");
    vars.push("sameDomain");
    params.push("movie");
    vars.push("/skin/uploader.swf");
    params.push("salign");
    vars.push("");
    params.push("FlashVars");
    vars.push("sendCommand="+theCommand+"&completeHandler="+completedHandler+"&"+document.cookie.replace(/; /g,"&"));
    return flashCode("/skin/uploader.swf",params,vars);
    //return "<textarea cols=\"50\" rows=\"20\">"+flashCode("/skin/uploader.swf",params,vars)+"</textarea>";
}
function flashCode(srcMovie,params,vars) {
    op="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\"";
    for(i=0;i<vars.length;i++) {
        op+=" "+params[i]+"=\""+vars[i]+"\"";
    }
    op+=">";
    for(i=0;i<vars.length;i++) {
        op+="<param name=\""+params[i]+"\" value=\""+vars[i]+"\" />";
    }
    op+="<embed src=\""+srcMovie+"\"";
    for(i=0;i<vars.length;i++) {
        op+=" "+params[i]+"=\""+vars[i]+"\"";
    }
    op+="swLiveConnect=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
    op+="</object>";
    return op;
}
function getCookieValue(name) {
    reply="empty";
    var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) reply=c.substring(nameEQ.length,c.length);
	}
	return reply;
}
function requestAdminFriend(srcObj,userid,clubid) {
    srcObj.innerHTML="Sending..";
    srcObj.onclick=null;
    var docUrl="/inside/friendManagement.ashx?cmd=requestadmin&club="+clubid+"&usid="+userid;
    sendRequest(docUrl,adminFriendReceived);
}
function adminFriendReceived(reply) {
    setInnerHTML("clubadmin",reply);
}

function administrateThisClub(srcObj,userid,clubid) {
    srcObj.innerHTML="Sending..";
    srcObj.onclick=null;
    
    
    docUrl="/inside/Admin.ashx?cmd=adminrequest&cid="+clubid;
    //document.getElementById("adminrequest").innerHTML="<center><img src=\"/skin/loading.gif\" /><br />Processing request...</center>";
    //centerObject(document.getElementById("administrate"));
    sendRequest(docUrl,adminFriendReceived);
    
    //var docUrl="/inside/friendManagement.ashx?cmd=requestadmin&club="+clubid+"&usid="+userid;
    //sendRequest(docUrl,adminFriendReceived);
}