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 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 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 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 encodeSafe(ip) {
    value=encodeURI(ip);
    //value=value.replace("'","#39");
    value=value.replace("&","(amp)");
    return value;
}
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 toggleCountry(code) {
    wasopen=false;
    for(i=0;i<allCountries.length;i++) {
        obj=document.getElementById("country"+allCountries[i]);
        if (allCountries[i]==code && obj.className=="countryOpen") wasopen=true;
        if (obj.className=="countryOpen") {
            closeDiv("regions"+allCountries[i]);
            obj.className="countryClosed";
        }
    }
    if (!wasopen) {
        document.getElementById("country"+code).className="countryOpen";
        openDiv("regions"+code);
    }
}
function showMap(title,theURL) {

    removeTheNode("mapper");
    var maxSize=getWindowWidth();
    var maxHeight=getWindowHeight();
    if (maxHeight<maxSize) {
        maxSize=maxHeight;
    }
    maxSize-=50;
    insert="<img src=\"/skin/loading.gif\" id=\"imageLoading\" />"
    insert+="<div><img src=\""+theURL+"&size="+maxSize.toString()+"\" onload=\"javascript:this.style.display='block';removeTheNode('imageLoading');centerObject(document.getElementById('mapper'))\" /></div>"
   
    
    insert=returnRoundedBox("mapper",title,insert,true,36,null,true,true)
    
    pasteRawHTML(insert,document.body);
    centerObject(document.getElementById("mapper"));
}