currentHandler=null;
centeredObjectId="";
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;
}
if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

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 removeTheNode(idname) {
	if (typeof(idname)=="string") {
		if (document.getElementById(idname)!=null)
		{
			if (fullresizeContainer[0]==document.getElementById(idname)) {
				cancelResize();
			}
			thisNode=document.getElementById(idname);
			thisNode.parentNode.removeChild(thisNode);
		}
	}else{
		idname.parentNode.removeChild(idname);
	}
    sizeFader();
}
function returnRoundedBox(id,title,content,centerText,zindex,width,removeWhichArray,withClose,withoutFadeDown) {
	output="<table id='"+id+"' style='position:absolute;z-index:"+zindex+";width:"+width+"px' cellspacing=0 cellpadding=0>";
	output+="<tr><td class='tl'>&nbsp;</td><td class='t'>&nbsp;</td><td class='tr'>&nbsp;</td></tr>";
	output+="<tr><td class='l'>&nbsp;</td><td class='c' "+((imgfolder=="malskin")?"style='padding:10px'":"")+">";
	if (title!="" || withClose) {
		output+="<div class=\"blockHeader\">";
		removeThese="";
		if (removeWhichArray!=null) {
			rems=removeWhichArray.split(",");
			if (removeWhichArray!=null) for(i=0;i<rems.length;i++) removeThese+=";removeTheNode('"+rems[i]+"')";
		}
		if (withClose) {
			//output+="<div class='closebut' onclick=\"";
			output+="<img src=\"/"+imgfolder+"/close.png\" style=\"cursor:pointer;float:right;margin:0px;\" alt=\"Close\" onmouseover='this.src=\"/"+imgfolder+"/closeover.png\"' onmouseout='this.src=\"/"+imgfolder+"/close.png\"' onclick=\"";
			if (!withoutFadeDown || withoutFadeDown==null) {
				output+="startFadeDown();";
			}
			//output+="removeTheNode('"+id+"');"+removeThese+"\">&nbsp;</div>";
			output+="removeTheNode('"+id+"');"+removeThese+"\" />";
		}
		output+=title+"</div>";
	}
	output+="<div class=\"blockContent\" style=\"text-align:"+(centerText?"center":"left")+"\">"+content+"</div>";
	
	output+="</td><td class='r'>&nbsp;</td></tr>";
	output+="<tr><td class='bl'>&nbsp;</td><td class='b'>&nbsp;</td><td class='br'>&nbsp;</td></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];
	if (obj.style.position=="fixed") st=0;
    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 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) {
	if (typeof(obj)=="string") {
    	thisresize=objid(obj);
	}else{
		thisresize=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") {
        fullresizeContainer.push(document.getElementById(container));
        fullresizeObj.push(thisresize);
        fullresizeObjContents.push(content);
        if (fullresizeObj.length==1) startResizeCentered();
    }else{
        thisresize.innerHTML=content;
    }
}
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);
            }
        }
    }else{
        clearTimeout(fullresizeTimer);
        fullresizeTimer=null;
    }
    
}
function cancelResize() {
    fullresizeObj[0].innerHTML="Cancelling";
    clearTimeout(fullresizeTimer);
    fullresizeTimer=null;
    fullresizeObj.shift();
    fullresizeObjContents.shift();
    fullresizeContainer.shift();
    if (fullresizeObj.length>0) startResizeCentered();
}
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 pressingEnter(e,handler) {
    if (window.event) {
        e=window.event;
        keycode=window.event.keyCode;
    }else{
        keycode=e.which;
    }
	if (keycode==13) handler();
}
function refreshPage(reply) {
	window.location.reload();
}
function isChild(parentObj,childObj) {
	reply=false;
	if (childObj!=document.body && childObj!=null) {
		if (childObj==parentObj) {
			reply=true;
		}else{
			if (childObj.parentNode==parentObj) {
				reply=true;
			}else{
				if (childObj.parentNode!=document.body) {
					reply=isChild(parentObj,childObj.parentNode);
				}
			}
		}
	}
	return reply;	
}
function rollOut(src,e,target) {
	closeit=false;
	if (window.event) {
		e=window.event;
		if (!src.contains(e.toElement)) {
			closeit=true;
		}
	}else{
		if (!isChild(src,e.relatedTarget)) {
			closeit=true;
		}
	}
	if (closeit) {
		if (document.getElementById(target).style.display=="block") toggleExpansion(target, false, true,"");
	}
}
function reloadPage(reply) {
	if (reply=="ok") {
		window.location.reload();
	}else{
		alert(reply);
	}
}
function receivedSectionContent(reply) {
	if (reply!="ok" && reply!="") {
		sect=reply.split("<sections>");
		for(i=0;i<sect.length;i++) {
			ss=/^<scripting>/;
			if (ss.test(sect[i])) {
				eval(sect[i].replace('<scripting>',''));
			}else{
				ins=/<insert>/;
				if (ins.test(sect[i])) {
					ip=sect[i].split("<insert>");
					ats=/^<appendtostart>/;
					cont=null;
					if (ats.test(ip[0])) {
						ip[0]=ip[0].replace('<appendtostart>','');
						if (cont=document.getElementById(ip[0])) ip[1]+=cont.innerHTML;
					}
					ats=/^<appendtoend>/;
					cont=null;
					if (ats.test(ip[0])) {
						ip[0]=ip[0].replace('<appendtoend>','');
						if (cont=document.getElementById(ip[0])) ip[1]=cont.innerHTML+ip[1];
					}
					if (cont==null) cont=document.getElementById(ip[0]);
					if (cont!=null) {
						setInnerHTML(cont,ip[1]);
					}
				}else{
					rep=/<replace>/;
					if (rep.test(sect[i])) {
						ip=sect[i].split("<replace>");
						if (src=document.getElementById("block"+ip[0])) {
							pasteRawHTML("<div id=\"tempcontainer\" style=\"display:none\">"+ip[1]+"</div>",document.body);
							newsrc=document.getElementById("tempcontainer").childNodes[0];
							src.parentNode.insertBefore(newsrc,src);
							removeTheNode(src);
							removeTheNode("tempcontainer");
						}
					}else{
						alert(reply);
					}
				}
			}
		}
	}
}
function getIndex(arr,obj) {
	index=-1;
	for(i=0;i<arr.length;i++) if (arr[i]==obj) index=i;
	return index;
}
function checkAlphaNumericOnly(e,enterHandler,email) {
    if (window.event) {
        e=window.event;
        keycode=window.event.keyCode;
    }else{
        keycode=e.which;
    }
	asc=e.charCode || e.keyCode;
	c=String.fromCharCode(asc);
	valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	reply=false;
	if (valid.indexOf(c)>=0) reply=true;
	if (keycode==9) reply=true; //tab
	if (email) {
		if (keycode==189) reply=true; //tab underscore and dash
		if (keycode==16 || keycode==192) reply=true;
		if (keycode==190 || keycode==110) reply=true;
	}else{
		if (keycode==32) reply=true; // space
	}
	if (keycode>95 && keycode<106) reply=true; //keypad
	if (keycode==8 || keycode==46 || keycode==36 || keycode==35 || keycode==37 || keycode==39) reply=true;
	if (keycode==13 && enterHandler!=null) enterHandler();
	return reply;
}
function checkNumericOnly(e,enterHandler) {
    if (window.event) {
        e=window.event;
        keycode=window.event.keyCode;
    }else{
        keycode=e.which;
    }
	asc=e.charCode || e.keyCode;
	c=String.fromCharCode(asc);
	valid="0123456789";
	reply=false;
	if (valid.indexOf(c)>=0) reply=true;
	if (keycode>95 && keycode<106) reply=true; //keypad
	if (keycode==9) reply=true; //tab
	if (keycode==8 || keycode==46 || keycode==36 || keycode==35 || keycode==37 || keycode==39) reply=true;
	if (keycode==13 && enterHandler!=null) enterHandler();
	//if (!reply) alert(keycode);
	return reply;
}
function checkDomainValid(e,enterHandler) {
    if (window.event) {
        e=window.event;
        keycode=window.event.keyCode;
    }else{
        keycode=e.which;
    }
	asc=e.charCode || e.keyCode;
	c=String.fromCharCode(asc);
	valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/.";
	reply=false;
	if (valid.indexOf(c)>=0) reply=true;
	if (keycode==9) reply=true; //tab
	//if (email) {
		if (keycode==189) reply=true; //tab underscore and dash
		if (keycode==16 || keycode==192) reply=true;
		if (keycode==190 || keycode==110) reply=true;
	//}else{
	//	if (keycode==32) reply=true; // space
	//}
	if (keycode>95 && keycode<106) reply=true; //keypad
	if (keycode==8 || keycode==46 || keycode==36 || keycode==35 || keycode==37 || keycode==39) reply=true;
	if (keycode==13 && enterHandler!=null) enterHandler();
	return reply;
}
function focusID(id) {
	setTimeout(function(){document.getElementById(id).select();},1000);
}
function pressingEnterOrEscape(srcObj,e,enterhandler,escapehandler) {
    if (window.event)
    {
        e=window.event;
        keycode=window.event.keyCode;
    }else{
        keycode=e.which;
    }
	if (keycode==13) enterhandler(srcObj);
	if (keycode==27) escapehandler();
}
function encodeUpload(ip) {
	return ip.replace(/&/g,"(amp)").replace(/=/g,"(eq)").replace(/%/g,"(per)").replace(/\+/g,"(plus)").replace(/ /g,"+");
}
function objid(id) {
	return document.getElementById(id);
}
function ClipBoard(txt) {
	ht=objid("holdtext");
	ht.value=objid("shrunken").value;
	ht.select();
	Copied = ht.createTextRange();
	Copied.execCommand("Copy");
}
function getFlashMovie(movieName) {
	return swfobject.getObjectById(movieName);
}
function imageLoader(imgs) {
	for(i=0;i<imgs.length;i++) {
		img=document.createElement("IMG");
		img.src=imgs[i];
	}
}
function showLoading(srcObj,message) {
	w=srcObj.clientWidth;
	h=srcObj.clientHeight;
	ins="<table cellspacing=0 cellpadding=0><tr><td style='width:"+w+"px;height:"+h+"px;text-align:center;vertical-align:middle'><img src='/"+imgfolder+"/loading.gif' /><br>"+message+"</td></tr></table>";
	srcObj.innerHTML=ins;
}
function eventLocation(e) {
	if (window.event) {
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}else{
		x = e.clientX + window.scrollX;
		y = e.clientY + window.scrollY;
	}
	return [x,y];
}
function getLeft(oElement) {
	var iReturnValue = 0;
	var lastAbsolute=false;
	while( oElement != null ) {
		if (oElement.style) {
			if (oElement.style.position=="absolute") {
				if (oElement.style.left) {
					iReturnValue += 1*oElement.style.left.replace("px","");
				}else{
					iReturnValue += oElement.offsetLeft;
				}
				if (oElement.offsetParent.style.position=="relative") {
					oElement = oElement.offsetParent;
				}else{
					oElement=null;
				}
			}else{
				iReturnValue += oElement.offsetLeft;
				oElement = oElement.offsetParent;
			}
		}else {
			iReturnValue += oElement.offsetLeft;
			oElement = oElement.offsetParent;
		}
	}
	return iReturnValue;
}

