// tell-a-friend
var path_to_cgi="https://www.citycreate.com/cgi-bin/tell_friend.cgi";

path_to_cgi += '?url=' + escape(document.location);

function tell_friend(){
window.open(path_to_cgi,"FRIENDS01","STATUS=NO,TOOLBAR=NO,LOCATION=NO,DIRECTORIES=NO,COPYHISTORY=NO,MENU=NO,RESIZABLE=NO,SCROLLBARS=YES,TOP=40,LEFT=20,WIDTH=500,HEIGHT=435");
}

// make Homepage
function makeHomeLink() {
	var isHPTxt='Make Your Home Page';
	var isHPURL = top.location.href;
	var globHtmlFtrSpan='<span id="hp" style="behavior:url(#default#homepage)"></span>';
	var NAV_IE=(navigator.appName.search(/microsoft internet explorer/i) > -1)?true:false;
	if (NAV_IE) {
		return globHtmlFtrSpan + "<font face=arial,verdana size=2 color=000099><a href="+isHPURL+" onClick=\"hp.setHomePage('"+isHPURL+"');\">"+isHPTxt+"</a><br><br></font>";
	} else {
		return "";
	}
}

//faq
function error_handler(a,b,c)
{
 window.status = (a +"\n" + b + "\n\n" + c + "\n\n" + error_handler.caller);
 return true;
}
window.onerror = error_handler;
String.prototype.trim=function(){return this.replace(/(^\s+)|\s+$/g,"");}


