var $j = jQuery.noConflict();
function setDivHeight() {
 var w = 0;
 var h = 0;
 if (window.innerWidth) { // All browsers but IE 
    w= window.innerWidth; 
    h= window.innerHeight;  
    
}
else if (document.documentElement && document.documentElement.clientWidth && (w==0 || h ==0)) { 
    // These functions are for IE 6 when there is a DOCTYPE 
    w= document.documentElement.clientWidth;  
    h= document.documentElement.clientHeight; 
    
} 
else if (document.body.clientWidth && (w==0 || h ==0)) { 
    w = document.body.clientWidth;  
    h = document.body.clientHeight;  
   
} 
else {
	w = window.screen.width;
	h = window.screen.height;

}


	$j("#container").css({height: h + "px", width: w  + "px"});
	$j("#containerframe").css({height: h + "px", width: w  + "px"});
	$j("#containerframe").attr("height", h );
	$j("#containerframe").attr("width", w );
	$j('#widget').css({position: 'absolute'});
}
var timer,timer2;

var dosubs = true;

$j(document).ready(function($){
	if(ie7less)
		$j("#containerframe").css({position: "fixed"});
	setDivHeight();	
	
	$j('#widget').draggable(
			{
				drag: function() {$j("#content").removeClass("shadow");dosubs=false;},
				stop: function() {$j("#content").addClass("shadow");dosubs=true;},
				handle:	'#title',
				delay: 10,
				iframeFix: true,
				containment: 'document'
			}
		);
	
	$j("#widget #title #minmax").click(function(){
		var newheight = 0;
		if ($j('#content').css("height") == "" || $j('#content').css("height") == "197px") {
			newheight = 79;
			$j(this).addClass("max");
			newheightic = 0;
			if(ie7less)
				$j('#images').css({position: "fixed"});
			timer2 = setTimeout(stopSlideShow, 800);
		}
		else {
			newheight = 197;
			newheightic = 82;
			timer2 = setTimeout(startSlideShow, 800);
			if(ie7less)
				$j('#images').css({position: "relative"});
			clearTimeout(timer2);
			$j(this).removeClass("max");
		}
		$j('#content').animate({ 
		   height: newheight+"px"		   
		 }, 800 );
	
		if (ie7less) {
			
			$j('#images').animate({ 
		   height: newheightic+"px"		   
		 }, 800 );
		}
	});
	
	$j("a.button").hover(function() {
		var id = $j(this).attr("id").replace("but_","");
		show_sub(id);
		clearTimeout(timer);		
	},
	function(){
		
		timer = setTimeout("hide_sub();", 100);
	});
	$j(".sub").hover(function() {		
		clearTimeout(timer);
		
	},
	function(){
		$j("a.button").removeClass("hover");
		timer = setTimeout("hide_sub();", 100);
	});
	
	startSlideShow();
});

function show_sub(id) {
	$j(".sub").css({display: "none"});
	if (dosubs) {
		$j("a.button").removeClass("hover");
		$j("#but_" +id).addClass("hover");
		$j("#sub_" +id).fadeIn("fast");
	}
}
function hide_sub(id) {
	$j("a.button").removeClass("hover");
	$j(".sub").css({display: "none"});
	//$j("#sub_" +id).fadeIn("fast");
}
window.onresize = setDivHeight;

function startSlideShow(){
	$j('#images').cycle({ 
		fx:    'fade', 
		random:  0,
		speed:  2200 
	});	
}
function stopSlideShow(){
	$j('#images').cycle({ 
		fx:    'fade', 
		random:  0,
		speed:  22003232234 
	});
	
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {
	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 
function pageHeight() {
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 
