function open_popup(url, w, h, resize, scroll,wname) {
/* place this in onclick or href:  "javascript:open_popup('[url]','[width of window]','[height of window]','[resize option]','[scroll opiton]','[windowname]');"  */
  wname = (wname == null) ? "popwin" : wname.replace(new RegExp(/ /g), "");
  
  scroll = ((scroll == null)||(scroll=='')||(scroll==1)||(scroll=='1'))? 'yes':'no';
  resize = ((resize == null)||(resize=='')||(resize==1)||(resize=='1'))? 'yes':'no';
  var properties = "toolbar=0,scrollbars="+scroll+",location=0,statusbar=1,menubar=0,resizable="+resize;
  properties += ",width="+ w +",height="+ h;
  child = window.open(url,wname,properties);
  child.focus();
}

function openurl(url){
  window.location = url;
}

function gotoSite(site) {
	if  (site != "") {
		window.parent.opener.location=site;
	}
	window.parent.opener.focus();
}


//DYNAMIC PULL-DOWN
/* <form><select name="mySelect" onChange="goSelect(this);">[options]</select>[submit]</form>*/

function goSelect(thisselect){
	if (thisselect.selectedIndex > 0){
		var url = thisselect.options[thisselect.selectedIndex].value;
		if (url != '') window.location = url;
	}
}

//DYNAMIC PULL-DOWN LINKING OUTSIDE OF AN IFRAME - target = new
/* <form><select name="menu" onchange="frameSelect(this.form)">[options]</select>[submit]</form> */

function frameSelect(form) {
var myindex=form.menu.selectedIndex
	if (form.menu.options[myindex].value != "0") {
		window.open(form.menu.options[myindex].value, 
		target="newframe");
	}
}

//
/* */

//DYNAMIC PULL-DOWN LINKING OUTSIDE OF AN IFRAME - target = top
/* <form><select name="iframemenu" onchange="iframeSelect(this.form)">[options]</select>[submit]</form> */

function iframeSelect(form) {
var myindex=form.iframemenu.selectedIndex
	if (form.iframemenu.options[myindex].value != "0") {
		window.open(form.iframemenu.options[myindex].value, 
		target="_top");
	}
}

//
/* */

function chooseFrame(thisselect) {
	if (thisselect.selectedIndex > 0)
	{

		if( thisselect.options[thisselect.selectedIndex].value.indexOf("http://",0) != -1 )
		{
			var url = thisselect.options[thisselect.selectedIndex].value;
			if (url != '') window.parent.location = url;
		}
		else
		{
			var url = thisselect.options[thisselect.selectedIndex].value;
			if (url != '') window.location = url;
		}
	}	
}


//SELECT PULL-DOWN WITH SUBMIT BUTTON 
/* <form name="formname"><select name="selectname">[options]</select><input onClick="return gotoURL()"></form> */

function gotoURL() {
     var Current = document.formname.selectname.selectedIndex;
     window.location.href = document.formname.selectname.options[Current].value;
     return false;
}

//ROLLOVERS

function swap(img,isrc) {
   if (!document.images) return;

   if( document.images[img] != null ) 
	  document.images[img].src = isrc;
}

//INPUT BUTTON ROLLOVERS
/* <input hoversrc="[image]"> */

var MWJ_img_cache = new Object();
for( var i = 0; i < 2; i++ ) {
	var ar = i ? ( document.getElementsByTagName ? document.getElementsByTagName('input') : ( document.all ? document.all.tags('INPUT') : [] ) ) : document.images;
	for( var x = 0; ar[x]; x++ ) {
		var im = ar[x];
		if( im.getAttribute ) { im.hoversrc = im.getAttribute('hoversrc'); im.activesrc = im.getAttribute('activesrc'); }
		if( im.hoversrc || im.activesrc ) {
			if( !MWJ_img_cache[im.src] ) { MWJ_img_cache[im.src] = new Image(); MWJ_img_cache[im.src].src = im.src; }
			im.rootsrc = im.src;
			im.onmouseout = function () { this.src = this.rootsrc; };
		}
		if( im.hoversrc ) {
			if( !MWJ_img_cache[im.hoversrc] ) { MWJ_img_cache[im.hoversrc] = new Image(); MWJ_img_cache[im.hoversrc].src = im.hoversrc; }
			im.onmouseover = function () { this.src = this.hoversrc; };
		}
		if( im.activesrc ) {
			if( !MWJ_img_cache[im.activesrc] ) { MWJ_img_cache[im.activesrc] = new Image(); MWJ_img_cache[im.activesrc].src = im.activesrc; }
			im.onmousedown = function (e) {
				e = e ? e : window.event;
				if( e.button > 1 || e.which > 1 ) { return; }
				this.src = this.activesrc;
			};
			im.onmouseup = function (e) {
				e = e ? e : window.event;
				if( e.button > 1 || e.which > 1 ) { return; }
				this.src = this.hoversrc ? this.hoversrc : this.rootsrc;
			};
		}
	}
}