self.WD = {
/*begin of functions==============================*/
browser:new Object(),
dull:function (){},


addEvent:function(obj, evType, fn)
{ 
	if (obj.addEventListener)
	{  
		obj.addEventListener(evType, fn, false);  return true; 
	}
	else if (obj.attachEvent)
	{   
		var r = obj.attachEvent("on"+evType, fn); 	
		WD.EventCache.add(obj, evType, fn);
		return r;
	}
	else 
	{
		//Mac IE5 sucks here
		return false;
	} 
},

removeEvent:function (obj, evType, fn)
{ 
	if (obj.removeEventListener){  obj.removeEventListener(evType, fn, false);  return true; }
	else if (obj.detachEvent){   var r = obj.detachEvent("on"+evType, fn);    return r; }
	else { return false; } 
},

getObjById:function(id)
{
	return document.getElementById(id);
},


getChildByClass:function(el,tagName,className)
{
	var els = el.getElementsByTagName(tagName);
	className = className.split(" ");
	for( var i=0;i<els.length;i++)
	{
		for(var c=0;c<className.length;c++)
		{
			if( els[i].className.trim() == className[c].trim() ){ return els[i] ;}
		}		
	}
	return null;
},




getChildByName:function(el,tagName,Name)
{
	var els = el.getElementsByTagName(tagName);
	className = className.split(" ");
	for( var i=0;i<els.length;i++)
	{
		if( els[i].Name == Name){ return els[i] ;}
	}
	return null;
},


getNextObjByTagName:function(el,tagName)
{
	while(el && el.nextSibling)
	{
		el = el.nextSibling;
		if(el.nodeName.toLowerCase()==tagName.toLowerCase()){return el;}
	}		
	return null;
},


getNextPreviousByTagName:function(el,tagName)
{
	while(el && el.previousSibling)
	{
		el = el.previousSibling;
		if(el.nodeName.toLowerCase()==tagName.toLowerCase()){return el;}
	}		
	return null;
},



getObjByClass:function (el,tagName,className,level)
{
	level = level || 1000;
	var p= 0;
	var exit = function(el){ return ( (p>level) || (el==null) || (el.parentNode==null) || (el.tagName==null) || (el.className==null) || (el==document.body) );}
		
	while( !exit(el)  )
	{			
			if( (el.tagName.toLowerCase() == tagName) )
			{
				var c = el.className.split(" ");
				for(var i=0;i<c.length;i++)
				{
					if( (c[i]==className) || (className==""))
					{
						return el;
					}
				}
				
			}
			el = el.parentNode;
			p++;
	}
	return null;
},



getObjByName:function (el,tagName,Name,level)
{
	level = level || 1000;
	var p= 0;
	var exit = function(el){ return ( (p>level) || (el==null) || (el.parentNode==null) || (el.tagName==null) || (el.name==null) || (el==document.body) );}
		
	while( !exit(el)  )
	{			
			if( (el.tagName.toLowerCase() == tagName) && (el.name == Name) )
			{;return el;};			
			el = el.parentNode;
			p++;
	}
	return null;
},





getDimension:function(el)
{
 var d = new Object();
 if(el.getBoundingClientRect)
	{       
	   d.x = el.getBoundingClientRect().left + Math.max(document.body.scrollLeft, document.documentElement.scrollLeft);
	   d.y = el.getBoundingClientRect().top + Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	   d.w = el.getBoundingClientRect().right - el.getBoundingClientRect().left;
	   d.h =  el.getBoundingClientRect().bottom - el.getBoundingClientRect().top;
	}
	else if(document.getBoxObjectFor)
	{
       d.x = document.getBoxObjectFor(el).x;
	   d.y =  document.getBoxObjectFor(el).y;
	   d.w = document.getBoxObjectFor(el).width;
	   d.h = document.getBoxObjectFor(el).height;
	}
	else
	{
			
			function offsetBy(el, type)
			{
			  if (this===el) return 0;
			  var v=999, owner=this, border='client'+type;
			  type = 'offset'+type;
			  do { v += owner[type];  } while ((owner=owner.offsetParent) && owner!==el && (v+=owner[border]))
			  return v-999;
			}
			
			d.x = offsetBy.call(el, null, 'Left');
			d.y= offsetBy.call(el, null, 'Top');
			d.w = el.offsetWidth;
			d.h = el.offsetHeight;
	
	}
	return d;
},

isTagName:function (el,tagName)
{
 return (el.nodeName.toLowerCase() == tagName.toLowerCase() );
},

hasClass:function (el,className)
{
 var c = el.className.split(" ");
 for(var i=0;i<c.length;i++)
	{
		if(c[i] == className){return true;};
	}
	return false;
},



getEvent:function (e)
{
	e = window.event ||e;
	e.leftButton=false;
	
	if(e.srcElement==null && e.target!=null)
	{	
		e.srcElement = e.target ;
		e.leftButton = ( e.button==1);		
	}
	else if(e.target==null && e.srcElement!=null)
	{ 
		e.target = e.srcElement;
		e.leftButton = ( e.button==0);
	}
	else if(e.srcElement!=null && e.target!=null)
	{
		//opera sucks and have both e.srcElement & e.target.
	}
	else{return null}

	e.mouseX = e.pageX || (e.clientX +  Math.max(document.body.scrollLeft, document.documentElement.scrollLeft));
	e.mouseY = e.pageY || (e.clientY + Math.max(document.body.scrollTop, document.documentElement.scrollTop));
	return e;
},



stopEvent:function(e)
{
	if(e && e.cancelBubble!=null)
	{
		e.cancelBubble = true;
		e.returnValue = false;
	}
	if(e && e.stopPropagation && e.preventDefault)
	{
		e.stopPropagation(); 
		e.preventDefault(); 
	}
	return false;
},


addClass:function(el,className)
{
	var c = el.className.split(" ");
	for(var i=0;i<c.length;i++)
	{
		if(c[i]==className){return;};
	}
	if(c.length>0)
	{
		el.className = (el.className + " " +className).trim();
	}
	else
	{
		el.className = className.trim();
	}
},


removeClass:function(el,className)
{
	var c = el.className.split(" ");
	for(var i=0;i<c.length;i++)
	{
		if(c[i]==className){c[i]="";};
	}
	el.className = c.join(" ").trim();
	
}


/*endof functions==============================*/
}

WD.EventCache = function()
{
	var listEvents = [];
	
	return {
		listEvents : listEvents,
	
		add : function(node, sEventName, fHandler, bCapture){listEvents[listEvents.length] = arguments;},
		
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1)
			{
				item = listEvents[i];				
				if(item[0].removeEventListener){item[0].removeEventListener(item[1], item[2], item[3]);};			
				if(item[1].substring(0, 2) != "on"){	item[1] = "on" + item[1];};				
				if(item[0].detachEvent){item[0].detachEvent(item[1], item[2]);};				
				item[0][item[1]] = null;
			};
		}
	};
}();


