jQuery(function(){
	if (box.dom("#mainRight").length > 0) {
		
		var typeUrlString = document.location.href;
		//var typeIndex = typeUrlString.indexOf("type")+1;
		$('#wrapper').removeClass('type0').removeClass('type1').removeClass('type2').removeClass('type3');
		//alert(typeUrlString.indexOf("type0")+1>0);
		if (typeUrlString.indexOf("partners.htm") + 1 > 0) {
		    $('#brochuresItem').hide();
		}
		
		if (typeUrlString.indexOf("type0About") + 1 > 0) {
			
			$('#resource').hide();
			$('#menu2').hide();
			$('#menuEnd2').hide();
			$('#location').show();
			$('#menu3').show();
			$('#menuEnd3').show();
		}
		else {
			$('#location').hide();
			$('#resource').show();
			$('#menu2').show();
			$('#menuEnd2').show();
			$('#menu3').hide();
			$('#menuEnd3').hide();
		}
		
	}
//	alert(box.dom("#menu2").length );
	if (box.dom("#menu2").length > 0) {
		var typeUrlString = document.location.href;
		//var typeIndex = typeUrlString.indexOf("type")+1;
		
		$('#wrapper').removeClass('type0').removeClass('type1').removeClass('type2').removeClass('type3').removeClass('type4');
		
		//alert(typeUrlString.indexOf("type0")+1>0);
		if(typeUrlString.indexOf("type0About")+1>0){
			$('#resource').hide();
			$('#menu2').hide();
			$('#menuEnd2').hide();
			$('#location').show();
			$('#menu3').show();
			$('#menuEnd3').show();
		}
		else{
		
			$('#location').hide();
			$('#resource').show();
			$('#menu2').show();
			$('#menuEnd2').show();
			$('#menu3').hide();
			$('#menuEnd3').hide();
		}
		if (typeUrlString.indexOf("e-commerce.htm") + 1 > 0) {
		    $('#menu2').show();
			$('#menuEnd2').show();
		}
		
		if (typeUrlString.indexOf("type0") + 1 > 0) 
		{
			$('#wrapper').addClass('type0');
			initMenu('menu2', 'oneOpen', 0);
			initMenu('menu3', 'oneOpen', 0);
		}
		else 
			if (typeUrlString.indexOf("type1") + 1 > 0) {
				$('#wrapper').addClass('type1');
				initMenu('menu2', 'oneOpen', 0);
				
			}
			else 
				if (typeUrlString.indexOf("type2") + 1 > 0) {
				
					$('#wrapper').addClass('type2');
					initMenu('menu2', 'oneOpen', 1);
				}
				else 
					if (typeUrlString.indexOf("type3") + 1 > 0) {
						$('#wrapper').addClass('type3');
						initMenu('menu2', 'oneOpen', 2);
					//alert(3);
					}
					else 
					if (typeUrlString.indexOf("type4") + 1 > 0) {
					
						$('#wrapper').addClass('type4');
						initMenu('menu4', 'oneOpen', 2);
					//alert(3);
					}
					else {
						$('#wrapper').addClass('type0');
						initMenu('menu2', 'oneOpen', 0);
					}
	}
		
	$.ajax({
		  url: 'top.htm',
		  cache: true,
		  success: function(html){
		  
			$("#headerTop").prepend( $(html).html() );
			setTime();
			setNav();
		  }
	});
	
	var setTime=function(){
		//get Month, week, year 
		var m_names = new Array("Jan", "Feb", "Mar", 
								"Apr", "May", "Jun", "Jul", "Aug", "Sep", 
								"Oct", "Nov", "Dec");
		var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
		var d = new Date();
		var curr_date = d.getDate();
		var curr_month = d.getMonth();
		var curr_year = d.getFullYear();
				
		$('#headerDate').html(curr_date);	
		$('#headerWeek').html(weekday[d.getDay()]);	
		$('#headerMonth').html(m_names[curr_month]+" "+curr_year);	
	}
	
	$('a').bind('focus',function(){if(this.blur)this.blur();});	
	
	
	
	
	//navigation bar	
	var setNav=function(){
		$('ul.sf-menu').superfish({ 
		delay:       1000,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       100,                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: true                            // disable drop shadows 
		}); 
	}		
	
	
	//tabs
	box.dom(function() {
		// Example of dynamic tabs
		box.ui('tabs').create({
			element: '#tabsListing'
		});
	});
	
	//partners fisheye
	var opts = { align:       'middle' //default
		   , size:         60
		   , distance:     80     //default
		   , coefficient : 2      //default
		   , labels:       false    //default
		   , duration:     500 //default
			 //for menu1 and menu7, set a function to use the 'alt' attribute if present, else construct a PNG path from the 'src'...
		   , source:        function(i){ return this.src.replace(/gif$/,'png'); }
		   };
	
	
	jQuery('#partner').jqDock(opts);
	
	//banner
	$('#photos').galleryView({
		panel_width: 720,
		panel_height: 172,
		frame_width: 30,
		frame_height: 30,
		overlay_color: '#222',
		overlay_text_color: 'white',
		caption_text_color: '#222',
		background_color: 'transparent',
		border: 'none',
		nav_theme: 'light',
		easing: 'easeInOutQuad',
		pause_on_hover: true,
		overlay_height:30
	});
	
	//"more" button 
	$('.more').hover(
		function(){
			$(this).animate({left: '3px'}, 100);			  
		},
		function(){
			$(this).animate({left: '-3px'}, 100);			  
		}
	);
	 
	
});