// preload flash



$(document).ready(function() {
    
    if($('#prodInner').length > 0 ) {
        $(document).pngFix(); 
    }

	if ($('.imgRight').length > 0) {
		$("a.fancy").fancybox({
			'zoomSpeedIn': 200,
			'zoomSpeedOut': 200,
			'overlayShow': true,
			'overlayOpacity': 0
		});
	}

	if ($('#gallery').length > 0) {
		$('#gallery a').hover(function() {
			$(this).children('.thumbOverlay').fadeIn(150);
		}, function() {
			$(this).children('.thumbOverlay').fadeOut(300);

		}).fancybox({
			'zoomSpeedIn': 200,
			'zoomSpeedOut': 200,
			'overlayShow': true,
			'overlayOpacity': 0
		});
	}
	/*
	if ($('#hButtons').length > 0) {
		var xmlSrc = "/homebuttonsxml";
		swfobject.embedSWF("/assets/swf/hButtons.swf", "hButtons", "610", "115", "9.0.0", "/assets/swf/expressInstall.swf", { "xmlSrc": xmlSrc }, { "wmode": "transparent" });
	}
	*/
	// language selector stuff


	function bindLang() {
		$('#languageBox').css("width", "195px");
		$('#funkyInner ul li').each(function() {
		    if($(this).attr('selected') == "selected") {
		        $(this).addClass('on');
		    }
		});
		downArrowPath = "/assets/images/global/langDown.gif";
		upArrowPath = '/assets/images/global/langUp.gif'
		upMessage = "click to collapse the menu";
		downMessage = "click to expand the menu";
		function toggleVisible() {
			if ($('#funkyInner ul li').not('.on').is(':hidden')) {
				$('#funkyInner ul li').show();
				$('#funkyCont').attr({ title: downMessage, alt: "down" }).children('img').attr('src', upArrowPath);

			} else {
			    
				$('#funkyInner ul li').hide();
				$('#funkyInner ul li.on').show();
				$('#funkyCont').attr({ title: upMessage, alt: "up" }).children('img').attr('src', downArrowPath);
			}
		}

		$('#funkyInner ul li.on, #funkyCont').click(function() {
			toggleVisible();
			return false;
		});
		toggleVisible();
	}

	langs = new Array();
	items = "";
	$('#languageBox form select option').each(function(i) {
		attribs = new Object();
		attribs.imgPath = $(this).attr('id');
		attribs.theName = $(this).val();
		attribs.anchorPath = $(this).attr('targ')
		attribs.isSelected = false;
		if($(this).attr('selected') == true) {
		    attribs.isSelected = true;
    		
		}
		langs[i] = attribs;
	});

	for (var i = 0; i < langs.length; i++) {
	    if(langs[i].isSelected == true) {
	        theFirstItem = '<li style="background-image: url(\'' + langs[i].imgPath + '\'); " class="on"><a href="' + langs[i].anchorPath + '">' + langs[i].theName + '</a></li>';
	    } else {
	       items += '<li style="background-image: url(\'' + langs[i].imgPath + '\'); "><a href="' + langs[i].anchorPath + '">' + langs[i].theName + '</a></li>';
	    }
	    
		
	};
        items = theFirstItem + items;
	funkyDrop = '<div id="funky"><div id="funkyInner" class="clearfix"><ul>' +  items + '</ul><a href="#" id="funkyCont" title="click to expand the menu"><img src="/assets/images/global/langDown.gif"  border="0" alt="Down"/></a></div></div>';

	$('#languageBox form').remove();
	$('#languageBox').append(funkyDrop);
	bindLang();
	
	/*
	if ($("#buyOnline").length > 0) {
		var buyOnline = $("#buyOnline");
		var buyOnlineImg = $("#buyOnline img");
		//buyOnline.click(function() { return false; });
		buyOnlineImg.css({ visibility: 'visible' });
		buyOnlineImg.hide();
		buyOnline.hover(function() {
			buyOnlineImg.stop(true, true);
			buyOnlineImg.fadeIn(120);
			buyOnlineImg.css({ top: 0 });
			buyOnlineImg.animate({ top: -20 }, { duration: 120, queue: false });
		},function() {
			buyOnlineImg.stop(true, true);
			buyOnlineImg.fadeOut(100);
		});
	}
	*/
	
});
/*
<div id="funky">
	<div id="funkyInner" class="clearfix">
		<ul>
			<li style="background-image: url('/assets/images/temp/eng.gif');" ><a href="#">English</a></li>
			<li style="background-image: url('/assets/images/temp/eng.gif');" ><a href="#">Japanese</a></li>
			<li style="background-image: url('/assets/images/temp/eng.gif');" ><a href="#">Spanish</a></li>

		</ul>
		<a href="#" id="funkyCont" title="click to expand the menu"><img src="/assets/images/global/langDown.gif"  border="0" alt="Down"/></a>
	</div>	
</div>


*/


 



