//Header
// performs search by the value entered in SearchValue input control.
function goSearch()
{
	// find SearchValue input control
	var sv = document.getElementById('SearchValue');
	if (sv)
		window.location.href = 'searchresults.aspx?wcsearch=' + sv.value; // redirect to SearchResults.aspx page with a search keyword
}

// Invokes search button's click event when 'Enter' key is pressed.
function ClickSubmit(evt)
{
	// check if 'Enter' key was pressed
	if(evt.keyCode==13) 
	{
		// find input with id 'gobutton'
		var GoBtnId=document.getElementById('goButton');
		if (GoBtnId != null)
			goSearch(); // invoke click event
	}
}

var customBrowserWidth = 750; // specify the width of the browser area
var customBrowserHeight = 800; // specify the height of the browser area
document.cookie="clientScreenWidth="+ customBrowserWidth.toString();
document.cookie="clientScreenHeight="+ customBrowserHeight.toString();
customRoomplannerWidth=957; // specify the width for the room planner applet

// Here is a code to determine whether user is logged on.
// Element with 'loggedinas' id must be present in the header file.

// Element with 'welcomemsg' id is added in inside 'loggedinas' element when user is logged on.
function et01_isLoggedOn() {
	var msgEle = document.getElementById('welcomemsg');
	if(msgEle == null)
	{
		// if user is not logged on
		// we need to updated links for register, login and favorties anchors
		var regA = document.getElementById('register');
		if(regA)
			regA.setAttribute('href', 'CreateAccount.aspx?caller=' + window.location.protocol + '//' + window.location.host + '/HomePage.aspx');

		var loginA = document.getElementById('login');
		if(loginA)
			loginA.setAttribute('href', 'Login.aspx?caller=' + window.location.protocol + '//' + window.location.host + '/HomePage.aspx');

		var favA = document.getElementById('favoritesUrl');
		if(favA)
			favA.setAttribute('href', 'Login.aspx?caller=' + window.location.protocol + '//' + window.location.host + '/Favorites.aspx?event=showFavorites');
	}
	else
	{
		// if user is logged on
		// then we hide register anchor
		var regEle = document.getElementById('register');
		if(regEle)
			regEle.style.display = 'none';

		// and we hide login anchor
		var loginEle = document.getElementById('login');
		if(loginEle)
			loginEle.style.display = 'none';

		// and show "View Account" anchor
		var viewAccountEle = document.getElementById('viewAccountLink');
		if(viewAccountEle)
			viewAccountEle.style.display = 'inline';
	}
}


//Footer
function gup( name )
	{
	  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  name = name.toLowerCase();
	  var url = window.location.href.toLowerCase();
	  var regexS = "[\\?&]"+name+"=([^&#]*)";
	  var regex = new RegExp( regexS );
	  var results = regex.exec( url );
	  if( results == null )
		return null;
	  else
		return results[1];
	}

	var crumb = document.getElementById('spnsiteCompass');
	var itemBrowserForm = document.getElementById('OffsetForm');
	if (crumb && itemBrowserForm){
		var searchBanner = document.getElementById('searchBanner');
		var imageName = null;
		
		var category = gup('Category');
		if (!category){
			category = gup('f_15');
			if (!category){
				category = gup('Type');
			}
			if (!category){
				category = gup('f_0');
			}
		}
	}
	
$(document).ready(function(){
    
   $("#categoryindex_expand").toggle(function(){
     $("#template01_Category_Index").slideDown('slow');
   },function(){
     $("#template01_Category_Index").slideUp('slow');
   });

  });  
  
    $(document).ready(function(){
    
   $("#siteindex_expand").toggle(function(){
     $("#template01_siteindex").slideDown('slow');
   },function(){
     $("#template01_siteindex").slideUp('slow');
   });


  });
