function siteselect(targ,selObj,restore){ 
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function popup_open (href, params)
{
    // Defaults (don't leave it to the browser)
    var defaultParams = {
        "width":       "700",   // Window width
        "height":      "500",   // Window height
        "top":         "50",     // Y offset (in pixels) from top of screen
        "left":        "40",     // X offset (in pixels) from left side of screen
        "directories": "no",    // Show directories/Links bar?
        "location":    "no",    // Show location/address bar?
        "resizable":  "yes",   // Make the window resizable?
        "menubar":     "no",    // Show the menu bar?
        "toolbar":     "no",    // Show the tool (Back button etc.) bar?
        "scrollbars":  "yes",   // Show scrollbars?
        "status":      "no"     // Show the status bar?
    };

    var windowName = params["windowName"] || "new_window";

    var i, useParams = "";

    // Override defaults with custom values while we construct the params string
    for (i in defaultParams)
    {
        useParams += (useParams === "") ? "" : ",";
        useParams += i + "=";
        useParams += params[i] || defaultParams[i];
    }

    return window.open(href, windowName, useParams);
};

function ucwords( str ) {
		 str = str.toLowerCase();
     return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) { return $1.toUpperCase( ); } );
}


$(document).ready(function() {

	$("form.googlesearch").submit(function(){ 
		$("input[@name='q']").val(ucwords($(this).children("input[@name='q']").val()));
	});

	$('.toggler2').click(function() {
		$(this).next().slideToggle('normal');
	});
		
		
	$(".toggler").toggle(function(){
		$(this).css({backgroundImage:"url(http://www.concept2.com/us/images/blue-arrowonly-down.png)",borderBottom:"0",backgroundColor:"#4473AB",color:"#fff"});
		$(this).next().slideDown("fast");
	},function(){
		$(this).next().slideToggle("fast");
		$(this).css({backgroundImage:"url(http://www.concept2.com/us/images/blue-arrowonly-right.png)",borderBottom:"1px solid #4473AB",backgroundColor:"#b7c8d8",color:"#000"});
	}).next().hide();

		
	$(".expander").click(function() {
		var expand = $(this).attr("rel");
		$("#"+expand).slideToggle();
	}); 

    
	var swapValue = $("#search").val();
	$("#search").focus(function(){
		if ($(this).val() == swapValue) {
    	$(this).val("");
    }
	}).blur(function(){
  	if ($.trim($(this).val()) == "") {
    	$(this).val(swapValue);
    }
  });
		
	$('a[rel*=facebox]').facebox();
	$('#facebox').bgiframe();
 
  $("a[rel*=popup]").click(function (){
   // Grab parameters using jQuery's data() method
		var params = $(this).data("popup") || {};            
		if ($(this).attr("target")) {
			params.windowName = $(this).attr("target");
		}
		
		var windowObject = popup_open(this.href, params);
		// Save the window object for other code to use
		$(this).data("windowObject", windowObject);
		return false;
	});
		
	$('a').each(function() {
		var domain = document.domain;
		domain = domain.replace(/www./, "");
		var href= $(this).attr('href');
		if (undefined != href) {
			if ( (href.match(/^http/)) && (! href.match(domain)) ) {
				$(this).click(function() {
 					if(typeof _gaq== 'function') { 
						_gaq.push(['_trackPageview','/external/' + href]);
					}
				});
			} else if (href.match(/\.(doc|pdf|xls|ppt|zip|txt|vsd|vxd|js|css|rar|exe|dmg|wma|mov|avi|wmv|mp3)$/)) {
				$(this).click(function() {
					if(typeof _gaq== 'function') { 
						_gaq.push(['_trackPageview','/downloads/' + href]);
					}
				});
			}	
		}	
	});
 
});