function showUpload(gallery,ref,maxfiles) {
	withoutFader=false;
	if (document.getElementById("editregion")!=null) withoutFader=true;
	if (!withoutFader) startFadeUp();
	if (maxfiles==null) maxfiles=1;
	toInsert=embeduploader("gallerytype="+gallery+"&ref="+ref,"galleryUploaded",maxfiles);
	h=(maxfiles*50)+20+25;
	toInsert="<div style=\"width:300px;height:"+h+"px;overflow:hidden\">"+toInsert+"</div>";
	toInsert=returnRoundedBox("uploading","Upload your banner file...",toInsert,true,20,320,"",true,true);
    pasteRawHTML(toInsert,document.body);
    centerObject(document.getElementById("uploading"));
}
function galleryUploaded(gallerytype,ref) {
	
	if (document.getElementById("editregion")==null) startFadeDown();
	removeTheNode("uploading");
	if (gallerytype=="article") {
		sendPostRequest('/index.php','cmd=reloadArticleImages&articleid='+ref,receivedSectionContent);
	}
}
function embeduploader(theCommand,completedHandler,maxfiles) {
    params=new Array();
    vars=new Array();
    params.push("width");
    vars.push("300");
    params.push("height");
    vars.push("600");
    params.push("src");
    vars.push("/"+imgfolder+"/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("transparent");
    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("/"+imgfolder+"/uploader.swf");
    params.push("salign");
    vars.push("");
    params.push("FlashVars");
	fv=theCommand+"&completeHandler="+completedHandler+"&quantity="+maxfiles+"&"+document.cookie.replace(/; /g,"&");
    vars.push(fv);
    return flashCode("/"+imgfolder+"/uploader.swf",params,vars);
}
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;
}