// JavaScript Document
document.oncontextmenu=function(e){return false;}
var IndxI;
$(document).ready(function(){
	if($('#leftProd').find('.lev_0_prod').length && !$('#extToolsNone').length){
		$('#leftProd > .lev_0_prod[value="'+$('#leftProd').attr('value')+'"]').addClass('sel');
		$('#leftProd > .lev_0_prod[value="'+$('#leftProd').attr('value')+'"]').find('.lev_3_prod').show();
		$('#leftProd > .lev_0_prod[value="'+$('#leftProd').attr('value')+'"]').find('.lev_2_prod').fadeIn();
		$('#leftProd > .sel >.lev_2_prod[value="'+$('#leftProd1').attr('value')+'"]').nextAll('.lev_3_prod[value="'+$('#leftProd2').attr('value')+'"]').eq(0).find('a').addClass('sel2');
		
		/*$('#leftProd > .sel >.lev_3_prod[value="'+$('#leftProd2').attr('value')+'"]').find('a').addClass('sel2');*/
		
		
		$('#leftProd > .sel >.lev_2_prod[value="'+$('#leftProd2').attr('value')+'"]').find('.exh_a_d').addClass('sel31');
		$('#leftProd > .sel >.lev_2_prod[value="'+$('#leftProd2').attr('value')+'"]').find('.sel31').removeClass('exh_a_d')
		$('#leftProd > .sel >.lev_2_prod[value="'+$('#leftProd2').attr('value')+'"]').find('.exh_a_t').addClass('sel32');
		$('#leftProd > .sel >.lev_2_prod[value="'+$('#leftProd2').attr('value')+'"]').find('.sel32').removeClass('exh_a_t');
		
		$('.exh_a_t,.exh_a_d').hover(function(){
			$(this).parent().find('.exh_a_d').addClass('sel31');
			$(this).parent().find('.exh_a_t').addClass('sel32');
		},function(){
			$(this).parent().find('.exh_a_d').removeClass('sel31');
			$(this).parent().find('.exh_a_t').removeClass('sel32');
		
		});
	}else if($('#extToolsNone').length){
		$('#leftProd > .lev_0_prod[value="'+$('#leftProd').attr('value')+'"]').addClass('sel');
	}
	if($('#prod_1_img').find('img').length>1){
		setInterval("showImg()",10000);
	}
	showPIC();
	
	menu();
	homeList();
})

function homeList(){
	if($('.homeList').length){
		swfobject.createCSS("#topList", "display:block;text-align:center; margin:0 auto;");
		swfobject.embedSWF("/picture.swf", "topList", "220", "160", "8", "/playerProductInstall.swf",
						   {
							   xmlUrl:'/home/topList_en/index.xml?do='+Math.round(Math.random()*10000),
							   fadeSpeed:35,
							   speed:8.3
						   }
						   );
		swfobject.createCSS("#BomList", "display:block;text-align:center; margin:0 auto;");
		swfobject.embedSWF("/picture.swf", "BomList", "220", "160", "8", "/playerProductInstall.swf",
						   {
							   xmlUrl:'/home/bottomList_en/index.xml?do='+Math.round(Math.random()*10000),
							   fadeSpeed:35,
							   speed:8.3
						   }
						   );
		/**/
		
		
		
		
/*
swfobject.embedSWF("/picture.swf", "bomList", "220", "160", "10.0.0", "/playerProductInstall.swf",{xmlUrl:' /home/main/bottomList/index.xml'});
		swfobject.createCSS("#bomList", "display:block;text-align:center; margin:0 auto 15px");
		swfobject.embedSWF("/picture.swf", "topList", "220", "160", "10.0.0", "/playerProductInstall.swf",{xmlUrl:'/home/main/topList/index.xml'});
		swfobject.createCSS("#topList", "display:block;text-align:center; margin:13px auto");
*/
 
	}
};

