$(document).ready(function(){
	
	slideUpDown();
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))){
		// what to do if iphone/ipod 
	}

	$("#span0").hide();
	$("#span1").hide();
	$("#span2").hide();
	$("#span3").hide();
	$("#span4").hide();
	$("#span5").hide();
	$("#span6").hide();
	$("#span7").hide();
	
	
	/* tile0 */
	$("#tile0 span").prepend($("#span0").html());
	$("#tile0").mouseenter(function(){
		$("#tile0 img").animate({"opacity":0}, 500)
	});
	$("#tile0").mouseleave(function(){
		$("#tile0 img").animate({"opacity":1}, 500)
	});
	
	/* tile1 */
	$("#tile1 span").prepend($("#span1").html());
	$("#tile1").mouseenter(function(){
		$("#tile1 img").animate({"opacity":0}, 500)	
	});
	$("#tile1").mouseleave(function(){
		$("#tile1 img").animate({"opacity":1}, 500)
	});
	
	/* tile2 */
	$("#tile2 span").prepend($("#span2").html());
	$("#tile2").mouseenter(function(){
		$("#tile2 img").animate({"opacity":0}, 500)
	});
	$("#tile2").mouseleave(function(){
		$("#tile2 img").animate({"opacity":1}, 500)
	});
	
	/* tile3 */
	$("#tile3 span").prepend($("#span3").html());
	$("#tile3").mouseenter(function(){
		$("#tile3 img").animate({"opacity":0}, 500)
	});
	$("#tile3").mouseleave(function(){
		$("#tile3 img").animate({"opacity":1}, 500)
	});
	
	/* tile4 */
	$("#tile4 span").prepend($("#span4").html());
	$("#tile4").mouseenter(function(){
		$("#tile4 img").animate({"opacity":0}, 500)
	});
	$("#tile4").mouseleave(function(){
		$("#tile4 img").animate({"opacity":1}, 500)
	});
	
	/* tile5 */
	$("#tile5 span").prepend($("#span5").html());
	$("#tile5").mouseenter(function(){
		$("#tile5 img").animate({"opacity":0}, 500)
	});
	$("#tile5").mouseleave(function(){
		$("#tile5 img").animate({"opacity":1}, 500)
	});
	
	/* tile6 */
	$("#tile6 span").prepend($("#span6").html());
	$("#tile6").mouseenter(function(){
		$("#tile6 img").animate({"opacity":0}, 500)
	});
	$("#tile6").mouseleave(function(){
		$("#tile6 img").animate({"opacity":1}, 500)
	});
	
	/* tile7 */
	$("#tile7 span").prepend($("#span7").html());
	$("#tile7").mouseenter(function(){
		$("#tile7 img").animate({"opacity":0}, 500)
	});
	$("#tile7").mouseleave(function(){
		$("#tile7 img").animate({"opacity":1}, 500)
	});
	
	
	
	
		
		
	$.fn.wait = function(time, type){
		time = time || 1000;
		type = type || "fx";
		return this.queue(type, function(){
			var self = this;
			setTimeout(function(){
				$(self).dequeue();
			}, time);
		});
	};	
	
});

function slideUpDown(){
	if((!navigator.userAgent.match(/iPhone/i)) && (!navigator.userAgent.match(/iPod/i))){
		$("#plus-minus div:visible").hide().addClass("hidden");
		$("#plus-minus li").addClass("closed");
		$(".false").click(function(){											
			$(this).next().slideToggle().parent().toggleClass("closed");
			return false
		});
	
	}
}

function tableStripe(){
	$(".zebra tr").each(function(){
		$(this).children().eq(0).addClass("right");
	});
	$(".zebra tr:odd").addClass("odd");
	$(".zebra tr:even").addClass("even");
	$(".zebra tr").mouseover(function(){
		$(this).addClass("over");
	});
	$(".zebra tr").mouseout(function(){
		$(this).removeClass("over");
	});
}

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 *	$.cookie('the_cookie'); // get cookie
 *	$.cookie('the_cookie', 'the_value'); // set cookie
 *	$.cookie('the_cookie', 'the_value', { expires: 7 }); // set cookie with an expiration date seven days in the future
 *	$.cookie('the_cookie', '', { expires: -1 }); // delete cookie
*/

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};