$(function(){
// uncomment to clear emailaddress cookie on page load.  For testing		   
//	$.cookie('emailaddress',null);

// round corners
	$(".roundedcorner").corner();


// code that fires when a user tries to download a whitepaper or success story.
// check to see if cookie exists.  If so, it's just a normal link.  If not, it blocks link and opens register dialog
	var useremail = $.cookie('emailaddress');
	$(".downloadlink").click(function(){
		if (useremail==null){
			$('#registerdialog').dialog('open');
			$.cookie('downloadname',this.id,{expires:60});
			$.cookie('downloadlink',this.href,{expires:60});			
			return false;
		}
	});

// dialogbox for registering whitepapers and success stories
	$("#registerdialog").dialog({ 
    	autoOpen: false, 
        modal: true 
  	}); 

});
/********************************************************/
//jquery dropdown menu
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function mainmenu_open()
{  mainmenu_canceltimer();
   mainmenu_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function mainmenu_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function mainmenu_timer()
{  closetimer = window.setTimeout(mainmenu_close, timeout);}

function mainmenu_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jmainmenu > li').bind('mouseover', mainmenu_open)
   $('#jmainmenu > li').bind('mouseout',  mainmenu_timer)});

document.onclick = mainmenu_close;

//**************************************************************/
//function used by homepage to auto populate input boxes
function autoFill(id, v){
	$(id).css({ color: "#b2adad" }).attr({ value: v }).focus(function(){
		if($(this).val()==v){
			$(this).val("").css({ color: "#333" });
		}
	}).blur(function(){
		if($(this).val()==""){
			$(this).css({ color: "#b2adad" }).val(v);
		}
	});

}
//***********************************************************************************
function submitsearch(){ 
	document.searchform.submit();}
//***********************************************************************************
function loadpage(thepagename){
}
//***********************************************************************************
function getElementHeight(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) { 
			xPos = elem.style.pixelHeight;
		} else {
			xPos = elem.offsetHeight;
		}
		return xPos;
	} 
}
//*****************************************************************************************
String.prototype.trim = function() {
	return this.ltrim().rtrim();
};

String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
//***********************************************************************************