/**
 * site.js
 */

/*dropdown START*/
$(function() {
	var dropdownShown = 0;
	function setDropdownShown() {
		dropdownShown = 1;
	}
	function setDropdownHidden() {
		dropdownShown = 0;
	}
	$('.dropdown').mouseenter(function(){
		if(dropdownShown == 0) {
			$('.dropdown ul').effect('slide', {direction: 'up'}, 500, setDropdownShown);
		}
	});
	$('.dropdown').mouseleave(function(){
		if(dropdownShown == 1 || 1) {
			$('.dropdown ul').hide('slide', {direction: 'up'}, 500, setDropdownHidden);
		}
	});
});
/*dropdown END*/

/*cufon START*/
Cufon.replace('.sans68', { fontFamily: 'sans68', hover: true });
Cufon.replace('.sans35', { fontFamily: 'sans35', hover: true });
Cufon.replace('.catDescription strong', { fontFamily: 'sans68', hover: true });
/*cufon END*/

/*open external links in a new window START*/
$(function() {
	$("a[href^=http]").each(function() {
		if(this.href.indexOf(location.hostname) == -1) {
			$(this).click(function(){window.open(this.href);return false;});
		}
	});
});
/*open external links in a new window END*/

/*bookmark START*/
function CreateBookmarkLink() {
	title = document.title; 
	url = document.location.href;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}
/*bookmark END*/

/*clearOnFocus START*/
$(document).ready(function(){
	$(".clearOnFocus").focusin(function(){
		var defVal = $(this).attr('title');
		if ($(this).attr('value') == defVal) {
			$(this).attr('value', '');
		}
	});
	$(".clearOnFocus").focusout(function(){
		var defVal = $(this).attr('title');
		if ($(this).attr('value') == '') {
			$(this).attr('value', defVal);
		}
	});
});
/*clearOnFocus END*/

/*stylishSelect START*/
$(document).ready(function(){
	//$('.formSelect select').sSelect();
	//$('.formSelect select').sSelect({ddMaxHeight: '200px'});
});
/*stylishSelect END*/

/*colorbox START*/
$(document).ready(function(){
	$('.cb').colorbox({
		href: function(){
			return url = $(this).attr('href')+'?cb';
		}
	});
});
/*colorbox END*/
