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=10;
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 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 removeTheNode(idname)
{
    if (document.getElementById(idname)!=null)
    {
        if (fullresizeContainer[0]==document.getElementById(idname)) {
            cancelResize();
        }
        thisNode=document.getElementById(idname);
        thisNode.parentNode.removeChild(thisNode);
    }
    sizeFader();
}
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 class=\"tl\" /><td class=\"t\" /><td class=\"tr\" /></tr>";
	output+="<tr><td class=\"l\" /><td class=\"content\" style=\"background-color:#fff;text-align:"+(centerText?"center":"left")+"\">";
	    if (withClose) {
        output+="<img src=\"/skin/close.gif\" onmouseout=\"javascript:this.src='/skin/close.gif'\" onmouseover=\"javascript:this.src='/skin/closeOver.gif'\" 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><td class=\"r\" /></tr>";
	output+="<tr><td class=\"bl\" /><td class=\"b\" /><td class=\"br\" /></tr>";
	output+="</table>";
	

    return output;
}
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 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 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 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 alert2(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 encodeSafe(ip) {
    value=encodeURI(ip);
    //value=value.replace("'","#39");
    value=value.replace("&","(amp)");
    return value;
}