var PublicConfig_showLogo01 = function(){
	
	var opts={
		clientAddress:"",
		china:"",
		english:"",
	    hanyu:"",
		fanti:"",
		riyu:"",
		eyu:"",
		fayu:"",
		xibanyayu:"",
		putaoyayu:"",
		deyu:"",
		languageList:""
		
	};
	
	var init=function(options){
	    $.extend(opts,options);
	    
	    initEvents();
	};
	
	var initEvents=function(){
		isdianji=true;
		if($(".showStyle4").length){
			
		}
		
		var regex=/zmobile/; 		
	    var isResee=regex.test(navigator.userAgent)||/zmios/.test(navigator.userAgent);
	    if(isResee){
	     $(".lang").hide();
	    }
	 
	    var languageList = opts.languageList;
	    for(var i=0;i<languageList.length;i++){
	    var HTMLlanguage ="";
	        HTMLlanguage='<li id="languageId'+i+'">'+
					     '<span class="active current" id="'+languageList[i].codes+'" alt="">'+languageList[i].name+'</span>'+
				         '<input type="hidden" id="websites" value="'+languageList[i].website+'"/>'+
				         '</li>';
		   $("#languageListHTML").append(HTMLlanguage); 
		   $("#languageId"+i).click(function(event,i){
		        event.stopPropagation();
		        var website = $(this).find("input").val();
				location.href="http://"+website;
		   });
	    }
//	    for(var i=0;i<languageList.length;i++){
//	    	var languageHtml="";
//		    languageHtml='<div class="langItem active" id="languageList'+i+'">'+languageList[i].name+'</div>'+
//		    '<input type="hidden" id="websites" value="'+languageList[i].website+'"/>';
//		    $("#languageHtml").append(languageHtml); 
//		    $("#languageList"+i).click(function(event){
//		        event.stopPropagation();
//		        var website = $(this).find("input").val();
//				location.href="http://"+website;
//		   });
//	    }
	 
 		
 		if($(".pageIndex").length || $(".PublicConfig_showLogo01-d1_c1 .showStyle1").length || $(".PublicConfig_showLogo01-d1_c1 .showStyle2").length || $(".PublicConfig_showLogo01-d1_c1 .showStyle3").length){
 			$(".PublicConfig_showLogo01-d1_c1").show();
 		}
 	
 	
		$("#downloadAndroid").tap(function(){
			location.href=opts.clientAddress;
		});
		$(document).tap(function(){
			$("span[name=openT]").not(".search").removeClass("current");
			$("#download").hide();
			$("#langurage").hide();
		});
		
		$("#download").tap(function(e){
			e.stopPropagation();
		});
		
		var tpass=1;

		$("span[name=openT]").tap(function(e){
			$("span[name=openT]").removeClass("current");
			e.stopPropagation();
			//处理微信tap触发两次问题
			if(tpass){
				tpass=0;
				setTimeout(function(){tpass=1;},500);
			}else{
				return;
			}
			if($(this).hasClass("search")){
				openToolbar('t',this);
			} else 
			if($(this).hasClass("download")){
				openToolbar('d',this);
			}else if($(this).hasClass("lang")){
				openToolbar('f',this);
			}
		});
		
		$(".showStyle3 .toolControl").tap(function(){
			$(this).parent().toggleClass("open");
			
		});
		function linkNavListClick(){
			location = $(this).data("link");
		}
		function openPublicConfigLogoNavTree(curId){
			$.ajax({
				type:'post',
				cache:false,
				async:false,
				url:"/PublicConfig.do?method=getLogoMoreSection",
				success:function(rs){
					$("#"+curId).html(rs);
					var initH = parseFloat($(window).height());
					$("#"+curId+" .contWrap").css("min-height",parseFloat($(window).height())+"px");
					$("#"+curId+" #navTheList").css("height",initH+"px");
					
					var navThelistScroll = new iScroll("navTheList", {
						zoom: false,
						hScroll: false,
						hScrollbar: false,
						vScrollbar : false,
						bounce: false,
						onBeforeScrollStart: function(e) {
							var target = e.target;
							navThelistScroll.targetElement = target;
							navThelistScroll.clickFunc = $(target).attr("onclick");
							
							while (target.nodeType != 1) target = target.parentNode;
							if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA' && target.tagName != 'BUTTON'){
								if(!$.os.ios){
									e.preventDefault();
								}
							}
						},
						onScrollMove :function(event){
							event.preventDefault();
							event.stopPropagation();
							navThelistScroll.touchMoveFlag = true;
						},
							
						onTouchEnd : function(){
							if(navThelistScroll.touchMoveFlag){
								
								$(navThelistScroll.targetElement).unbind("click",linkNavListClick);
								setTimeout(function(){
									$(navThelistScroll.targetElement).bind("click",linkNavListClick);
									navThelistScroll.targetElement = null;
									navThelistScroll.clickFunc = null;
									navThelistScroll.startY = null;
									navThelistScroll.endY = null;
									navThelistScroll.touchMoveFlag = false;
								},500);
							}
						  }
					});
					navThelistScroll.refresh();
					//$("#"+curId).css("left","0px");
					//$("#box_mainBody").css("position","relative");
					
					FUI.openMoreLayer("#"+curId,"r"); 
					
					$("#"+curId).bind("touchmove",function(event){
						event.preventDefault();
						event.stopPropagation();	
					});
					
					$("#"+curId+" .barWrap").tap(function(){
				
						//$("#"+curId).css("left","-100%");
						//$("#box_mainBody").css("position","absolute");
						FUI.closeMoreLayer("#"+curId,"r"); 
						//FUI.openMoreLayer("#"+curId,"r"); 
					});
					$("#"+curId).swipeLeft(function(e){
						//$("#"+curId).css("left","-100%");
						//$("#box_mainBody").css("position","absolute");
						FUI.closeMoreLayer("#"+curId,"r"); 
					});
					$("#"+curId+" .navWrap li h3").click(linkNavListClick);
					
					$("#"+curId+" #downloadAndroid").tap(function(){
						location.href=opts.clientAddress;
					});
									
					 var languageList = opts.languageList;
					 for(var i=0;i<languageList.length;i++){
				    	var languageHtml="";
					    languageHtml='<div class="langItem active" id="languageList'+i+'" data-code="websites'+i+'">'+languageList[i].name+'</div>'+
					    '<input type="hidden" id="websites'+i+'" value="'+languageList[i].website+'"/>';
					    $("#languageHtml").append(languageHtml); 
					    $("#languageList"+i).click(function(event){
					        event.stopPropagation();
					        var thisinputID=$(this).data("code");
					        var website =  $("#"+thisinputID).val();
							location.href="http://"+website;
					   });
				    }
				       navThelistScroll.refresh();
					
					var url = window.location.href;

					for(var i=0;i<$("#"+curId+" #navTheList").find(".item").length;i++){
						var index = "";
	                    var datalink = $("#"+curId+" #navTheList").find(".item h3").eq(i).attr("data-link");
	                    if(datalink == '/index.html'){
	                    	var index = "http://" + window.location.host+"/";
	                    }
	                    var link = "http://" + window.location.host + datalink 
	                    if(url==link || url==index){
	                    	$("#"+curId+" #navTheList").find(".item").eq(i).addClass("current");
	                    }
					}
				}
			});
			
			      
		}
		if($("#PublicConfigLogoNavTreeOpenBtn").length){
			$("#PublicConfigLogoNavTreeOpenBtn").tap(function(){
				openPublicConfigLogoNavTree("PublicConfigLogoNavTree");
			});
		}
		
		$(".PublicConfig_showLogo01-d1_c1 .logoWrap img").tap(function(){
			location.href="/index.html";
		});
		$(".showStyle4 .list").tap(function(){
			openPublicConfigLogoNavTree("PublicConfigLogoNavTreeOne");
			
		});
		
		$(".showStyle3 .logoWrap").swipeLeft(function(e){
			$(this).next().toggleClass("open");
		});
		$(".showStyle3 .toolWrap").swipeRight(function(e){
			$(this).toggleClass("open");
		});
		var browseMode=localStorage["browseMode"];
	
		if(browseMode=='close'){
			$("#hdLine").hide();
			$("#hdBtnTop").hide();
		}
		switchHdTopButton(browseMode);
		/*switchButton(browseMode);
	
		$("#hdBtnTop").tap(function(e){
			if($("#hdSpan").hasClass("hdmode")){
				switchHdTopButton('lc');
				switchButton('lc');
			}else{
				switchHdTopButton('gq');
				switchButton('gq');
			}
		});
		$("#hdBtnTop").swipeLeft(function(e){
			switchHdTopButton('gq');
			switchButton('gq');
		});
		$("#hdBtnTop").swipeRight(function(e){
			switchHdTopButton('lc');
			switchButton('lc');
		});	*/
		
	};
	
	window.mainBodyBottom=0;
	
	var openToolbar=function(flag,el){
		if(flag=='f'){
			$(el).toggleClass("current").siblings().removeClass("current");
			$('#othercolumns').hide();
			$("#download").hide();
			
			$("#searchmoney").removeClass("current");
			$("#searchweighing").height(0);
			$("#box_mainBody").css("position","absolute");
			isdianji=true;
			
			$("#langurage").toggle();
		}
		if(flag=='d'){
			$(el).toggleClass("current").siblings().removeClass("current");
			$('#othercolumns').hide();
			$("#langurage").hide();
			
			$("#searchmoney").removeClass("current");
			$("#searchweighing").height(0);
			$("#box_mainBody").css("position","absolute");
			isdianji=true;
			
			$("#download").toggle();
		}
		if(flag=='t'){
			$("#langurage").hide();
			$("#download").hide();
			
			var logoheight= $(".PublicConfig_showLogo01-d1_c1").height();
			var searchTab = $(".searchTab").height();
			var searchInput= $(".searchInput").height();
			
			if(isdianji){
				$("#searchmoney").addClass("current");
				$("#searchweighing").height(document.body.scrollHeight-logoheight);
				$(".searchResult").css("max-height",document.body.scrollHeight-searchTab-searchInput-logoheight);
				$(".searchResult").hide();
				mainBodyBottom=$('#box_mainBody').css('bottom');
				if($.os.ios&&navigator.userAgent.indexOf("Safari")!=-1 && navigator.userAgent.indexOf("MQQBrowser")==-1){
					$('#box_mainBody').css('bottom','-61px');
				}else{
					$('#box_mainBody').css('bottom','0');
				}
				//$("#box_mainBody").css("position","relative");
				$(".controlBar").hide();
				$('.circleIcon,.circleListWrap,.toolMoreWrap,.controlBar').hide();
				isdianji=false;
			}else{
				$("#searchmoney").removeClass("current");
				$("#searchweighing").height(0);
				$("#box_mainBody").css("bottom",mainBodyBottom);
				//$("#box_mainBody").css("position","absolute");
				$(".controlBar").show();
				$('.circleIcon,.controlBar').show();
				isdianji=true;
			}
		}
	};
	var switchHdTopButton=function(str){
		if(str=='lc'){
			$("#hdSpan").addClass('lcmode');
			$("#hdSpan").removeClass('hdmode');		
		}else if(str=='gq'){
			$("#hdSpan").addClass('hdmode');
			$("#hdSpan").removeClass('lcmode');		
		}
	}
	
	return {
		init:init
	};
}();