function menu(){
	if($.browser.msie && $.browser.version=='6.0'){
		/*
		var m2Len=0;
		//alert($('#menu2').width());
		$('#menu2 >.lev_0_prod').width($('#menu2').width());
		$('#menu2 > .lev_0_prod > .lev_1_prod').width(500);
		for(var i=0;i<$('#menu2').find('.lev_0_prod').length;i++){
			
			if($('#menu2').find('.lev_0_prod').eq(i).find('.lev_1_prod').width()>m2Len){
				m2Len=$('#menu2').find('.lev_0_prod').eq(i).find('.lev_1_prod').width();
				
			}
		}
		$('#menu2').find('.lev_0_prod').find('.lev_1_prod').width(m2Len);
		*/
	}
	$('.top2').find('img').mouseover(function(){
		if($(this).attr('name')=='product'){
			$('#menu2').show();
		}else{
			$('#menu2').hide();
		}
		if($(this).attr('name')=='services'){
			$('#menu3').show();
		}else{
			$('#menu3').hide();
		}
	});
	$('#menu2').find(' .lev_1_prod').hover(function(){
		$(this).css('background','#7d0200');
	},function(){
		$(this).css('background','#570100');
	});
	$('#menu2').hover(function(){
		//$(this).css('background','#7d0200');
	},function(){
		$('#menu2').hide();
	});
	
	
	$('#menu3').find(' .lev_1_prod').hover(function(){
		$(this).css('background','#7d0200');
	},function(){
		$(this).css('background','#570100');
	});
	$('#menu3').hover(function(){
		//$(this).css('background','#7d0200');
	},function(){
		$('#menu3').hide();
	});
}
function showPic_(inx){
	if (typeof document.body.style.maxHeight === "undefined") {
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		$('select').hide();
	}
	var sum=$('.imgpdList').length;
	IndxI=inx;
	$("body").append("<div id='RO_overlay'></div><div id='RO_window'><img id='RO_img' src='/images/loading.gif'/></div><div id='RO_imgColse'></div><div id='RO_imgPrev'></div><div id='RO_imgNext'></div>");
	$('#RO_overlay').addClass('RO_overlayBG');
	$('#RO_overlay,#RO_imgColse').click(function(){closeImg()});
	nextPrev();
	$('#RO_imgNext').click(function(){
		IndxI++;
		if(IndxI==sum) IndxI=0;
		imgLoad();
		nextPrev();
	});
	$('#RO_imgPrev').click(function(){
		IndxI--;
		if(IndxI<0) IndxI=sum-1;
		imgLoad();
		nextPrev();
	});
	
	$("#RO_window").css({display:"block"});
	imgLoad();

}
function nextPrev(){
	if(IndxI<($('.imgpdList').length-1)) $('#RO_imgNext').fadeIn();
	else $('#RO_imgNext').fadeOut();
	if(IndxI>0) $('#RO_imgPrev').fadeIn();
	else $('#RO_imgPrev').fadeOut();
}
function imgLoad(){
	var img=new Image();
	img.src=$('.imgpdList').eq(IndxI).attr('value');
	$(img).load(function(){ 
		var pagesize = getPageSize();
		var imageWidth = img.width;
		var imageHeight = img.height;
		var x = pagesize[0] - 150;
		var y = pagesize[1] - 150;
		RO_WIDTH = imageWidth;
		RO_HEIGHT = imageHeight 
		$('#RO_img').attr('src',$('.imgpdList').eq(IndxI).attr('value'));
		$('#RO_img').hide();
		$('#RO_img').fadeIn();
		position();
	});
	if(jQuery.browser.msie){
		img.src=$('.imgpdList').eq(IndxI).attr('value');
	}
}

function showImg(){
	var n=$('#prod_1_img').find('img').length;
	var ind=$('#prod_1_img').find('img').index($('#prod_1_img>.selImg'));
	ind++;
	if(ind==n) ind=0;
	$('#prod_1_img > .selImg').fadeOut(1500);
	$('#prod_1_img').find('img').eq(ind).fadeIn(1500);
	$('#prod_1_img > .selImg').removeClass('selImg');
	$('#prod_1_img').find('img').eq(ind).addClass('selImg');
}
function showPIC(){
	if($('.imgpdList').length){
		$('.imgpdList').click(function(){
			showPic_($('.imgpdList').index(this));
		});
		$('#dp_img_btn').click(function(){showPic_(0)});
	}
}
function closeImg(){
	//$("#RO_imageOff").unbind("click");
	//$("#RO_closeWindowButton").unbind("click");
	$('#RO_window,#RO_overlay,#RO_img,#RO_imgColse,#RO_imgPrev,#RO_imgNext').unbind( "click" ) ;
	$("#RO_window").fadeOut("fast",function(){$('#RO_window,#RO_overlay,#RO_img,#RO_imgColse,#RO_imgPrev,#RO_imgNext').trigger("unload").unbind().remove();});
	//$("#RO_window,#RO_overlay,#RO_img,#RO_imgColse,#RO_imgPrev,#RO_imgNext").remove();
	//$("#RO_window").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
		$('select').show();
	}
	//document.onkeydown = "";
	//document.onkeyup = "";
	return false;
}

function getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}
function position() {
$("#RO_window").css({marginLeft: '-' + parseInt((RO_WIDTH / 2),10) + 'px', width: RO_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		$("#RO_window").css({marginTop: '-' + parseInt((RO_HEIGHT / 2),10) + 'px'});
	}
}
/*
var n=$('#prod_1_img').find('img').length;
	var ind=$('#prod_1_img').find('img').index($('#prod_1_img>.selImg'));
	ind++;
	if(ind==n) ind=0;
	$('#prod_1_img > .selImg').fadeOut(1500);
	$('#prod_1_img').find('img').eq(ind).fadeIn(1500);
	$('#prod_1_img > .selImg').removeClass('selImg');
	$('#prod_1_img').find('img').eq(ind).addClass('selImg');
*/
function cl(t){if (t.defaultValue==t.value) t.value = '';}

