//*** This code is copyright 2002-2003 by Gavin Kistner and Refinery Inc.; www.refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt


// Find the x,y location in pixels for a relatively positioned object
// returns an object with .x and .y properties.
function FindXY(obj){
	var x=0,y=0;
	while (obj!=null){
		x+=obj.offsetLeft-obj.scrollLeft;
		y+=obj.offsetTop-obj.scrollTop;
		obj=obj.offsetParent;
	}
	return {x:x,y:y};
}

// Find the x,y location in pixels for a relatively positioned object
// returns an object with .x, .y, .w (width) and .h (height) properties.
function FindXYWH(obj){
	var objXY = FindXY(obj);
	return objXY?{ x:objXY.x, y:objXY.y, w:obj.offsetWidth, h:obj.offsetHeight }:{ x:0, y:0, w:0, h:0 };
}

//*** End copyrighted code


function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// fadeDirection is a global variable used to minimize visual stuttering during fadeIn/fadeOut loops.
fadeDirection = 1;
balloonOpacity = 0;
itemOpacity = 0;


balloonCopyArray = new Array (
"Someday, information will be in me.",
"This item is very much like the first one, but is lower down on the page. Moreover, the contents of this balloon contain considerably more text than the other one."
)

function showBalloon(invokerId) {
	invokerNum = parseInt(invokerId.split('_')[1]);
	theBalloon = document.getElementById('balloon');
	theBalloonCopy = document.getElementById('balloonCopy');
	theBalloonCopy.innerHTML = balloonCopyArray[invokerNum];
	showItem('balloon',invokerId,'topright');
}


function showBalloonHelp(invokerId, helpText) {
	invokerNum = parseInt(invokerId.split('_')[1]);
	theBalloon = document.getElementById('balloon');
	theBalloonCopy = document.getElementById('balloonCopy');
	theBalloonCopy.innerHTML = helpText;
	showItem('balloon',invokerId,'topright');
}

function showPriceRange(invokerId, priceRangeType) {
	invokerNum = invokerId.split("_")[1];
	
	theBalloon = document.getElementById("balloon");
	theBalloonCopy = document.getElementById("balloonCopy");
	
	var copyString = (priceRangeType == "Bride_Price") ?
		"Price Range: " + showPriceRange._priceBride["_" + invokerNum] :
		"Price Range: " + showPriceRange._priceOther["_" + invokerNum] ;
		
	if (copyString.indexOf("undefined") == -1) {

		theBalloonCopy.innerHTML = copyString;
		
		showItem("balloon", invokerId, "topright");

	} else {
	/* This empty array prevents later functions from trying to un-hide page elements that were never hidden to begin with. */
		tempHidden["balloon"] = new Array();

	}
	
}
showPriceRange._priceBride = {
	"_$" : "$500 and under",
	"_$$" : "$501 - $1000",
	"_$$$" : "$1001 - $1500",
	"_$$$$" : "$1501 - $3000",
	"_$$$$$" : "$3001 and up"
}
showPriceRange._priceOther = {
	"_$" : "$80 and under",
	"_$$" : "$81 - $150",
	"_$$$" : "$151 - $250",
	"_$$$$" : "$251 - $300",
	"_$$$$$" : "$301 and up"
}


