//preload rollobver images
portfolio_off = new Image (77, 22);
portfolio_off.src = "images/portfolio_off.gif";
portfolio_on = new Image (77, 22);
portfolio_on.src = "images/portfolio_on.gif";
contact_off = new Image (98, 22);
contact_off.src = "images/contact_off.gif";
contact_on = new Image (98, 22);
contact_on.src = "images/contact_on.gif";

function changeImage (imageId,imageObj)	{
	var imgId = imageId;
	var arrImg = imageObj;
	var imageSrc = '';
	imageSrc = imageObj +'.src';
	document.getElementById(imgId).src = eval(imageSrc);

}

$(document).ready(function() {

	//below function taken from - 
    //http://www.kevinleary.net/jquery-fadein-fadeout-problems-in-internet-explorer/
	//opacity fix for IE8
	(function($) {
		$.fn.customFadeIn = function(speed, callback) {
			$(this).fadeIn(speed, function() {
				if(!$.support.opacity)
					$(this).get(0).style.removeAttribute('filter');
				if(callback != undefined)
					callback();
			});
		};
		$.fn.customFadeOut = function(speed, callback) {
			$(this).fadeOut(speed, function() {
				if(!$.support.opacity)
					$(this).get(0).style.removeAttribute('filter');
				if(callback != undefined)
					callback();
			});
		};
		$.fn.customFadeTo = function(speed,to,callback) {
			return this.animate({opacity: to}, speed, function() {
				if (to == 1 && jQuery.browser.msie)
					this.style.removeAttribute('filter');
				if (jQuery.isFunction(callback))
					callback();
			});
		};
	})(jQuery);

	toggleDiv = 0; //no right panel = 0, contact panel = 1
  	
	$('#contact').click(function() {
		var currentState = toggleDiv;
		if (currentState == 0)	{
    		$('#rightpanel_contact').customFadeIn('slow');
			toggleDiv = 1;
		}
		else if (currentState == 1)	{
			$('#rightpanel_contact').customFadeOut('slow');			
			toggleDiv = 0;
		}		
  	});
});
