
jQuery(document).ready(function() {

$(function()
{
	$('#imagecol-scrolling').jScrollPane({scrollbarMargin: 1, dragMinHeight: 20, dragMaxHeight: 20, reinitialiseOnImageLoad: true});
	$('.scroll-pane').jScrollPane({scrollbarMargin: 1, dragMinHeight: 20, dragMaxHeight: 20});
});

	$('ul > li > ul').addClass("hidden");
	$('#open_nav').removeClass("hidden");
	$('#open_nav_2nd').removeClass("hidden");
	$('ul li:has(ul li)').children('a').click(function() {	
		$(this).parent().children('ul').toggleClass("hidden");		
		//return false;		
	});   
	$('html').removeClass("js");
	
	$('.popup_img').hide();
	
	$(".newsitem").hover(
	function(event){ //mouseover
		var currentId = $(this).attr('id');
		$("#" + currentId + " > .overlay").css({visibility:'visible'}); 
		$("#" + currentId + " > .header a").css({color:'#993300'}); 
	},
	function(event){ //mouseout
		var currentId = $(this).attr('id');
		$("#" + currentId + " > .overlay").css({visibility:'hidden'}); 
		$("#" + currentId + " > .header a").css({color:'#656565'}); 
	}
	);
	
	$(".projectitem").hover(
	function(event){ //mouseover
		var currentId = $(this).attr('id');
		$("#" + currentId + " > .overlay").css({visibility:'visible'}); 
		$("#" + currentId + " > .header a").css({color:'#993300'}); 
	},
	function(event){ //mouseout
		var currentId = $(this).attr('id');
		$("#" + currentId + " > .overlay").css({visibility:'hidden'}); 
		$("#" + currentId + " > .header a").css({color:'#656565'}); 
	}
	);
	
	$(".siximage_item").hover(
	function(event){ //mouseover
		var currentId = $(this).attr('id');
		$("#" + currentId + " > .overlay").css({visibility:'visible'}); 
		$("#" + currentId + " > .header a").css({color:'#993300'}); 
	},
	function(event){ //mouseout
		var currentId = $(this).attr('id');
		$("#" + currentId + " > .overlay").css({visibility:'hidden'}); 
		$("#" + currentId + " > .header a").css({color:'#d8d8d8'}); 
	}
	);
	
	$('#homephoto').cycle({ 
    	fx: 'fade',
		speed:  2800
	});
	
	$("a.popup_click").click(function() {
		var currentId = $(this).attr('id');
		$('.popup_img').hide();
        $("#popup" + currentId).show();
    });
	
	$(".popup_img").click(function() {
		var currentId = $(this).attr('id');
        $("#" + currentId).hide();
    });
	
});

jQuery.fn.debug = function(message) {
        return this.log('debug:' + (message || '')
+"[").each(function(){jQuery.log(this);}).log("]");
}
jQuery.fn.log = jQuery.log = function(message) {
        if (!message) message = 'UNDEFINED'
        if (typeof message  == "object") message = jsO(message)
        if(window.console && window.console.log) //safari
                window.console.log(message)
        else if(window.console && window.console.debug) //firebug
                window.console.debug(message)
        else
                jQuery("body").prepend(message+ "<br/>")
        return this
}

function jsO(obj) { // convert to simple js object for quick and dirty access almost anything 
// not a good function for dom stuff because of duplicate chidlren tags
        if (typeof obj == "object") {
                var res = "{\n";
                var v = Array(0);
                var val=obj.nodeValue;
                if (val){
                        res += "'" + val + "'\n";
                } else if (obj.nodeType){ // a dom node!
                        res += obj.nodeName.replace(/-/g,"_dash_").replace(/#/g,"_hash_") + ":{";
                        if (obj.hasAttributes()) {
                                var attrs = obj.attributes;
                                for (var i = 0; i < attrs.length; i++){
                                        var attr=attrs[i];
                                        v[v.length] = "_" + attr.name + ":'" + attr.value + "'\n";
                                }
                        }
                        if (obj.hasChildNodes()) {
                                var children = obj.childNodes;
                                for (var i = 0; i < children.length; i++){
                                        v[v.length] = "" + i + ":" + jsO(children[i]) + "\n";
                                }
                        }
                } else {
                        for (var item in obj){
                                try {
                                        v[v.length] = "" + item + ":" + jsO(obj[item]) + "\n";
                                } catch (e) {
                                        v[v.length] = "" + item + ":'whoops'\n";
                                }
                        }
                }
                res += v.join(",") + '}\n';
                return res;
        } else {
                //if (obj.length > 20) obj = obj.substr(0,20) + "…";
                 return obj;
        }
}



