/*============================================================

Author: Simon Young
http://simonyoung.net
http://twitter.com/simon180

ONLOAD.JS 
Site specific JavaScript functionality

(c) Simon Young, 2010. All rights reserved.

============================================================*/


function moveCloseLink(){ 
    var cb=document.getElementById('sb-nav-close'); 
    var tb=document.getElementById('sb-title'); 
    if(tb) tb.appendChild(cb); 
}


$(document).ready(function () {
	
	Cufon.replace("#header p, #main #partner-links h2, #main #blog-links h2, #main #solution-links h3, #main #content h1, #main #content h2, #main #content h3, #main #content h4, #blog-sidebar h3", {
            hover: true
    });
	
	// make links with rel=external open in new window/tab
	$(function() {
        $('a[rel*=external]').click( function() {
            window.open(this.href);
            return false;
        });
    });
    
    
    //set up search box  
    $('#keywords').focus(function(){  
        if($(this).attr("value") == 'Enter your search term here') $(this).attr("value", "");  
    });  
    $('#keywords').blur(function(){  
        if($(this).attr("value") == "") $(this).attr("value", 'Enter your search term here');  
    });
    
    
    //home page panel
    $('#carousel').cycle({ 
        //prev:   '.prev', 
        //next:   '.next', 
        pager:  '.pager', 
        speed:  300,
        timeout: 5000 
    });
    
    Shadowbox.init({
        handleOversize: "drag",
        modal: true,
        overlayOpacity: 0.75,
        onOpen: moveCloseLink
    });
    
    //logo carousel
    $("#partner-links").jCarouselLite({
        auto: 1200,
        speed: 1000,
        visible: 6
    });
    
    
    //apply rounded corners with javascript if border radius is not supported
    if(!Modernizr.borderradius) { 
        $('#key-links li').corner('14px');
        $('#nav').corner('10px tl tr');
        $('#nav li:first-child').corner('10px tl');
        $('#sitesearch').corner('14px bl br');
        $('#base-content').corner('15px bl br');
        //$('#main #carousel .carousel-item .carousel-txt').corner('20px tr br');
        //$('li.pager a').corner('16px');
    }
	
	//set up validation for forms
	$(".form-with-validation").validate();
	
});
