﻿/*
 * tomgreuter.nl / jquery.com :)
 * version 1.0 - september, 2007
 */
 $(document).ready(function(){
   SC.init();
 });
 
var SC = {
	/*
	 * Class constructor
	 */
	init: function() {
		SC.fixIE6();
		SC.toggleFaq();	
		SC.search();		
		SC.handleFotoalbum();	
	},
	/*
	 * Add IE6-menu function which cannot be done with CSS
	 */
	addMOForIE6: function() {
		$( function() { 
			$("#navmenu li").mouseover( 
				function() {
					SC.toggleNavMenuItem(this, true);
				} 
			)
			.mouseout(
				function() {
					SC.toggleNavMenuItem(this, false);
				} 
			);
		} ); 
	},
	/*
	 * Fix issues with IE6
	 */
	fixIE6: function() {
		if($.browser.msie && navigator.appVersion.indexOf("MSIE 6.0") > 0) { 
			SC.addMOForIE6();
			SC.fixPNG();
		};
	},
	/*
	 * Fix PNG-support IE5 and IE6
	 */
	fixPNG: function() {
		// Thanks to: http://homepage.ntlworld.com/bobosola/
		var myImage = $("#hsclogo")[0];
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
		var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' ";
		var imgStyle = "display:inline-block;" + myImage.style.cssText; 
		var strNewHTML = "<span " + imgID + imgClass + imgTitle;
		strNewHTML += " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";";
		strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
		strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"; 
		myImage.outerHTML = strNewHTML;
	},
	/*
	 * Handle Fotoalbum - enable jQuery lightbox plugin (http://leandrovieira.com/projects/jquery/lightbox/)
	 */
	handleFotoalbum: function() {
    $(function() {
			var mynode = $('#gallery a');
			if (mynode.length > 0) {
	      mynode.lightBox({
					overlayBgColor: '#fb0',
					imageLoading: '/img/lightbox/lightbox-ico-loading.gif',
					imageBtnClose: '/img/lightbox/lightbox-btn-close.gif',
					imageBtnPrev: '/img/lightbox/lightbox-btn-prev.gif',
					imageBtnNext: '/img/lightbox/lightbox-btn-next.gif',
					txtImage: 'Foto',
					txtOf: 'van'});
			}
    });
	},
	/*
	 * Redirect search entry to Google
	 */
	search: function() {
		$("#zoek").submit(
			function() {
				$("#q").val($("#q").val() + " site:www.sportchallenge.nl");
			}
		);
	},
	/*
	 * Toggle questions on FAQ-page
	 */
	toggleFaq: function() {
		$("#faq dt").click(
			function() {
				// Hide alle DD's
				$("#faq dd").hide();
				// Open nu alleen de DD die onder de aangeklikte DT hangt
				$(this).next("dd").show();
			}
		);
	},
	/*
	 * Toggle submenu's in navigation bar
	 */
	toggleNavMenuItem: function(obj, bln) {
		if (bln) {
			obj.className += " over";
		} else {
			obj.className = obj.className.replace(" over", "");
		}
	}
};







