// JavaScript Document

$(document).ready(init);

function init()
{
	select1();
	select2();
	pngFix_(); 
	loadpic();
}

function select1()
{
	$("#img_cont").find("img").mouseover(
				function () {
						$(this).css("border", "2px solid #A7263C");
				}							  
	); 
	$("#img_cont").find("img").mouseout(
		function () {
						$(this).css("border", "2px solid #ddd");
				}								  
	);
	
	
	$("#img_cont").find("img").click(
				function () {
					//var img = new Image();
					//img.src = $(this).get(0).getAttribute("lpic");
					//$(img).load(function () {
						//var w = 20+img.width; var h = 20+img.height;
						//if (w>=h) h +=40; // h +=120; 
						//else w+=225;
						//w=10; h=10;
						//window.open (href, "mapWindow", "status=1, toolbar=0, resizable=1, height="+h+", width="+w);
					//});
					myWindow = window.open($(this).get(0).getAttribute("link"), "mapWindow", "status=1, toolbar=0, resizable=1, height=700, width=700");
					
				}
	); //click
}//select1

function loadpic(){
	
	if ($("#photodescr").find("img").get(0)){
		//$("#photodescr").find("img").load(function () {
		//$("#photodescr").find("img").get(0).onload = function () {
			//var w = 60+$("#photodescr").find("img").get(0).width; 
			//var h = 80+$("#photodescr").find("img").get(0).height;
		
			/*var w = 60+$($("#photodescr").find("img").get(0)).attr("width");
			var h = 60+$($("#photodescr").find("img").get(0)).attr("height");
			
		
			if (w>=h) h +=40; // h +=120; 
			else { w +=225; h +=10; }*/
		 
			//self.resizeTo(w,h);
		//}
		//});
		
		
	}
}

function select2()
{
	$("#gearlist").find("img").css("display", "none");
	$("#gearlist").find("a").mouseover(
				function () {
						$("#gearlist").find("img").css("display", "block");
						$("#gearlist").find("img").get(0).src = $(this).get(0).getAttribute("plink");
				}							  
	); 
	$("#gearlist").find("a").mouseout(
		function () {
						$("#gearlist").find("img").css("display", "none");
				}								  
	);
}

function pngFix_(){
		
		$("img.img02").each(
			  function()
			  {
				
				 pngFix(this, 101, 105);
			  }
		);
		$("img.img01").each(
			  function()
			  {
				 pngFix(this, 132, 132);
			  }
		);

		$("img.img03").each(
			  function()
			  {
				 pngFix(this, 230, 47);
			  }
		);
		
}

function pngFix(obj, w, h){
	  if( obj.runtimeStyle && obj.src.match( /\.png$/ ) ){
						/*var img = new Image();
						var w; var h;
						img.src = obj.src;
						$(img).load(function () {
							w = this.width;h = this.height;
						}*/
						//alert(window.hostname );
						//alert('http://'+window.location.host +'/_images/0.gif');
						obj.width = w; 
						obj.height = h; 
						obj.runtimeStyle.filter
							= 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src='
							+ obj.src
							+ ', sizingMethod=scale)';
						obj.src = 'http://'+window.location.host+'/_images/0.gif';
						
					}
}

