<%#= encoding: utf-8 %>
// function slideshow() {
// 	var $globalW = $(".global").width(),
// 		$slideImg = $(".slideImg"),
// 		$slidebanner = $(".slidebanner"),
// 		$slideshow = $(".slideshow"),
// 		$slideImgOW = $slideImg.width(),
// 		$slideImgOH = $slideImg.height();
// 	$slideImg.css({
// 		"widht": $globalW,
// 		"height": Math.floor(($globalW/$slideImgOW)*$slideImgOH),
// 	});
// 	$slideshow.css({
// 		"width": $globalW,
// 		"height": Math.floor(($globalW/$slideImgOW)*$slideImgOH),
// 	});
// 	alert(Math.floor(($globalW/$slideImgOW)*$slideImgOH))
// }
$('#index').live('pageinit',function(){
	var $globalW = $(window).width(),
		$slideshow = $(".slideshow");
	$slideshow.css({
		"width": $globalW, "height": Math.floor($globalW/720*240)
	});
	$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
	$(this).find(".newpic img").muImageResize({width: 280, height: 200});
	$('.slideshow').cycle({
		fx: $effect,
		timeout: $timeout
	});
	$(".newlist").css({
		"width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30,
	})
	// var oc_timer;
 //    clearTimeout(oc_timer);
 //    oc_timer = setTimeout(function () {
	// 	$('.newlist').swipePlanes();
 //    }, 1000);
});
$('#announcement_content').live('pageinit',function(){
	$(this).find(".newpic img").muImageResize({width: 320, height: 220});
});

$('#map').live('pageinit', function() {
	var mobileDemo = { 'center': $map_center, 'zoom': $map_zoom };
	var $windowH = $(window).height();
	$("#map_canvas").css({
		'height' : $windowH,
	})
	gmAPI.add('basic_map', function() {
		$('#map_canvas').gmap({'center': mobileDemo.center, 'zoom': mobileDemo.zoom, 'disableDefaultUI':false, 'callback': function() {
			var self = this;
			self.addMarker({'position': this.get('map').getCenter() }).click(function() {
				self.openInfoWindow({ 'content': $info }, this);
			});
		}}); 
	}).load('basic_map');
});

$('#map').live('pageshow', function() {
	gmAPI.add('basic_map', function() { $('#map_canvas').gmap('refresh'); }).load('basic_map');
});

$(document).bind('pagebeforehide',function(){
	$("section.main-menu").removeClass("expanded");
});
$(document).bind("ready", function(){
	// $(".openmenu").live("tap", function(){
	// 	$("section.main-menu").toggleClass("expanded");
	// 	return!1
	// });
	$("body").delegate(".openmenu","vclick",function(){
		$("section.main-menu").toggleClass("expanded");
		return!1
	});
	// alert(navigator.userAgent)
	// $(".newpic img").muImageResize({width: 280, height: 100});
	// $('.newlist').swipePlanes();
});

// $(window).resize(function(){
// 	alert("Resize");
// 	$(".slidebanner").removeAttr("style");
// 	$(".slidebanner").find("div").removeAttr("style");
// 	$(".slideImg").removeAttr("style");
// 	var $globalW = $(window).width(),
// 		$slideshow = $(".slideshow");
// 	$slideshow.css({
// 		"width": $globalW, "height": Math.floor($globalW/720*240)
// 	});
// 	$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
// 	$('.slideshow').cycle({
// 		fx:'scrollLeft',
// 		timeout: 6000,
// 	});
// });
$(window).bind("orientationchange", function(){
	var oc_timer;
    clearTimeout(oc_timer);
    oc_timer = setTimeout(function () {
		$(".slidebanner").removeAttr("style");
		$(".slidebanner").find("div").removeAttr("style");
		$(".slideImg").removeAttr("style");
		// $(".newlist").removeAttr("style");
		// $(".newlist").find(".clear").removeAttr("style");
		// $(".newitem").removeAttr("style");
		// $(".newlist").find(".clear").nextAll("div").remove();
		var $globalW = $(window).width(),
			$slideshow = $(".slideshow"),
			$windowH = $(window).height();
		$slideshow.css({
			"width": $globalW, "height": Math.floor($globalW/720*240)
		});

		$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
		$('.slideshow').cycle({
			fx: $effect,
			timeout: $timeout
		});

		$(".newlist").css({
			"width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30,
		})

		$("#map_canvas").css({
			'height' : $windowH,
		})
		// $('.newlist').swipePlanes();
    }, 500);
});