WD.addEvent(window,"unload",WD.EventCache.flush);
WD.browser["ie"] =  (document.all!=null)  && (window.opera==null); 
WD.browser["ie4"]  =  WD.browser["ie"] && (document.getElementById==null); 
WD.browser["ie5"]  =   WD.browser["ie"] && (document.namespaces==null) && (!WD.browser["ie4"]) ; 
WD.browser["ie6"]  =  WD.browser["ie"] && (document.implementation!=null) && (document.implementation.hasFeature!=null) 
WD.browser["ie55"]  =  WD.browser["ie"] && (document.namespaces!=null) && (!WD.browser["ie6"]); 
WD.browser["ns4"]  = !WD.browser["ie"] &&  (document.layers !=null) &&  (window.confirm !=null) && (document.createElement ==null); 
WD.browser["opera"] =  (self.opera!=null); 
WD.browser["gecko"] =  (document.getBoxObjectFor!=null); 
WD.browser["khtml"] = (navigator.vendor =="KDE"); 
WD.browser["konq"] =  ((navigator.vendor == 'KDE')||(document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)); 
WD.browser["safari"] = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(!navigator.accentColorName); 
WD.browser["safari1.2"] = (parseInt(0).toFixed==null) && (WD.browser["safari"] && (window.XMLHttpRequest!=null)); 
WD.browser["safari2.0"] = (parseInt(0).toFixed!=null) && WD.browser["safari"] && !WD.browser["safari1.2"] ;
WD.browser["safari1.1"] = WD.browser["safari"] && !WD.browser["safari1.2"]  &&!WD.browser["safari2.0"] ;

for(i in self.WD)
{
 if(self[i]==null)
	{
		self[i] = self.WD[i];//synchronize for faster deelopement
	}
}

var ui_accordion = new Object();

ui_accordion["mouseout"] = function ()
{
	removeClass(this,"hover");
	return false;
}

ui_accordion["mousedown"] = function ()
{
	this.timer = setTimeout("void(0)",0);
	var k = 0;			
	var mb = this.mb;
	
	
	var dds = mb.parentNode.getElementsByTagName("dd");
	var dts = mb.parentNode.getElementsByTagName("dt");
	
	if(this.parentNode.getAttribute("standalone")!=null)
	{
		var do_expand = (mb.offsetHeight>1)?false:true;
		var action = function()
		{
			clearTimeout(this.timer);
			if(do_expand)
			{//do expand
				
				if(	mb.offsetHeight < (mb.scrollHeight-5) )
				{
					mb.style.height = Math.ceil( mb.offsetHeight +  (mb.scrollHeight-mb.offsetHeight)/7) + "px";
					this.timer = setTimeout(action,0);
				}
				else
				{
					mb.style.height="auto";
					mb.style.overflow ="visible";
					do_expand = null;
					action = null;
					mb = null;				
				}
			}else{//do collapse;

				if(	 parseInt(mb.style.height) > 3)
				{
					
					mb.style.height = Math.ceil(  parseInt(mb.style.height) +  (- parseInt(mb.style.height))/2) + "px";
					window.status =  mb.style.height + new Date();
					this.timer = setTimeout(action,0);
				}
				else
				{
					mb.style.height="0";
					mb.style.overflow ="hidden";
					mb.style.display = "none";
					do_expand = null;
					action = null;
					mb = null;				
				}
			}
		}

		if(do_expand)
		{//begin expand
			mb.style.height="1px";
			mb.style.overflow ="auto";
			mb.style.display="block";
		}else{//begin collapse;

			mb.style.height= mb.offsetHeight + "px";
			mb.style.overflow ="hidden";
			mb.style.display="block";
			
		
		}
		clearTimeout(this.timer);
		this.timer = setTimeout(action,0);
		return false;
	}
	
	
	var hasExpendedDD = false;
	for(var i=0;i<dds.length;i++)
	{
		dds[i].ddIndex = i;
		var closed,expand,collapse ;
		var collapsed = false;
		
		if( dds[i] == mb)
		{
			
			
			if(dts[mb.ddIndex]){ addClass(dts[mb.ddIndex],"expanding");};
		
			var start = new Date();
			expand = function()
			{	
				clearTimeout(this.timer);
				if(mb.style.display.toLowerCase()!="block")
				{
					mb.style.display="block";
					mb.endHeight =  mb.scrollHeight;
					mb.style.overflow ="hidden";			
				};

				var end = new Date();

				if((mb.offsetHeight < mb.endHeight) && ((end - start)<500))
				{
					mb.style.height = Math.ceil( mb.offsetHeight + (mb.endHeight- mb.offsetHeight)/33 ) + "px";
					this.timer = setTimeout(expand,0);				
				}
				else
				{	
					mb.style.height="auto";
					mb.style.overflow="auto";					
					if(dts[mb.ddIndex]){ removeClass(dts[mb.ddIndex],"expanding");};					
				}
				
			}
			
			
		}else if(dds[i].offsetHeight>0)
		{
		
			hasExpendedDD = true;
			collapsed = true;
			closed = dds[i];
			closed.style.height = closed.offsetHeight+"px";
			closed.style.overflow ="hidden";
			addClass(closed,"collapsing");
		
			if(dts[closed.ddIndex]){ addClass(dts[closed.ddIndex],"collapsing");};
			var start = new Date();
			collapse = function()
			{
				
				clearTimeout(this.timer);
				var ph = parseInt(closed.style.height);
				var end = new Date();
				if((ph > 2) && ((end - start)<200))
				{
					closed.style.height =Math.floor(ph  + (0-ph)/2)  + "px";
					this.timer = setTimeout(collapse,0);
				}else
				{	
					closed.style.height="0";
					closed.style.display="none";
					closed.style.overflow ="visible";
					if(dts[closed.ddIndex])
					{
						removeClass(dts[closed.ddIndex],"collapsing");
						removeClass(closed,"collapsing");
					}

					this.timer = setTimeout(expand,0);
				}
			}
			clearTimeout(this.timer);
			this.timer = setTimeout( collapse,0);
		}
		
	}
	if(collapsed==false){ if(dts[mb.ddIndex]){ removeClass(dts[mb.ddIndex],"expanding");};};
	if(hasExpendedDD == false)
	{
		for(var i=0;i<dds.length;i++)
		{
			closed = dds[i];
			closed.style.height = 0;
			closed.style.overflow ="visible";
			removeClass(closed,"default_close");
			closed.style.display="none";	
			
			
		};
	
		this.timer = setTimeout(expand,0);
	};
	return false;
}



