function clearText() 
{ 

  document.getElementById("Search_txtSearch").value ="";
  //document.form.theSearch_txtSearch.value = ""; 
  //document.form.Search2_txtSearch.value = ""; 
}     

// commented out because it involves a second txt field, which at this moment we dont' have.
function resetText() 
{ 
//	if(document.forms[0].theSearch_txtSearch.value.length == 0){
//		document.forms[0].theSearch_txtSearch.value = document.forms[0].Search2_txtSearch.value;
//	} else{
//		document.forms[0].Search2_txtSearch.value = document.forms[0].theSearch_txtSearch.value;
//	}
//
}  

function ReturnNoSubmit(e) 
{	
  if(e == null || e.keyCode == null) {
    if(event == null) {
	  return false;
	}
	else {
	  if(event.keyCode == 13) {
	    return false;
	  }
	}
  }
  else if (e.keyCode == 13) {
    return false;
  }
  
  return true;
}

function KeyDownHandler(e) 
{
  if(e == null || e.keyCode == null) {
	return false;
  }
  if (e.keyCode == 13) { 
  
     //The following conditional is due to IE wanting to process the form, when
     //enter is pressed while selecting a suggestion with the enter key, before the
     //suggestion is populated in the search box.  The prevents this handler from
     //being processed while the suggestion box is open.
     if(actb_display) {
		return false;
	 }
  
     resetText();
     		 
	  if (e.target) {
	    targ = e.target;
	  } else if (e.srcElement) {
			targ = e.srcElement;
		}
				
		if (targ.nodeType == 3){   // defeat Safari bug 
			targ = targ.parentNode;
		}
		
		//alert(targ.id.indexOf("Search"));
		
		//	alert(document.getElementById(targ.id).value);
    if(targ.id.indexOf("Search")!=-1 ){
		//	if(e.srcElement.id=='AFLLeftMenu1_theSearch_txtSearch' )
		  var txtSearchObj=document.getElementById(targ.id);
			var txtSearchKey=txtSearchObj.value;
			var strLen=txtSearchKey.length;
						
						//To find whether '<' character is there in the search string
						if(txtSearchKey.indexOf("<")!=-1)
						{
							var index=txtSearchKey.indexOf("<");
							index=index+1
							if(index<strLen)
							{
								alert("Potentially unsafe content!Please modify the Search KeyWord");
								return false;
							}
						}
						//For handling situation if search string is too long
						if(strLen>100)
						{
							alert("The Search key word is too long.Please Enter a valid key word");
							return false;
						}
						var flag=false;
						if(txtSearchKey!=""&&txtSearchKey!=null)
						{
							//search string is not null
							for(var i=0;i<strLen;i++)
							{
								if(txtSearchKey.charAt(i)!=" ")
								{
									flag=true;
								}
							}
							if(flag==false)
							{
								//search string is having nothing other than blank spaces
								alert("Please Enter a valid search key word");
								return false;
							}
						}
						else
						{
							//search string is null
							alert("Please Enter a search key word");
							return false;
						}
						var btn = document.getElementById("Search_imgbtnSearch");
e.cancelBubble = true;
e.returnValue = false;
	
						btn.focus();
   					btn.click();
					}
				}
			}
			
			function SearchValidation(event)
			{	
				if(event.srcElement == null || event.srcElement.id=='Search_imgbtnSearch' )
				{
					var txtSearchObj=document.getElementById("Search_txtSearch")
					var txtSearchKey=txtSearchObj.value;
					var strLen=txtSearchKey.length;

					//To find whether '<' character is there in the search string
					if(txtSearchKey.indexOf("<")!=-1)
					{

						var index=txtSearchKey.indexOf("<");
						index=index+1;
						if(index<strLen)
						{
							alert("Potentially unsafe content!Please modify the Search KeyWord");
							return false;
						}
					}

					//For handling situation if search string is too long
					if(strLen>100)
					{
						alert("The Search key word is too long.Please Enter a valid key word");
						return false;
					}
					var flag=false;
					if(txtSearchKey!=""&&txtSearchKey!=null)
					{
						//search string is not null
						for(var i=0;i<strLen;i++)
						{
							if(txtSearchKey.charAt(i)!=" ")
							{
								flag=true;
							}
						}
						if(flag==false)
						{
							//search string is having nothing other than blank spaces
							alert("Please Enter a valid search key word");
							return false;
						}
					}
					else
					{
						//search string is null
						alert("Please Enter a search key word");
						return false;
					}
					
					document.getElementById("Search_txtSearch").name = "Search:txtSearch";
				}
			}			

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]');"  */
/* 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;

  properties = (wname == "custserv") ? properties.replace(new RegExp(/toolbar=0/g),"toolbar=1") : properties;
  child = window.open(url,wname,properties);
  child.focus();  
}

function swap(img,isrc) {
  if (!document.images) return;

	if( document.images[img] != null ) 
	  document.images[img].src = isrc;
}
			
function ShowLogOutPopUP() {
  open_popup("LogOutPopUp.aspx","350","250","1","1","logout");
//  window.showModalDialog("LogOutPopUp.aspx",null, "dialogWidth=350px;dialogHeight=250px")
}

//Script taken from http://www.multicastmedia.com/Launchers/KNOTLaunch.js to link to the KnotTV
document.write('<SCRIPT LANGUAGE=JavaScript>var javascript_version = 1.0;</SCRIPT>');
document.write('<SCRIPT LANGUAGE=JavaScript1.1>javascript_version = 1.1;</SCRIPT>');
document.write('<style>.launcher {border:0; cursor: pointer; cursor: hand;}</style>');

var newwin;
function LaunchKNOT()
{
var winname;
var winurl;
var winfeatures;
winfeatures = "width=352, height=708, resizable=0"
winurl = "http://www.multicastmedia.com/launchers/KNOTTV.htm";
	newwin = window.open(winurl,winname,winfeatures);
	if(javascript_version > 1.0)
	{
 		setTimeout('newwin.focus();',250);
	}
}

//START functions for shortcut toolbar  -- for wc toolbar
	var firsttext='Planning Checklist'
	var secondtext='Wedding Website'
	var thirdtext='Wedding Scrapbook'
	var fourthtext='Guest List Manager'
	var fifthtext='Budget Calculator'

	function writetext(shortcut){
	document.getElementById('shorttext').innerHTML=''+shortcut+'';

	}
	function notext(){
	document.getElementById('shorttext').innerHTML='Tools';
	}

// end of functions for shortcut toolbar

function CustomerServicePopup(anchor) 
{
	open_popup(anchor.href, 300, 550, "0", "1", "CustomerService");
	return false;
}
