
google.setOnLoadCallback(function() {
	jQuery.cookie = function(name, value, options) {
	    if (typeof value != 'undefined') { // name and value given, set cookie
	        options = options || {};
	        if (value === null) {
	            value = '';
	            options.expires = -1;
	        }
	        var expires = '';
	        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
	            var date;
	            if (typeof options.expires == 'number') {
	                date = new Date();
	                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
	            } else {
	                date = options.expires;
	            }
	            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
	        }
	        // CAUTION: Needed to parenthesize options.path and options.domain
	        // in the following expressions, otherwise they evaluate to undefined
	        // in the packed version for some reason...
	        var path = options.path ? '; path=' + (options.path) : '';
	        var domain = options.domain ? '; domain=' + (options.domain) : '';
	        var secure = options.secure ? '; secure' : '';
	        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
	    } else { // only name given, get cookie
	        var cookieValue = null;
	        if (document.cookie && document.cookie != '') {
	            var cookies = document.cookie.split(';');
	            for (var i = 0; i < cookies.length; i++) {
	                var cookie = jQuery.trim(cookies[i]);
	                // Does this cookie string begin with the name we want?
	                if (cookie.substring(0, name.length + 1) == (name + '=')) {
	                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
	                    break;
	                }
	            }
	        }
	        return cookieValue;
	    }
	};
	
	
  $(function() {
	  $(document).ready(function() {

		clearPrevious = '';
		
		  $("#s").focus(function() {
			if($(this).val() == "Enter Keywords")
			{
					clearPrevious = $(this).val();
					$(this).val('');
			}
			
			});
			
			$("#s").blur(function() {
				if($(this).val()=='')
				{
					$(this).val(clearPrevious);
				}
			});
			
		  
		  
		  $("#searchform").submit(function(event) {
			  
			  if ($("#s").val() == 'Enter Keywords')
			  {
		  			event.preventDefault();
		  			$("#s").focus();
					
		  			 return false; 
			  }
			  else {
			  return true;
			  }
					
		  });

		  // Google Analytics Virtual Page Tracking
			$("#ClickAndChat.com_chat_link").click(function() {
				pageTracker._trackPageview('/thank-you/live-chat/header/');				
			});
			$(".askaquestion").click(function() {
				pageTracker._trackPageview('/thank-you/live-chat/sidebar/');				
			});
			$(".homepage_TCO-clicks").click(function() {
				pageTracker._trackPageview('/test/homepage/TCO-Clicks/');
			});			
			
			
//		  <a id="ClickAndChat.com_chat_link" href="https://server1.clickandchat.com/chat/chatstart.htm?domain=www.omnivue.net" target="_blank"><img border="0" src="http://server1gateway.clickandchat.com/stat.gif?u=44-1289347545450&amp;d=www.omnivue.net&amp;p='http%3A//64.88.168.110/'&amp;r=''&amp;response=g&amp;timestamp=1290016107577"></a>
		  /* 
		   * 
		   * 
		   * REgistration

		   * 
		   *    Gated Download
		   *    
		   *   http://forms.omnivue.net/af2?LinkID=CH00095628eR00000033AD

		   *   
		   */
		 // $("#salesfusion_offer").hide();
		 
			// site-wide offer
		  $("#salesfusion_offer").append('<IFRAME id="sfId" width=200 height=750 >');
		    // original 
			//$('iframe#sfId').attr('src', 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000040AD');
			// modified to pass UTMZ vars - feb 2011
			var urlDialog = 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000060AD';
			var urlUTMZ = '&ga_source=' + source + '&ga_medium=' + medium + '&ga_term=' + term + '&ga_content=' + content + '&ga_campaign=' + campaign + '&ga_segment=' + csegment + '';	
			var url = urlDialog+''+urlUTMZ;
		    $('iframe#sfId').attr('src', url);
		    $('iframe#sfId').hide();
		    $('iframe#sfId').load(function() 
		    {
		    	$("#salesfusion_offer_loading").fadeOut(function () {
		    		 $('iframe#sfId').show();
		    		$("#salesfusion_offer").fadeIn();
		    	});
		    	
		    	
		        //callback(this);
		    });

		// contact us page
		  $("#salesfusion_contactus").append('<IFRAME id="sfId_contactus" width=400 height=450 >');
			var urlDialog = 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000037AD';
			var urlUTMZ = '&ga_source=' + source + '&ga_medium=' + medium + '&ga_term=' + term + '&ga_content=' + content + '&ga_campaign=' + campaign + '&ga_segment=' + csegment + '';	
			var url = urlDialog+''+urlUTMZ;
		    $('iframe#sfId_contactus').attr('src', url);
		    $('iframe#sfId_contactus').hide();
		    $('iframe#sfId_contactus').load(function() 
		    {
		    	$("#salesfusion_offer_loading_contactus").fadeOut(function () {
		    		 $('iframe#sfId_contactus').show();
		    		$("#salesfusion_contactus").fadeIn();
		    	});
		        //callback(this);
		    });

		  // variable dialog url
		  // salesfusion_iframe_variable();
		  $("#salesfusion_variable").append('<IFRAME id="sfId_variable" width=400 height=750 >');
			// get the URL from the url attribute of div
			var urlDialog = $("#salesfusion_variable").attr('url');
			// var urlDialog = 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000037AD';
			var urlUTMZ = '&ga_source=' + source + '&ga_medium=' + medium + '&ga_term=' + term + '&ga_content=' + content + '&ga_campaign=' + campaign + '&ga_segment=' + csegment + '';	
			var url = urlDialog+''+urlUTMZ;
		    $('iframe#sfId_variable').attr('src', url);
		    $('iframe#sfId_variable').hide();
		    $('iframe#sfId_variable').load(function() 
		    {
		    	$("#salesfusion_offer_loading_variable").fadeOut(function () {
		    		 $('iframe#sfId_variable').show();
		    		$("#salesfusion_variable").fadeIn();
		    	});
		        //callback(this);
		    });

			
			
			/* ################## I DONT THINK ANY OF THIS GATED JS WORKS ##################### */
		    

			  $("#salesfusion_gate_offer").append('<IFRAME id="sfId2" width=200 height=700   scrolling=no >');
				// original
				// $('iframe#sfId2').attr('src', 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000032AD');
				// modified to pass UTMZ vars - feb 2011
				var urlDialog = 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000032AD';
				var urlUTMZ = '&ga_source=' + source + '&ga_medium=' + medium + '&ga_term=' + term + '&ga_content=' + content + '&ga_campaign=' + campaign + '&ga_segment=' + csegment + '';	
				var url = urlDialog+''+urlUTMZ;
				$('iframe#sfId2').attr('src', url);

			    $('iframe#sfId2').hide();
			    $('iframe#sfId2').load(function() 
			    {
			    	$("#salesfusion_gate_offer_loading").fadeOut(function () {
			    		 $('iframe#sfId2').show();
			    		$("#salesfusion_gate_offer").fadeIn();
			    	});
			    	
			    	
			        //callback(this);
			    });

			    // sidebar gated download mechanism
			   $(".gateddownload").click(function() {
				   
				   try {
				   myhref=$(this).attr('href');
				   gate = $(this).attr('gate');
				   loc = $(this).attr('loc');
				   
				   if (!gate)
				   {
						// original
						// gate = 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000033AD';
						// modified to pass UTMZ vars - feb 2011
						var urlDialog = 'http://forms.omnivue.net/af2?LinkID=CH00095628eR00000033AD';
						var urlUTMZ = '&ga_source=' + source + '&ga_medium=' + medium + '&ga_term=' + term + '&ga_content=' + content + '&ga_campaign=' + campaign + '&ga_segment=' + csegment + '';	
						var url = urlDialog+''+urlUTMZ;
						gate = url;
				   }
				   //alert(myhref);
				   
				   $.cookie("gatedownload", loc, {
					   path: '/',
					   expires: 365
				   	
				   });
				   document.location = gate;
				   
				   }catch (ex) { alert(ex);}
				   
				   /*$.cookie("gateddownload", , {
				        path: '/',
				        expires: 365
				    });*/
				   
				   	return false;
			   });
		    
	  });
  });
  
});


 
	
