
/* ONLOAD */
$(document).ready(function() {

	$("a").each( function() {
		$(this).focus( function() { $(this).blur(); });
	});

	if ( $("div#UnderConstruction").length > 0 ) {

		$("div#UnderConstruction").flash( { src: "flash/under_construction.swf", width: 450, height: 100, wmode: "transparent", menu: "false", scale: "noScale" }, { version: 8 } );
	}

	if ( $("div#ThaiAust").length > 0 ) { // Thai-Aust
		// Top Menu
		if ( $("div#ThaiAust div#Right div#Menu").length > 0 ) {
			$("div#ThaiAust div#Right div#Menu").flash( { src: "flash/thaiaust-menu.swf", width: 740, height: 65, wmode: "opaque", menu: "false", scale: "noScale", flashvars: { path: "xml/thaiaust_menu.xml", page: parseInt($("div#ThaiAust div#Right div#Menu").attr("active")) } }, { version: 8 } );
		}

		// Highlight Project & News Events
		if ( $("div#ThaiAust div#Left div#Update").length > 0 ) {
			$("div#ThaiAust div#Left div#Update").accordion({
				active: true,
				autoheight: false,
				alwaysOpen: false,
				header: '.head',
				selectedClass: 'active'
			});
		}

		// Home
		if ( $("div#ThaiAust div#Home").length > 0 ) {
			$("div#ThaiAust div#Home").flash( { src: "flash/thaiaust-home.swf", width: 700, height: 270, wmode: "opaque", menu: "false", flashvars: { path: "xml/thaiaust_home.xml" } }, { version: 8 } );
			$("div#ThaiAust div#NewProduct").flash( { src: "flash/thaiaust-home_product.swf", width: 700, height: 125, wmode: "opaque", menu: "false", flashvars: { path: "api/thaiaust_home_product.php" } }, { version: 8 } );
		}

		// Company Profile
		if ( $("div#ThaiAust div#Right div#Profile div#Detail").length > 0 ) {
			$("div#ThaiAust div#Right div#Profile div#Detail").jScrollPane({scrollbarWidth:15, showArrows:true});
		}
		if ( $("div#ThaiAust div#Profile div.SubTitle").length > 0 ) {
			$("div#ThaiAust div#Profile div.SubTitle", this).each(function(){
				$(this).flash({
					src: "flash/title-category_trustand.swf", 
					width: 650, height: 30, 
					wmode: "transparent", menu: "false", 
					flashvars: { title: $(this).attr("title") }
				}, { version: 8 } );
			});
			//$("div#Trustand div#ProductList div#Title").flash( { src: "flash/title-category_trustand.swf", width: 930, height: 30, wmode: "transparent", menu: "false", flashvars: { title: $("div#Trustand div#ProductList div#Title").attr("title") } }, { version: 8 } );
		}

		// News & Events
		if ( $("div#ThaiAust div#Right div#NewsEvents div#List").length > 0 ) {
			$("div#ThaiAust div#Right div#NewsEvents div#List").jScrollPane({scrollbarWidth:15, showArrows:true});
		}
		if ( $("div#ThaiAust div#Right div#NewsEvents div#Detail").length > 0 ) {
			$("div#ThaiAust div#Right div#NewsEvents div#Detail").jScrollPane({scrollbarWidth:15, showArrows:true});

			$("div#ThaiAust div#Right div#NewsEvents div#Gallery a").lightBox();
		}

		// Join Us
		if ( $("div#ThaiAust div#Right div#JoinUs div#List").length > 0 ) {
			$("div#ThaiAust div#Right div#JoinUs div#List").jScrollPane({scrollbarWidth:15, showArrows:true});
		}
		if ( $("div#ThaiAust div#Right div#Application div#Form").length > 0 ) {
			$("div#ThaiAust div#Right div#Application div#Form").jScrollPane({scrollbarWidth:15, showArrows:true});

		}

		// Additional Effect for jScrollPane
		if ( $("div.jScrollPaneContainer div.jScrollPaneDrag").length > 0 ) {
			$("div.jScrollPaneContainer div.jScrollPaneDrag").mouseover(function() {
				$(this).addClass("DragOver");
			});
			$("div.jScrollPaneContainer div.jScrollPaneDrag").mouseout(function() {
				$(this).removeClass("DragOver");
			});
		}

	} else if ( $("div#EzyWindow").length > 0 ) { // EzyWindow
		// Top Menu
		if ( $("div#EzyWindow div#Menu").length > 0 ) {
			$("div#EzyWindow div#Menu").flash( { src: "flash/ezywin-menu.swf", width: 720, height: 25, wmode: "opaque", menu: "false", flashvars: { } }, { version: 8 } );
		}

		// Home
		if ( $("div#EzyWindow div#Home").length > 0 ) {
			$("div#EzyWindow div#Home div#Head").flash( { src: "flash/ezywin-head_home.swf", width: 600, height: 100, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
			$("div#EzyWindow div#Home div#Banner").flash( { src: "flash/ezywin-home.swf", width: 340, height: 375, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
		}

		if ( $("div#EzyWindow div#ProductList").length > 0 ) {
			$("div#EzyWindow div#ProductList div#Head").flash( { src: "flash/ezywin-head_product.swf", width: 940, height: 100, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
			//$("div#EzyWindow div#ProductList div#Banner").flash( { src: "flash/ezywin-home.swf", width: 340, height: 375, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
		}

		if ( $("div#EzyWindow div#ProductDetail").length > 0 ) {
			$("div#EzyWindow div#ProductDetail div#Head").flash( { src: "flash/ezywin-head_product_detail.swf", width: 630, height: 100, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
			$("div#EzyWindow div#ProductDetail div#Banner").flash( { src: "flash/ezywin-product.swf", width: 335, height: 375, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
		}

	} else if ( $("div#Trustand").length > 0 ) { // Trustand
		// Top Menu
		if ( $("div#Trustand div#Menu").length > 0 ) {
			$("div#Trustand div#Menu").flash( { src: "flash/trustand-menu.swf", width: 720, height: 30, wmode: "opaque", menu: "false", flashvars: { } }, { version: 8 } );
		}

		// Head Banner
		if ( $("div#Trustand div#Head").length > 0 ) {
			$("div#Trustand div#Head").flash( { src: "flash/trustand-head_product.swf", width: 950, height: 190, wmode: "opaque", menu: "false", flashvars: { } }, { version: 8 } );
		}

		// Home
		if ( $("div#Trustand div#Home").length > 0 ) {
			$("div#Trustand div#Home div#Intro").flash( { src: "flash/trustand-home.swf", width: 700, height: 300, wmode: "transparent", menu: "false", flashvars: { } }, { version: 8 } );
		}

		// Product Category
		if ( $("div#Trustand div#ProductCategory").length > 0 ) {
			$("div#Trustand div#ProductCategory div#Title").flash( { src: "flash/title-category_trustand.swf", width: 930, height: 30, wmode: "transparent", menu: "false", flashvars: { title: $("div#Trustand div#ProductCategory div#Title").attr("title") } }, { version: 8 } );
		}

		// Product List
		if ( $("div#Trustand div#ProductList").length > 0 ) {
			$("div#Trustand div#ProductList div#Title").flash( { src: "flash/title-category_trustand.swf", width: 930, height: 30, wmode: "transparent", menu: "false", flashvars: { title: $("div#Trustand div#ProductList div#Title").attr("title") } }, { version: 8 } );
		}

		// Product Accessory
		if ( $("div#Trustand div#ProductAccessory").length > 0 ) {
			$("div#Trustand div#ProductAccessory div#Title").flash( { src: "flash/title-category_trustand.swf", width: 930, height: 30, wmode: "transparent", menu: "false", flashvars: { title: $("div#Trustand div#ProductAccessory div#Title").attr("title") } }, { version: 8 } );
		}

		// Project Reference
		if ( $("div#Trustand div#ProjectReference").length > 0 ) {
			$("div#Trustand div#ProjectReference div#SubMenu").flash( { src: "flash/trustand-project.swf", width: 920, height: 30, wmode: "transparent", menu: "false", flashvars: { cate: $("div#Trustand div#ProjectReference div#SubMenu").attr("active") } }, { version: 8 } );
		}

		if ( $("div#Trustand div#ProjectReference div#Detail").length > 0 ) {

			$("div#Trustand div#ProjectReference div#Title").flash( { src: "flash/title-project_reference.swf", width: 800, height: 25, wmode: "transparent", menu: "false", flashvars: { title: $("div#Trustand div#ProjectReference div#Title").attr("title") } }, { version: 8 } );

			$("div#Trustand ul#myCarousel a").click(function() {
				if ( $(this).attr("href").length > 0 ) {
					$("div#Trustand ul#myCarousel a").removeClass("active");
					$(this).addClass("active");

					$("div#Trustand div#Preview a").css("background-image", "url('images/trustand/loading.gif')");
					if ( $("div#Trustand div#Preview div.Description").length == 0 ) {
						$("div#Trustand div#Preview").prepend('<div class="Description"></div>');
					}
					$("div#Trustand div#Preview div.Description").empty().hide().css( {opacity: 0.7} );
					$("div#Trustand div#Preview a").hide();

					var img = new Image();
					$(img).hide();
					$(img).load(function() {
						$("div#Trustand div#Preview a").attr("href", $(this).attr("src"));
						$("div#Trustand div#Preview a").css("background-image", "url('"+$(this).attr("src")+"')");
						if ($("div#Trustand div#Preview div.Description").length > 0 && $(this).attr("title").length > 0 ) {
							$("div#Trustand div#Preview div.Description").html( $(this).attr("title") );
							//alert("Show")
							$("div#Trustand div#Preview a").fadeIn("normal", function() {$("div#Trustand div#Preview div.Description").fadeIn();} );
						} else {
							$("div#Trustand div#Preview a").fadeIn();
						}
						$("div#Trustand div#Preview a").lightBox();
					});
					$(img).attr("title", $(this).attr("title"));
					$(img).attr("src", $(this).attr("href"));
				}
				return false;
			});

			$("div#Trustand ul#myCarousel").jcarousel();
			$("div#Trustand ul#myCarousel a:first").click();

			/*$("ul#myCarousel li img").each(function(i) {
				mycarousel_itemList[i] = {url: $(this).attr("src"), title: $(this).attr("title") };
			});
			$("div#Trustand div#ProjectReference ul#myCarousel").jcarousel({
				wrap: "circular",
				itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
				itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}
			});*/
		}

		// Product Search
		if ( $("div#Trustand div#ProductSearch").length > 0 ) {
			$("div#Trustand div#ProductSearch div#Title").flash( { src: "flash/title-category_trustand.swf", width: 920, height: 30, wmode: "transparent", menu: "false", flashvars: { title: $("div#Trustand div#ProductSearch div#Title").attr("title") } }, { version: 8 } );
		}

	}



	if ( $("a.lightbox").length > 0 ) {
		$("a.lightbox").lightBox();
	}
});