//POP UP WINDOW BASED ON COOKIE
/* Put this code in the page:
<script language="javascript" type="text/javascript"> 
var page="pagename.html";
var windowprops = " width=x, height=y, location=no, toolbar=no, menubar=no, scrollbars=1, resizable=1";
var cookiecount = "new value";
window.onload=checkCount; 
</script>*/

var expDays = 9999; 

function GetPopupCookie (name) { 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	
	while (i < clen) { 
		var j = i + alen; 
		
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1;  
		if (i == 0) break; 
	} 
	
	return null;
}

function SetPopupCookie (name,value) {
	var argv = SetPopupCookie.arguments;
	var argc = SetPopupCookie.arguments.length;   
	var expires = (argc > 2) ? argv[2] : null;   
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;   
	var secure = (argc > 5) ? argv[5] : false; 
	document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
} 

function DeletePopupCookie (name) { 
	var exp = new Date(); exp.setTime (exp.getTime() - 1); 
	var cval = GetPopupCookie (name);  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
} 

var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); 

function amt(){
	var count = GetPopupCookie(cookiecount);  
	if(count == null){
		SetPopupCookie(cookiecount,'1'); return 1;
	} else { 
		var newcount = parseInt(count) + 1;   
		DeleteCookie(cookiecount); 
		SetPopupCookie(cookiecount,newcount,exp); 
		return count;
	}
}

function getCookieVal(offset) {
	var endstr=document.cookie.indexOf(";",offset);
	if(endstr==-1)endstr=document.cookie.length; 
	return unescape(document.cookie.substring(offset,endstr));
}

function checkCount() {
	var count=GetPopupCookie(cookiecount);	
	if(count==null||expDays==-1) { 
		count=1;
		SetPopupCookie(cookiecount,count,exp);
		window.open(page,"",windowprops); 
	} else{ 
		count++;SetPopupCookie(cookiecount,count,exp);
	}
}

// SLIDESHOW
/* Put this code in the page:
<a href="#" onClick="toggle('div1',1); toggle('div2',0); toggle('div3',0); return false;"><img src="image" border="0"></a>*/

function toggle(id,fff) {
if (fff=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (fff=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}

//NAVIGATION DROPDOWNS
var menuList = new Array("droppc", "dropge", "droprw", "dropac", "dropfa", "dropbe", "dropmm", "dropgg", "drophm");
navNames = new Array("pc", "ge", "rw", "ac", "fa", "be", "mm", "gg", "hm");
var timer = 'null';
function showMenu(MenuName) {
	//alert(MenuName);
	clearTimeout(timer);
	hideMenus();
	document.getElementById(MenuName).style.visibility = 'visible';
}

function hideMenus() {
	for(i=0;i < menuList.length;i++) {
	document.getElementById(menuList[i]).style.visibility = 'hidden';
	}
}
function OverLayer() {
	clearTimeout(timer);
}

function OutLayer() {
	clearTimeout(timer);
	timer = setTimeout("hideMenus();",300);
}

//IMAGE PRECACHING    
if (document.images) {
    // create "normal" Image object, populate with and set URLs for the "normal" images
    var navimgurl = "http://images.theknot.com/topnav/";
    
    var imagesNormal = new Object( );
    
	
	// create "on" Image object, populate with and set URLs for the "on" images
    var imagesOn = new Object( );
	
	// create "over" Image object, populate with and set URLs for the "over" images
    var imagesOver = new Object( );
	
}

// LIBERTY TRAVEL POPUP
/* Put this code in the page in the body:
<body onLoad="libertyTravelPop();">*/

function SetLTCookie (name,value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) + ((expires) ? "; expires=" + expdate.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
}

function GetLTCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	var j;
	
	while (i < clen) {
		j = i + alen;
		if (document.cookie.substring(i, j) == arg){
			return (getCookieVal(j));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	
	return null;
}

function libertyTravelPop()
{
  return false; // deactivating Liberty Travel popup just in case I missed any invocations

	if( GetLTCookie("this") == null )
	{
		open_popup("http://www.theknot.com/libertytravelpop.html","400","360","0","0","LibertyTravel");
		SetLTCookie("this","that",null,null,"theknot.com", null );
	}
}


/* old js functions brought over */
function popTool(poptoolurl){
  open_popup(poptoolurl, "600", "550", "1", "1", "poptool_local")
}

function AddOnload(myfunc) {
	if(window.addEventListener) {
		window.addEventListener('load', myfunc, false);
	} else if(document.addEventListener) {
		document.addEventListener('load', myfunc, false);
	} else if(window.attachEvent) {
		window.attachEvent('onload', myfunc);
	}
}