function findXYPos(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

// global object for tracking elements which need to be invisibled during a DHTML popup (Flash containers, SELECTs in IE, etc.)
// members are named after item ID's, and are Arrays of objects that need to be hidden for that ID
var tempHidden = new Object;

function showItem(faderId,invokerId,positionVH,offsetX,offsetY) {
	// The 'positionVH' argument currently accepts one of five values:
	// 'topleft', 'topright', 'bottomleft', 'bottomright', or null.
	if (undefined == offsetX) { offsetX = 0; }
	if (undefined == offsetY) { offsetY = 0; }
	theFader = FindXYWH(document.getElementById(faderId));
	theInvoker = FindXYWH(document.getElementById(invokerId));
	invokerElement = document.getElementById(invokerId);
	faderWidth = theFader.w;
	faderHeight = theFader.h;
	invokerWidth = theInvoker.w;
	invokerHeight = theInvoker.h;
	invokerPosX = findPosX(invokerElement);
	invokerPosY = findPosY(invokerElement);
	// If no position is specified, put the fader in the center of the screen.
	if (undefined == positionVH) {
		document.getElementById(faderId).style.left = document.body.offsetWidth/2 - faderWidth/2 + 'px';
		document.getElementById(faderId).style.top = document.body.offsetHeight/2 - faderHeight/2 + 'px';
	} else {
		//...Otherwise set default position as 'center'/'middle'
		newFaderPosX = invokerPosX + invokerWidth/2 - faderWidth/2;
		newFaderPosY = invokerPosY + invokerHeight/2 - faderHeight/2;
		//...And then check to see if a specific alignment has been requested.
		if (positionVH.indexOf('top') != -1) { newFaderPosY = invokerPosY - faderHeight; }
		if (positionVH.indexOf('bottom') != -1) { newFaderPosY = invokerPosY + invokerHeight; }
		if (positionVH.indexOf('left') != -1) {	newFaderPosX = invokerPosX - faderWidth; }
		if (positionVH.indexOf('right') != -1) {	newFaderPosX = invokerPosX + invokerWidth; }
		document.getElementById(faderId).style.left = newFaderPosX + offsetX +'px';
		document.getElementById(faderId).style.top = newFaderPosY + offsetY + 'px';
	}

	tempHidden[faderId] = new Array();
	
	// any not-already-hidden SELECT elements outside the item to be shown will need to be hidden in IE6
	if(navigator.userAgent.indexOf('MSIE') != -1) {
		var allSelects = document.getElementsByTagName("select");
		var excludeSelects = document.getElementById(faderId).getElementsByTagName("select");
		for (var i=0; i < allSelects.length; i++) {
			var exclude = false;
			for (var j=0; j < excludeSelects.length; j++) {
				if (allSelects[i] == excludeSelects[j]) {
					exclude = true;
					break;
				}
			}
			
			// if select is not viewable, or is descendant of such an element, exclude it
			var j=allSelects[i];
			do {
				if (j.style.visibility == 'hidden' || j.style.display == 'none') {
					exclude = true;
					break;
				}
			} while (j = j.parentElement);
		
			if (!exclude) tempHidden[faderId].push(allSelects[i]);
		}
	}
	
	// Flash containers will need to be hidden in all browsers
	var allFlash = getElementsByRegex('class', 'flashContainer');
	for (var i=0; i < allFlash.length; i++) {
		tempHidden[faderId].push(allFlash[i]);
	}
	
	// hide what needs to be hidden
	for (var i=0; i < tempHidden[faderId].length; i++) {
		if (tempHidden[faderId][i].style) {
			tempHidden[faderId][i].style.visibility = 'hidden';
		}
	}
	
	fadeDirection = 1;
	fadeIn(faderId);
	if(faderId != 'balloon' && faderId != 'dateballoon'){page.reloadAssets();} // reload all ads and stats based on user interaction with the page.
}

function hideItem(faderId) {
	fadeDirection = -1;
	fadeOut(faderId);
	
	// restore anything we had to temporarily hide
	var obj;
	while (obj = tempHidden[faderId].pop()) {
		if (obj.style) {
			obj.style.visibility = 'visible';
		}
	}
	delete tempHidden[faderId];
	if(faderId != 'balloon' && faderId != 'dateballoon'){page.reloadAssets();} //reload all ads and stats based on user interaction with the page.
}

function fadeIn(objId) {
  if (itemOpacity < 0) { itemOpacity = 0; }
  if (fadeDirection == 1) {
    obj = document.getElementById(objId);
	obj.style.visibility = 'visible';
    if (itemOpacity <= 100) {
      setOpacity(obj, itemOpacity);
      itemOpacity += 10;
      window.setTimeout("fadeIn('"+objId+"')", 30);
    }
  }
}

function fadeOut(objId) {
  if (itemOpacity > 100) { itemOpacity = 100; }
  if (fadeDirection == -1) {
    obj = document.getElementById(objId);
    if (itemOpacity >= 0) {
      setOpacity(obj, itemOpacity);
      itemOpacity += -10;
      window.setTimeout("fadeOut('"+objId+"')", 15);
    } else { 
    	obj.style.visibility = 'hidden'; 
    }
  }
}

//page 2

function toggleLine(num) {
// NB: For the sake of brevity, this function assumes that the 'selected' class
// will only be applied to DIVs that already have an existing class.
	//var numberExp = /[0-9]+/g;
	//if ( numberExp.test(num) ) 
	if (typeof num == "number")
	{
		var thisDivId = "line" + num;
		prevClassname = document.getElementById(thisDivId).className;
		if (prevClassname.indexOf('selected') != -1) {
		 newClassname = prevClassname.substring(0,(prevClassname.indexOf('selected') - 1));
		 document.getElementById(thisDivId).getElementsByTagName('span')[0].innerHTML = '&#9658;';
		} else {
		 newClassname = prevClassname + ' selected';
		 document.getElementById(thisDivId).getElementsByTagName('span')[0].innerHTML = '&#9660;';
		}
		document.getElementById(thisDivId).className = newClassname;
	} // close if num equals number
	else if ( num == "showAll" || num == "hideAll" )
	{
			// collect all of the <div>s as an array
			var divArray = document.getElementsByTagName('div');
			// loop through the array
			 for (var i=0; i < divArray.length; i++) 
			 {
			   // check for divs with line IDs assigned to them
			   if(divArray[i].id.indexOf('line') != -1)
				{ 
					var thisDivId = divArray[i].id;
					var prevClassname = document.getElementById(thisDivId).className;
					var spanArray = document.getElementById(thisDivId).getElementsByTagName('span');
					if (num == 'showAll')
					{
						var newClassname = prevClassname + ' selected';
				 		for (var j=0; j < spanArray.length; j++)
						{
					
								if ( spanArray[j].className == 'r0') 
								{
									spanArray[j].innerHTML = '&#9660;';
								}
						}
						document.getElementById(thisDivId).className = newClassname;
					}
					if (num == 'hideAll')
					{
						if (prevClassname.indexOf('selected') != -1) 
						{
							newClassname = prevClassname.substring(0,(prevClassname.indexOf('selected') - 1));
							for (var j=0; j < spanArray.length; j++)
							{
								if ( spanArray[j].className == 'r0') 
								{
									spanArray[j].innerHTML = '&#9658;';
								}
							}
							document.getElementById(thisDivId).className = newClassname;
						}
					}
				} // close if statement
			 } // close for loop
	} // close else if num equals showAll or hideAll
	page.reloadAssets(); // reload all ads and stats based on user interaction with the page.
} // close toggleLine function

// Parse URL string for variables
function parseQueryString (str) {
  str = str ? str : location.search;
  var query = str.charAt(0) == '?' ? str.substring(1) : str;
  var args = new Object();
  if (query) {
	var fields = query.split('&');
	for (var f = 0; f < fields.length; f++) {
	  var field = fields[f].split('=');
	  args[unescape(field[0].replace(/\+/g, ' '))] = unescape(field[1].replace(/\+/g, ' '));
	}
  }
  return args;
}
// usage: var args = parseQueryString (); args['c'] would equal URL variable 'c'

/******************************************

var pqs = new ParsedQueryString();

pqs.param( name )
  Returns the string value associated with name (name is case sensitive). If
  name was not defined in the query string, returns undefined. If multiple
  values were associated with name, returns the first value from the order it
  occurs in the query string.
  
  e.g., QUERY-STRING: "hello=world&hello=hi&foo=bar"
  pqs.param('hello') returns "world"
  pqs.param('foo') returns "bar"
  pqs.param('not there') returns undefined

pqs.params( [ name ] )
  Returns an array for all values associated with name (name is case
  sensitive). If name was not defined in the query string, returns null. If
  name is omitted, returns an array of every name in the query string.
  
  e.g., QUERY-STRING: "hello=world&hello=hi&foo=bar"
  pqs.params('hello') returns ["world", "hi"]
  pqs.params('foo') returns ["bar"]
  pqs.params('not there') returns null
  pqs.params() returns ["hello", "foo"]

*****************************/

String.prototype.decodeURL = function() {
    return unescape(this.replace(/\+/g, " "));
}

function ParsedQueryString() {
    var parameters = {};
    
    parse();
    function parse() {
        var parts = window.location.search.substr(1).split(/[&;]/);
        for (var i = 0; i < parts.length; ++i) {
            var pair = parts[i].split(/=/);
            var name = pair[0].decodeURL();
            var value = pair[1] != undefined ? pair[1].decodeURL() : undefined;
            if (parameters[name] == undefined)
                parameters[name] = [value];
            else
                parameters[name].push(value);
        }
    }
    
    this.param = function(name) {
        return parameters[name] != undefined ? parameters[name][0] : undefined;
    }
    
    this.params = function(name) {
        if (arguments.length)
            return parameters[name] != undefined ? parameters[name] : null;
        else {
            var pnames = [];
            for (var p in parameters)
                pnames.push(p);
            return pnames;
        }
    }
}

dateballoonOpacity = 0;



function showdateballoon_lrm(invokerId) {
	theBalloon = document.getElementById('dateballoon');
	newInvokerId = "info" + invokerId;
	showItem('dateballoon',newInvokerId,'topleft');
}

function showdateballoon(invokerId) {
//	invokerNum = parseInt(invokerId.split('_')[1]);
	theBalloon = document.getElementById('dateballoon');
	newInvokerId = "info" + invokerId;
//	theBalloonCopy = document.getElementById('dateballoonCopy');
//	theBalloonCopy.innerHTML = balloonCopyArray[invokerNum];
	showItem('dateballoon',newInvokerId,'topright');
}

function hidedateballoon() {
	fadeDirection = -1;
	// IE BUG-FIX show form SELECT when DIV is hidden
	var selNodes = document.getElementsByTagName('select')
	var i=0;
	if (!selNodes.item(0)){
		return false;
	} else {
		do {
			selNodes.item(i).style.visibility = 'visible';}
		while (++i < selNodes.length);
	}	
	fadeOut('dateballoon')
}


// Calendar functionality
function KW_cal_class(m,d,y,d1,d2,mn,c) { // v1.3.0
	this.o="";this.dsp="";this.m=m;this.d=d;this.y=y;this.d1=d1;this.d2=d2;
	this.mn=mn,this.sy=((y%100)<10)?"0"+(y%100):(y%100);this.mm=(m<10)?"0"+m:m;this.c=c
	this.dd=(d<10)?"0"+d:d;	iD=new Date(y,(m-1),d);eD=new Date();eD.setMilliseconds(0)
	eD.setHours(0);eD.setMinutes(0);eD.setSeconds(0);this.ofs=parseInt((eD-iD)/86400000)
	this.gC=function(){iD=new Date(this.y,(this.m-1),this.d);sD=this.dsp.toString()
	retVal="on";if (sD.indexOf("<a")!=0)retVal="off";if (iD.getDay()==0||iD.getDay()==6)
	if (sD.indexOf("<a")!=0)retVal="wkendoff";else retVal="wkendon";if (this.c==0)
	if (sD.indexOf("<a")!=0)retVal="ntmoff";else retVal="ntmon";if (this.ofs==0) 
	retVal="today";	if (this.spc()==true)retVal="special";return "kw_cal_"+retVal;}
	this.spc=function(){var retVal=false;dc=document;if (dc.kw_sp){ for (var i=0;i<dc.kw_sp.length;i++){
	if (this.m==dc.kw_sp[i].m&&(this.y==dc.kw_sp[i].y||dc.kw_sp[i].y=="*")&&this.d==dc.kw_sp[i].d)
	retVal=true;}} return retVal;}
}

function KW_setThisDisplay(f,n,d,o,a1,a2,a3,a4,w,l,sd){ // v1.4.0
	var rV="<a href=\"javascript:window.opener.KW_setCalendar('"+f+"',"+n+",'"+l+"');hidedateballoon(); window.close();\">"+d+"</a>";
	if ((a1==1&&o>0)||(a1==-1&&o<1)||(a1==2&&o>=0)) rV=d;if (a2>0) {if (o<=-a2) rV=d;} 
	else if (a2<0) {if (o>=-a2) rV=d;}if (a3!=-1) {ss=a3.split("|");if (ss[w]==1) rV=d} 
	if (a4>0) {if (o>=-a4 && o<0) rV=d;} if (a4<0) {if (o<=-a4 && o>0) rV=d; } if (sd) {
	rV=d} return rV;
}

function KW_date_class(m,d,y) {this.m=m;this.d=d;this.y=y;}

function KW_setCalendar(obj,n,l) { // v1.3.0
	dc=document;dO=dc.tMh[n];if (obj.indexOf("|")==-1)MM_findObj(obj).value=dO.o;
	else {oS=obj.split("|");tV= new Array(dO.m,dO.d,dO.y);for(var i=0;i<3;i++) {
	tO=MM_findObj(oS[i]);dc.KW_calYear=dO.y;for (var j=0;j<tO.options.length;j++)
	if (tO.options[j].value==tV[i]) tO.selectedIndex=j;}}dc.KW_calMonth=dO.m-1;
	if (l!=''){o=MM_findObj(l);v="hide";if (o.style){o=o.style; v='hidden'} o.visibility=v}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function KW_setDel(val) { // v1.3.1
	return (val.match(/\.gif$|\.png$|\.jpg$|\.jpeg$/i))?"<img src=\""+val+"\" class=\"kw_img\">":val
}

function KW_expertCalendar(){ // v1.4.1 
	var dc=document,a=KW_expertCalendar.arguments,d=new Date();d.setDate(1); if (a[29]!=-1) 
	d.setMonth(a[29]);else if (dc.KW_calMonth) d.setMonth(dc.KW_calMonth);cMn= d.getMonth(); 
	pMt=((cMn-1)<0)?11:cMn-1;nMh=((cMn+1)>11)?0:cMn+1;if (a[30]!=-1) d.setFullYear(a[30]);
	else if (dc.KW_calYear) d.setYear(dc.KW_calYear);cYr=d.getFullYear();pYr=(pMt==11)?cYr-1:cYr;
	nYr=(nMh==0)?cYr+1:cYr;wdy=d.getDay();dc.tMh=new Array();if (a[25]==1) wdy=((--wdy)<0)?6:wdy;
	tpM=new Date(d.getFullYear(),d.getMonth(),d.getDate()-wdy);for (var i=0;i<wdy;i++) {
	n=dc.tMh.length;dc.tMh[n]= new KW_cal_class((tpM.getMonth()+1),tpM.getDate(),tpM.getFullYear(),
	a[21],a[23],a[tpM.getMonth()],0);dc.tMh[n].o=eval("dc.tMh["+n+"]."+a[20])+dc.tMh[n].d1+
	eval("dc.tMh["+n+"]."+a[22])+dc.tMh[n].d2+eval("dc.tMh["+n+"]."+a[24]);	dc.tMh[n].dsp=
	(a[31]==1)?"&nbsp;":KW_setThisDisplay(a[19],n,tpM.getDate(),dc.tMh[n].ofs,a[26],a[27],
	a[28],a[42],tpM.getDay(),a[41],(dc.tMh[n].spc() && a[45]==1));tpM.setDate(tpM.getDate()+1)}EOM=false;for (var i=1;!EOM;i++) {
	n=dc.tMh.length;dc.tMh[n]=new KW_cal_class((d.getMonth()+1),d.getDate(),d.getFullYear(),
	a[21],a[23],a[d.getMonth()],1);;dc.tMh[n].o=eval("dc.tMh["+n+"]."+a[20])+dc.tMh[n].d1+
	eval("dc.tMh["+n+"]."+a[22])+dc.tMh[n].d2+eval("dc.tMh["+n+"]."+a[24]);
	dc.tMh[n].dsp=KW_setThisDisplay(a[19],n,d.getDate(),dc.tMh[n].ofs,a[26],a[27],a[28],a[42],
	d.getDay(),a[41],(dc.tMh[n].spc() && a[45]==1));d.setDate(d.getDate()+1);if (d.getDate()==1) EOM=true;} wdy=d.getDay();
	if (a[25]==1) wdy=((--wdy)<0)?6:wdy;for (var i=wdy;i<7;i++) {n=dc.tMh.length;
	dc.tMh[n]= new KW_cal_class((d.getMonth()+1),d.getDate(),d.getFullYear(),a[21],a[23],
	a[d.getMonth()],0);dc.tMh[n].o=eval("dc.tMh["+n+"]."+a[20])+dc.tMh[n].d1+
	eval("dc.tMh["+n+"]."+a[22])+dc.tMh[n].d2+eval("dc.tMh["+n+"]."+a[24]);
	dc.tMh[n].dsp=(a[31]==1)?"&nbsp;":KW_setThisDisplay(a[19],n,d.getDate(),dc.tMh[n].ofs,
	a[26],a[27],a[28],a[42],d.getDay(),a[41],(dc.tMh[n].spc() && a[45]==1));d.setDate(d.getDate()+1);} 
	ns4 =(dc.layers)?true:false;px=(ns4||window.opera)?'':'px';s=a[32];if (a[33]==-1) 
	{ww=window;d="document.getElementById('"+a[32].name+"')";k=1;x=0;y=0;xpos=0;ypos=0;
	iM=(navigator.appVersion.indexOf("Mac")==-1);p=".offsetParent";if (dc.getElementById) {
	if (!eval(d)) {d=d.replace(/.getElementById/,".getElementsByName")}
	while (eval(d+p)) {	x+=parseInt(eval(d+p+".offsetLeft"));
	y+=parseInt(eval(d+p+".offsetTop"));p+=".offsetParent";}ox=parseInt(s.offsetLeft);
	oy=parseInt(s.offsetTop);} else {x=parseInt(screen.height/2-75);ox=0;oy=0;
	y=parseInt(screen.width/2-75);}xp=parseInt(x+ox),yp=parseInt(y+oy+20);
	winW=(ns4)?window.innerWidth-16:dc.body.offsetWidth-20;
	winH=(ns4)?window.innerHeight:dc.body.offsetHeight;if (dc.all && iM) winH+=dc.body.scrollTop
	if ((xp+a[35])>winW) xp=winW-a[35]; if ((yp+a[36])>winH) yp=winH-a[36];	
	if (a[41]=='') {if (isNaN(ww.screenX)) {xp=xp-dc.body.scrollLeft+ww.screenLeft;
	yp=yp-dc.body.scrollTop+ww.screenTop;}else {xp=xp+ww.screenX+
	(ww.outerWidth-ww.innerWidth)-ww.pageXOffset;yp=yp+ww.screenY+
	(ww.outerHeight-24-ww.innerHeight)-ww.pageYOffset;	}if (!iM && dc.all)
	{ xp=xp-dc.body.scrollLeft;yp=yp-dc.body.scrollTop}}a[33]=xp;a[34]=yp}
	str="<html><head><title>"+a[cMn]+" "+cYr; accs="<a class=\"kw_cal_a\" ";
	str+="</title></head><link href=\""+a[43]+"\" rel=\"stylesheet\" type=\"text/css\" />"
	str+="<body style=\"margin:0; background-color:"+a[44]+";\">";if (a[41]!='' && !ns4) str="";
	str+="<table class=\"kw_cal_tbl2\" border=0 cellspacing=0 cellpadding=2><tr><td colspan=\"7\">"
	str+="<table width=\""+(a[35]-10)+"\" border=0 cellspacing=0 cellpadding=2 class=\"kw_cal_tbl2\">";
	endStr="','"+a[31]+"',0";for(ix=33;ix<37;ix++)endStr+=","+a[ix];for(ix=37;ix<46;ix++)
	endStr+=",'"+a[ix]+"'";bStr="";for (var j=0;j<29;j++) bStr+="'"+a[j]+"',";
	aStr1=bStr+"'"+pMt+"','"+pYr+endStr;aStr2=bStr+"'"+nMh+"','"+nYr+endStr;str+="<tr><td "
	str+="class=\"kw_cal_mnth\">"+accs+"href=\"javascript:window.opener.KW_expertCalendar("+aStr1;
	str+=")\">"+KW_setDel(a[37])+"</a>"+a[cMn]+accs+"href=\"javascript:window.opener.KW_expertCalendar("
	str+=aStr2+")\">"+KW_setDel(a[38])+"</a></td>";aStr1=bStr+"'"+cMn+"','"+(cYr-1)+endStr;
	aStr2=bStr+"'"+cMn+"','"+(cYr+1)+endStr;str+="<td class=\"kw_cal_yr\">"+accs
	str+="href=\"javascript:window.opener.KW_expertCalendar("+aStr1+")\">"+KW_setDel(a[39])+"</a>"
	str+=cYr+accs+"href=\"javascript:window.opener.KW_expertCalendar("+aStr2+")\">"
	str+=KW_setDel(a[40])+"</a></td></tr></table></td></tr><tr>"
	for (var i=(a[25]==1)?13:12;i<19;i++) str+="<td class=\"kw_cal_wktitle\">"+a[i]+"</td>";
	if (a[25]==1) str+="<td class=\"kw_cal_wktitle\">"+a[12]+"</td>";str+="</tr>";
	for (var i=0;i<dc.tMh.length;i++) {if ((i)/7==parseInt((i)/7)) str+="<tr>"; 
	tdClass=dc.tMh[i].gC();temp=dc.tMh[i].dsp.toString();tdActive=(temp.indexOf("<a")!=-1)?"id='kwon'":"";
	str+="<td class=\""+tdClass+"\" "+tdActive+">"+dc.tMh[i].dsp+"</td>"
	if ((i+1)/7==parseInt((i+1)/7))str+="</tr>";}str+=(a[41]==''&&!ns4)?"</table></body></html>":"</table>";
	if (a[41]!='' && !ns4) {t=MM_findObj(a[41]);v="show";if (t.style) { t=t.style; v='visible'}
	t.visibility=v;	t.left=xp+px;t.top=yp+px;while (str.indexOf('window.opener.')!=-1)
	str=str.replace('window.opener.','');p1=str.indexOf(" window.close();"); while (p1!=-1) {
	str=str.substring(0,p1)+str.substring(p1+16);p1=str.indexOf(" window.close();")}
	MM_findObj(a[41]).innerHTML=str;} else {var nnx=(ns4)?1.25:1;var look='width='+(a[35]*nnx)
	look+=',height='+(a[36]*nnx)+',left='+a[33]+',top='+a[34];
	popwin=window.open('','calendar',look);	with(popwin.document){open();write(str);close();}}
}

function getEl(id) {
    if (document.layers) { return document.layers[id]; }
    else if (document.all) { return document.all[id]; }
    else if (document.getElementById) { return document.getElementById(id); }
}
function openWin(url) {
    var win = window.open(url,'newWindow','width=450,height=400,menubar=yes,location=no,statusbar=yes,personalbar=no,scrollbars=yes,resize=yes');
}
function openWinVSize(url,width,height) {
    var win = window.open(url,'newWindow','width='+width+',height='+height+',menubar=no,location=no,statusbar=no,personalbar=no,scrollbars=yes,resize=yes');
}

function replaceSpan(ht,hd,hs){						

	var newSpan = document.createElement("span");

	if (ht) {

		var newText = document.createTextNode(ht);

	} else {

		// Default text for headline

		var newText = document.createTextNode("Contact Brides.com");

	}

	newSpan.appendChild(newText);						

	var para = document.getElementById(hd);

	var spanElm = document.getElementById(hs);

	var replaced = para.replaceChild(newSpan,spanElm);

}


function getElementsByRegex (attr, regex) {
	if (attr == 'class') attr = 'className';
	var myRegex = new RegExp('\\b' + regex + '\\b');
	var allTags = document.getElementsByTagName('*');
	var matches = new Array();
	for (i=0; i<allTags.length; i++) {
		if ( myRegex.test( eval('allTags[i].' + attr) ) ) {
			matches.push(allTags[i]);
		}
	}
	return matches;
}

function addClass(obj, classValue) {
	if (obj && obj.className) {
		var alreadyThere = false;
		var classArr = new Array;
		classArr = obj.className.split(' ');
		for (var i=0; i<classArr.length; i++) {
			if (classArr[i] == classValue) {
				alreadyThere = true;
			}
		}
		if (! alreadyThere) {
			classArr.push(classValue);
			var newClassName = classArr.join(' ');
			obj.className = newClassName;
		}
	} else if (obj) {
		obj.className = classValue;
	}
}

function removeClass(obj, classValue) {
  if (obj && obj.className) {
    var wasThere = false;
    var classArr = new Array;
    classArr = obj.className.split(' ');
    for (var i=0; i<classArr.length; i++) {
      if (classArr[i] == classValue) {
        classArr.splice(i, 1);
        wasThere = true;
        break;
      }
    }
    if (wasThere) {
      var newClassName = classArr.join(' ');
      obj.className = newClassName;
    }
  }
}



//this function is a wrapper used to reload ads and stats. don't remove it - dan
// to use this call page.reloadAssets(); 
page={
 reloadAssets:function(args) {
  GetStatsData(undefined, true); //HACK: "undefined" are you kidding me... bad idea!
  cnp.ad.property.reloadAds()
 },
 trackFlash:function(altURI) { // this is used in a JCPenney flash promotion that needs to track flash activity as pageviews 
   if(altURI == undefined) { altURI = document.location.pathname;}
   GetStatsData(altURI, true);
 }
}
isSafari = cnp.util.browser.isSafari(); // HACK fix gallery detail js code

/* 
 * Dan Holly Wells / Adam Fahy
 * this function used to store events until the userData object is returned by the DWR call the function
 * userDataEventRegistry.run is called header.jsp by the userData.load callback function. 
 */  
userDataEventRegistry={
	list:[],
	add:function(item) {
		if(userData != undefined) {
			new Function(item)();
		} else {
			userDataEventRegistry.list.push(item);
		}
	},
	run:function() {
		if (userDataEventRegistry.list.length != 0){
			for(i=0;i<userDataEventRegistry.list.length;i++) {
				new Function(userDataEventRegistry.list[i])();
			}
		}
	}
}


//onload page queue function.
function WindowOnload(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
  }
  
  
//this is for the local link in the header.  it will redirect users to the local landing page they are localized as.
//the href action should be /local the onClick action should be this function
function localizedLocal() {
 if(link_location != 'national') {
  window.location = '/local/'+link_location;
 } else {
  window.location = '/local/';
 }
}

// To compensate for the unexpected behavior of the "infinite height" layout method,
// this function scrolls the page to an object with the specified ID.
function scroll2Anchor(divName) {
	if (obj = document.getElementById(divName)) {
		yAmount = findPosY(obj);
		self.scrollTo(0, yAmount);
	}
}

/* populate search box if the user has preformed a search */
function populateSearchString() {
var pqs = new ParsedQueryString();
 if (typeof pqs.param('search_string') != 'undefined') {
	search_string = pqs.param('search_string');
	$('searchField').value = search_string;
 }
}
WindowOnload(populateSearchString)

function searchOnSubmit() {
 $('searchField').value = $('searchField').value.toLowerCase()
	if ($('searchField').value == 'search') {
		$('searchField').value = '';
	}	
}


/*
//////////////////////////////////
// CFG STARTS
// Configure refresh (in seconds)
var refreshinterval=60
var refreshcap = Math.floor(Math.random()*11);
if (refreshcap <= 4) {refreshcap = 5};
// CFG ENDS
/////////////////////////////////

var starttime
var nowtime
var reloadseconds=0
var secondssinceloaded=0
var reloadcount=0

function pandora() {
	if (document.location.href.match('forums') != null) {
		starttime=new Date(); starttime=starttime.getTime(); countdown();
	}
}

function countdown() {
	nowtime= new Date();
	nowtime=nowtime.getTime();
	secondssinceloaded=(nowtime-starttime)/1000;
	reloadseconds=Math.round(refreshinterval-secondssinceloaded);
	if (refreshinterval>=secondssinceloaded) {
		var timer=setTimeout("countdown()",1000);
	} else if (reloadcount != refreshcap){
      clearTimeout(timer)
		page.reloadAssets();
		//alert('what did you do ray?');
		pandora();
		reloadcount++
    } 
}
WindowOnload(pandora);
 */
 
function clearSelect(selectId) {
    var selectObj = document.getElementById(selectId);
    if (selectObj) {
        for (var i=0; i<selectObj.options.length; i++) {
            selectObj.options[i].selected = false;
        }
    }
}

/* returns string in format MM/DD/YYYY given a date object such as userData.weddingDate
* used in contact a vendor popup */ 
function formatMMDDYYYY(dateObj) { 
	var dateStr = "";
	if (typeof(dateObj) == "object") {
		var dateArr = ["", "", String(dateObj.getFullYear())];		
		var monthNum = dateObj.getMonth() + 1;
		var dateNum = dateObj.getDate();
		
		dateArr[0] = String(monthNum);
		dateArr[1] = String(dateNum);
		
		if (monthNum < 10) {
			dateArr[0] = "0" + dateArr[0];	
		}
		if (dateNum < 10) {
			dateArr[1] = "0" + dateArr[1];
		}
		dateStr = dateArr.join("/");			
	} 
	return dateStr;
}






/* Begin ================================= 
HACK: AMEX Adunit
HACK: remove after Feb 1 2008 
   ==================================== */
function loadAmaxUnit(link) {
  
  var AMEXheadlineBox=parent.document.getElementById('headlineTree');
  var AMEXnewa=document.createElement('a');
  var AMEXnewimg=document.createElement('img');
  AMEXnewimg.src='http://ad.doubleclick.net/1287943/starwood_10.5logo.gif'; // path to starwood image
  AMEXnewimg.alt='Starwood'; // add special alt text
  AMEXnewa.appendChild(AMEXnewimg);
  AMEXnewa.className='absoluteSponsor';
  AMEXnewa.target='_new';
  AMEXnewa.href=link;
  if(AMEXheadlineBox != null) {
    AMEXheadlineBox.appendChild(AMEXnewa);
  }
}    
/*   =======================================
HACK: AMEX Adunit
HACK: remove after Feb 1 2008 
   ================================ End */