ui_accordion["mouseover"] = function (e,dt,doExpand)
{
 
 var el;
if(dt)
{
	el = dt;
}
else
{
	e =  getEvent(e);
	el =  getObjByClass(e.target,"dt","",2) ;
}

 if(el && el.parentNode && hasClass(el.parentNode,"accordion"))
 {
	var  def = getChildByClass(el.parentNode,"dd","default",1);
	
	if(!def)
	 {
		if(el.parentNode.getElementsByTagName("dd").length>0)
		 {
			var dd = el.parentNode.getElementsByTagName("dd")[0];
			addClass(dd ,"default");
			addClass(dd ,"default_close");			
		 }
		 else{return;}
	 }
	
	if(!doExpand)
	{
		addClass(el,"hover");
	}

	if(el.init==null)
	{
		var mb = getNextObjByTagName(el,"dd");
		if(mb==null){return;}			;
		
		el.mb = mb;		
		el.init = true;
		el.onmouseout =ui_accordion["mouseout"];
		el.onmousedown =ui_accordion["mousedown"];
		el.expand = ui_accordion["mousedown"];
		
	}
	
	if(doExpand)
	{
		el.expand();
	}

	if(e){ return stopEvent(e);}
 }
}



var init = addEvent(document,"mouseover",ui_accordion["mouseover"]);
if(init)
{
 document.write("<style media=\"screen\"> dl.accordion dd{height:0;display:none;}; </style>");
}

function accordion_menu_expand(accordion_header_id)
{
 var el  = document.getElementById(accordion_header_id);
 if(!el){return false;};
 if(el.tagName.toLowerCase()!="dt"){return false;}
 ui_accordion["mouseover"](null,el,true);
}

// popup resize
function getRefToDivMod( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivMod(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return oDoc.getElementById(divID); }
	if( document.all ) { return oDoc.all[divID]; }
	return oDoc[divID];
}

function openPerfectPopup(oW,oTitle,oContent) {
	var x = window.open('','windowName','width=500,height=400,resizable=1');
	if( !x ) { return true; }
	x.document.open();
	x.document.write('<html><head><title>'+oTitle+'<\/title><\/head><body>'+
		(document.layers?('<layer left="0" top="0" width="'+oW+'" id="myID">'):('<div style="position:absolute;left:0px;top:0px;display:table;width:'+oW+'px;" id="myID">'))+
		oContent+(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	x.document.close();
	var oH = getRefToDivMod( 'myID', x.document ); if( !oH ) { return false; }
	var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
	x.resizeTo( oW + 200, oH + 200 );
	var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
	if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
	else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
	else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
	if( window.opera && !document.childNodes ) { myW += 16; }
	x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2));
	if( x.focus ) { x.focus(); }
	return false;
}

//really not important (the first two should be small for Opera's sake)
PositionX = 10;
PositionY = 10;
defaultWidth  = 600;
defaultHeight = 400;

//kinda important
var AutoClose = true;

//don't touch
function popImage(imageURL,imageTitle){
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
		'<img src="'+imageURL+'" alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

