/*网厅公共调用类
2010-6-8
By iSee
*/

var imgnum = 6;	//adv_flash最多图片显示数量
var CT10000=Class.create();
var areaArray = ['hz','hu','nb','wz','tz','jh','qz','ls','zs','jx','sx'];
var COOKIE_KEY_PROVINCE = "province";	//全省
var COOKIE_KEY_AREAID = "area_id";	//地区
var COOKIE_KEY_CITYID = "city_id";	//业务点
var COOKIE_KEY_CITYID_IP = "city_id_ip";	//业务点的ip Cookie

CT10000.prototype={
	//当前默认业务点
	defUrl:"",
	//存储业务点的编码
	cityMap:false,
    //自定义的构造函数:initialize   
    initialize:function(){
		this.run();
    },
	run:function(){
		$j(document).ready(function(){
			//alert($j.cookie("area_id_ip"));
			/*地区点击 begin*/
			$j("#area .arealist>ul>li>a").click(function(){
			   var city = $j(this).attr("href");
			   city = city.replace(/\//g, "");
			   if(jQuery.inArray(city, areaArray) >= 0){
					CT10000.prototype.setArea(city, this);
					return false;
			   }
			   /*选择的是全省设置清空业务点 cookie*/
			   //CT10000.prototype.setCookie('zj', '', '');
			   return true;
			});
			/*end*/

			/*自动加载头部的搜索onsubmit验证*/
			$j("#topsearch").submit(function(){
				return CT10000.prototype.topSearch();
			});
			
			//是否有公告滚动层存在
			if($j(".marquee").length > 0){
				CT10000.prototype.setAnnounce();
			}
		});

		//窗口resize,更改相应的遮罩层的位置
		$j(window).resize(function() {
			CT10000.prototype.setAreaDiv(); 
			CT10000.prototype.setLoginDiv();
			CT10000.prototype.setProductDiv(); 
		});

	},
	//设置cookie
	setCookie:function(province, area_id, city_id){
		//$j.cookie(’name’, ‘value’, {expires: 7, path: ‘/’, domain: ‘zj.CT10000.com’, secure: true});
		if(province) $j.cookie(COOKIE_KEY_PROVINCE, province);
		if(area_id) $j.cookie(COOKIE_KEY_AREAID, area_id);
		if(city_id) $j.cookie(COOKIE_KEY_CITYID, city_id);
	},
	//动态加载javascript files为Array数组
	loadScript:function(files){
		if(jQuery.isArray(files)){
			var head = $j('head');
			for(var i=0; i<files.length; i++){
				var file = files[i];
				document.write('<script type="text/javascript" src="'+ file +'"></script>');
				//$j("<scri"+"pt>"+"</scr"+"ipt>").attr({src:file,type:'text/javascript',id:''}).appendTo(head);
			}
		}
	},
	//banner图片切换
    showBanner:function(){   
		var imgLength = imgnum;
		var maxLength = $j("#myjQueryContent").children("div").length;
		var ulObject = $j("#myjQueryNav");
		if(imgLength >= maxLength) {
			imgLength = maxLength;
		}else{
			//随机删除图片
			for(var imgindex=0; imgindex<(maxLength-imgLength); imgindex++){
				var nIndex = (Math.round(Math.random()*(maxLength-imgindex+3)));
				$j("#myjQueryContent > div:nth-child("+ (nIndex+1) +")").remove();
			}
		}
		imgnum = imgLength;
		$j("#myjQueryContent > div:nth-child(1)").removeClass("smask"); //删除第一个图片的class
		for(var imgindex=0; imgindex<imgLength; imgindex++){
			$j("<li/>").attr("id","LI"+(imgindex+1)).appendTo(ulObject);
		}
    },
	//是否显示广告，给广告系统调用
	showAds:function(show){
		if($j("div.home_phone_flash").length > 0){
			if(show==1){
				$j("div.home_phone_flash").show();
			}
			else{
				$j("div.home_phone_flash").hide();
			}
		}
	},
	//更换地区 area 地区  curobj 是否存在当前点击 
	setArea:function(area, curobj){
		if(area==''){
			$j("#area .citylist").hide();
		}else{
			$j("#area .citylist").show();
			if(curobj){
				$j("#area .arealist > ul > li > a").removeClass("curr");
				$j("#area .arealist > ul > li > a").filter(function(index) {
					return (curobj.href.indexOf($j(this).attr("href"))>0);
				}).addClass("curr"); 
				$j("#area .citylist > p > a").html(curobj.innerHTML + "全地区");
				$j("#area .citylist > p > a").attr("href",curobj.href);
			}
			
			$j("#area .citylist > ul").hide();
			$j("#area .citylist > ul").filter(function(index) {
				return $j(this).attr("city")==area;
			}).show(); 
		}
		return false;
	},
	//设置当前菜单
	setMenu:function(menuid, i){
		$j(document).ready(function(){
			setHeadMenu(menuid);
			/*
			bannerAlt(menuid, i);
			$j("#" + menuid).mouseout(function(){
				   bannerAlt(menuid, i);
			});

			function bannerAlt(menuid,i){
				var temp = $j("#" + menuid).attr("src");
				if(i==1){
					temp = temp.replace("A", "B");
				}
				if(i==2){
					temp = temp.replace("B", "A");
				}
				$j("#" + menuid).attr("src", temp);
			};
			*/
		});
	},
	//快捷服务选项卡js
	loadService:function(){
		$j(document).ready(function(){
			$j("#rolin>li>h3").click( function () {
			   // alert(i);
			   if ($j(this).parent().find(".fast_service_con").is(":hidden")) {
			   $j("#rolin").find(".fast_service_con").slideUp("slow");
			   $j("#rolin li").removeClass('rolin_active');
			   $j(this).parent().find(".fast_service_con").slideDown("slow");
			   $j(this).parent().addClass('rolin_active');
			  }
			else{}
			   
			});
		});
	},
	//业务点地区选择
	setPoint:function(point){
		//初始化业务点hash
		this.initCityMap();
		//判断city_id_ip是否存在，存在则调整
		if(this.defCityUrlForCookie(point)) return;
		
		//存在#alertDiv层，则添加地区业务的选择层
		if($j("#alertDiv").length > 0){
			//不存在业务点层，则创建
			if($j("#alertDiv .alertarea").length <= 0){
				$j('<div class="alertbox alertarea" style="display:none" ></div>').appendTo("#alertDiv");
				$j('<div class="close"><span>请选择您想要切换到的地区：</span><a href="javascript:;">close</a></div>').appendTo("#alertDiv .alertarea");
				$j('<div class="arealist"></div>').appendTo("#alertDiv .alertarea");
				//把头部地区选择的所有业务点加载进来,并重构
				if($j("#area .arealist").length > 0) {
					$j("#alertDiv .alertarea .arealist").append($j("#area .arealist").html());
					$j("#alertDiv .alertarea .close > a").click(function(){
						$j("#alertDiv").hide();
						$j("#alertDiv .alertarea").hide();
					});
					
					//现网直接用/
					var urlRoot = $j("#alertDiv .arealist > ul > li > a:nth-child(1)").attr("href");//网站根目录，用于删除层中的所有链接含有该根目录
					//替换index(首页为 / 不调用 )
					urlRoot = urlRoot.replace("index/","");
					//var urlRoot = "/";

					$j("#alertDiv .arealist").attr("root", urlRoot); //暂时保持更目录到层属性中以备后用
					$j("#alertDiv .arealist > ul > li:nth-child(1)'").remove();	//删除浙江省
					$j("#alertDiv .arealist").find("p").remove();	//删除全地区选择
				}
				
				
				/*地区点击 begin*/
				$j("#alertDiv .alertarea .arealist>ul>li>a").click( function () {
				   var city = $j(this).attr("href");
				   city = city.substring(urlRoot.length);
				   city = city.replace(/\//g, ''); //去除"/" 取得地区
				   if(jQuery.inArray(city, areaArray) >= 0){
						CT10000.prototype.changePoint(city, this);
						return false;
				   }
				   return true;
				});

				/*删除根地址，保存初始链接地址*/
				$j("#alertDiv .alertarea .arealist .citylist").find("a").each(function(){
					$j(this).attr("url", $j(this).attr("href"));
				});

			}
			//替换业务点url
			var root = $j("#alertDiv .arealist").attr("root");
			//是否套餐业务类，套餐遵循2.0路径格式
			var yewu = (point.indexOf('taocan') >= 0 || point.indexOf('etc') >= 0 || point.indexOf('zhuanti') >= 0 || point.indexOf('yewu') >= 0);
			$j("#alertDiv .alertarea .arealist .citylist").find("a").each(function(){
				var link = $j(this).attr("url");
				var last = root;
				if(yewu){
					last += link.substring(root.length, link.length) + point + "/";	//.shtml
				}else{
					last += point + "/" + link.substring(root.length, link.length);
				}
				$j(this).attr("href",last);	//重构路径
			});
			
			this.setAreaDiv(); 

			//显示层
			$j("#alertDiv").show();
			mask.show("alertDiv");
			$j("#alertDiv .alertarea").show();
		}
	},
	//com.selectArea(point, lstArea, lstCity, speCity, speUrl, defPoint)
	//业务点地区选择 2010-8-24
	//defPoint 是否直接到默认的业务点,设置后直接打开默认业务点地址 如 "hz/yh"
	//point 业务套餐地址 如 taocan/88678
	//lstArea 设置地区数组，不设置显示所有地区 如 ['hz','tz']
	//lstCity 设置城市数组, 不设置显示所有业务点 如['hz/yh','tz/jj']	该功能暂未实现 2010-08-25
	//speCity speUrl 设置特殊的城市和URL，配对出现,可设置业务点和地区；
	//业务点和地区同时出现后，业务点URL会覆盖掉地区的URL
	//地区的地址下面的业务点URL可以用{0}来批量设置不同的地址
	//如 speCity=['hz/yh','tz','wz'],  speUrl=['http://zj.ct10000.com/abc/123/','http://zj.ct10000.com/tz/jj/','http://zj.ct10000.com/{0}/taocan/123/']
	//具体事例可见 http://122.224.205.18/zjpr/activities/zjftth/query.html
	selectArea:function(point, lstArea, lstCity, speCity, speUrl, defPoint){

		init();

		function init(){
			if($j("#alertDiv").length == 0){
				$j("<div id='alertDiv'></div>").appendTo('body');
			}
			if($j("#alertDiv").length > 0){
				//存在业务点选择层，删除，不存在业务点层，则创建
				if($j("#alertDiv .pointSelect").length > 0){
					$j("#alertDiv .pointSelect").remove();
				}
				$j('<div class="alertbox alertarea pointSelect" style="display:none" ></div>').appendTo("#alertDiv");
				$j('<div class="close"><span>请选择您想要切换到的业务点：</span><a href="javascript:;">close</a></div>').appendTo("#alertDiv .pointSelect");
				$j('<div class="arealist pointList"></div>').appendTo("#alertDiv .pointSelect");
				//把头部地区选择的所有业务点加载进来,并重构
				if($j("#area .arealist").length > 0) {
					$j("#alertDiv .pointSelect .pointList").append($j("#area .arealist").html());
					$j("#alertDiv .pointSelect .close > a").click(function(){
						$j("#alertDiv").hide();
						$j("#alertDiv .pointSelect").hide();
					});
					
					var urlRoot = $j("#alertDiv .pointList > ul > li > a:nth-child(1)").attr("href");//网站根目录，用于删除层中的所有链接含有该根目录
					//替换index(首页为 / 不调用 )
					urlRoot = urlRoot.replace("index/","");
					

					$j("#alertDiv .pointList").attr("root", urlRoot); //暂时保持更目录到层属性中以备后用
					$j("#alertDiv .pointList > ul > li:nth-child(1)").remove();	//删除浙江省
					$j("#alertDiv .pointList").find("p").remove();	//删除全地区选择
					//lstArea 有设置地区的值，则过滤
					if(jQuery.isArray(lstArea)){
						if(lstArea.length > 0){
							$j("#alertDiv .pointList > ul > li").hide();
							for(var j=0; j<lstArea.length; j++){
								$j("#alertDiv .pointList>ul>li").find("a").each(function(){
									if($j(this).attr("href").indexOf(lstArea[j])>0){
										$j(this).parent().show();
										//只有一个地区时默认显示业务点
										if(lstArea.length == 1){
											$j(this).addClass("curr");
											CT10000.prototype.changePoint(lstArea[j]);
										}
									}
								});
							}
						}
					}
				}
				
				
				/*地区点击 begin*/
				$j("#alertDiv .pointSelect .pointList>ul>li>a").click( function () {
				   var city = $j(this).attr("href");
				   city = city.substring(urlRoot.length);
				   city = city.replace(/\//g, ''); //去除"/" 取得地区
				   if(jQuery.inArray(city, areaArray) >= 0){
						CT10000.prototype.changePoint(city, this);
						return false;
				   }
				   return true;
				});

				/*删除根地址，保存初始链接地址*/
				$j("#alertDiv .pointSelect .pointList .citylist").find("a").each(function(){
					$j(this).attr("url", $j(this).attr("href"));
				});

				//替换业务点url
				var root = $j("#alertDiv .pointList").attr("root");
				var directTo = false; //是否直接跳转的临时变量
				//是否业务和套餐地址
				var isYewu = (point.indexOf('taocan') >= 0 || point.indexOf('etc') >= 0 || point.indexOf('zhuanti') >= 0 || point.indexOf('yewu') >= 0);
				//是否包含map标签
				var siteMap = "";
				if(point.indexOf('#') > 0){
					siteMap = point.substring(point.indexOf('#'));
					point = point.substring(0,point.indexOf('#'));
				}
				
				$j("#alertDiv .pointSelect .pointList .citylist").find("a").each(function(){
					var link = $j(this).attr("url");
					var last = root;
					
					var pointCity = link.substring(root.length, link.length-1); //取得原业务点的节点URL 如hz/hz
					var pointArea = link.substring(root.length, link.length-4); //取得业务点所属的地区  如hz

					//speCity speUrl 设置了特殊业务点的值，则重构
					var tmpLast = "";
					if(jQuery.isArray(speCity) && jQuery.isArray(speUrl)){
						if(speCity.length > 0 && speUrl.length > 0){
							//重构包含地区的URL
							var arrayIndex = jQuery.inArray(pointArea, speCity);
							if(arrayIndex >= 0){
								tmpLast = speUrl[arrayIndex].replace("{0}",pointCity);
							}
							//重构包含业务点的URL
							arrayIndex = jQuery.inArray(pointCity, speCity);
							if(arrayIndex >= 0){
								tmpLast = speUrl[arrayIndex];
							}
						}
					}
					if(tmpLast!=""){
						last = tmpLast;
					}else{
						//是否业务URL
						if(isYewu){
							last += link.substring(root.length, link.length) + point + "/";
						}else{
							last += point + "/" + link.substring(root.length, link.length);
						}
						//添加描点
						last += siteMap;
						
					}
					//默认业务点存在，并且配对就直接跳转
					if(defPoint!='undefined' && defPoint!=null && defPoint!=""){
						if(defPoint == pointCity){
							window.open(last);
							directTo = true;
							return;
						}
					}
					$j(this).attr("href",last);	//重构路径
					$j(this).attr("target","_blank");
					$j(this).click(function(){
						$j("#alertDiv").hide();	//隐藏弹窗
					});
				});
				if(directTo) return;
				CT10000.prototype.setAreaDiv(); 

				//显示层
				$j("#alertDiv").show();
				$j("#alertDiv .pointSelect").show();
			}
		}
	},
	//ie 6中select无法遮罩的解决，用iframe层
	setAlertIframe:function(){
		if($j("#alertDiv #alertIframe").length <=0){
			$j('<iframe id="alertIframe" style="position:absolute;width:100%;height:100%;_filter:alpha(opacity=0);opacity=0;border-style:none;"></iframe>').appendTo("#mask_id");
		}
	},
	//遮罩层更改大小
	setMaskResize:function(){
		//遮罩层变动
		$j("#alertDiv .mask_block").css({
			"height": $j(document).height() + "px",
			"width": $j(document).width() + "px"
		});
	},
	//选择地区业务点层设置
	setAreaDiv:function(){
		//让层一直出现在中央和全屏
		$j("#alertDiv .alertarea").css({
			"position":"absolute",
			"top":($j(window).height())/2 + $j(window).scrollTop() + "px",
			"left":($j(window).width())/2 + $j(window).scrollLeft() + "px"
		});
		this.setMaskResize();
		this.setAlertIframe();
	},
	//登录层设置
	setLoginDiv:function(){
		//让层一直出现在中央和全屏
		$j("#alertDiv .alertlogin").css({
			"position":"absolute",
			"top":($j(window).height())/2 + $j(window).scrollTop() + "px",
			"left":($j(window).width())/2 + $j(window).scrollLeft() + "px"
		});
		this.setMaskResize();
		this.setAlertIframe();
	},
	//类型选择层设置
	setProductDiv:function(){
		//让层一直出现在中央和全屏
		$j("#alertDiv .produtalert").css({
			"position":"absolute",
			"top":($j(window).height())/2 + $j(window).scrollTop() + "px",
			"left":($j(window).width())/2 + $j(window).scrollLeft() + "px"
		});
		this.setMaskResize();
		this.setAlertIframe();
	},
	//更改业务点点击
	changePoint:function(area, curobj){
		if(area==''){
			$j("#alertDiv .alertarea .arealist .citylist").hide();
		}else{
			$j("#alertDiv .alertarea .arealist .citylist").show();
			if(curobj){
				$j("#alertDiv .alertarea .arealist > ul > li > a").removeClass("curr");
				$j("#alertDiv .alertarea .arealist > ul > li > a").filter(function(index) {
					return curobj.href.indexOf($j(this).attr("href"))>=0; //return curobj.href.indexOf($j(this).attr("href") && ($j(this).attr("href") != "/"))>=0; //首页为 /调用
				}).addClass("curr"); 
			}
			
			$j("#alertDiv .alertarea .arealist .citylist > ul").hide();
			$j("#alertDiv .alertarea .arealist .citylist > ul").filter(function(index) {
				return $j(this).attr("city")==area;
			}).show(); 
		}
		return false;
	},
	//头部搜索验证
	topSearch:function(){
		var key = $j("#query").attr("value");
		if(key.length <= 0) {
			key = "充值";
		}
		//搜索都转到电信客户知识库系统上
		$j("#topsearch").attr("action","/zjpr/faq/faqSearch/search.htm?pr_faq_searchDomain.keywords=" + key);
		$j("#topsearch").attr("method","POST");

		return true;
	},
	hdzoneUrl:function(nexturl){
		if(nexturl.indexOf("chanpin")>=0 || nexturl.indexOf("denglu")>=0){
			this.setLoginDiv();
			nexturl = nexturl.substring(nexturl.indexOf("nexturl")+8);
			//um_tanchu_login(nexturl);
			um_jump_login(nexturl);
		}else{
			if(nexturl.indexOf("http://")>=0){
				window.location.href =nexturl;
			}
			if(com.isInserver()){
				host = window.location.host;	
		    }else{
				host = window.location.host+"/ct10000";
		    }
			if(nexturl.substring(0,1) == "/") {
				window.location.href ="http://"+host+nexturl;
			}
			else{
				window.location.href ="http://"+host+"/"+nexturl;
			}
			return;
		}
	},
	//退出登录
	exit:function()
	{
		var nexturl = this.getLastNextUrl();
		if(this.getCurrentURI){
			window.location.href="/zjpr/user/signout.htm?nexturl="+nexturl;
		}else{
			window.location.href="/ct10000/zjpr/user/signout.htm?nexturl="+nexturl;
		}
		return false;
	},
	//获取当前页面地址
	getLastNextUrl:function()
	{
		var currentUrl = document.location.href;
		var currentUrl1 = currentUrl.substring(8,currentUrl.length);
		var host = document.location.host;
		var nexturl = currentUrl1.substring(host.length,currentUrl1.length);
		var index = 0;
		while (nexturl.indexOf("/")>=0){
			if(index>=20){
				nexturl=null;
				break;
			}
			index++;
			nexturl = nexturl.replace("/","%2F");
		}
		var count=0;
		while(nexturl.indexOf("?")>=0){
			if(count>=20){
				nexturl=null;
				break;
			}
			index++;
			nexturl = nexturl.replace("?","%3F");
		}
		return nexturl;
	},
	//当前页面的Url
	getCurrentURI:function(){
		var url = top.location.href;
		url = url.replace(top.location.host,'');
		url = url.replace("http:///","");
		//alert(url);
		return escape(url);
	},
	//iMusic音乐
	iMusic:function(musicid, songerid){
		if(musicid){
			window.open("http://www.118100.cn/v5/action/secweborder/weborder2.do?cid="+ musicid +"&pt=1&ca=");
		}
		else if(songerid){
			window.open("http://www.118100.cn/Quku/Artist/"+ songerid +"---------/--/--/qk/qk_singer_info/singinfo.html");
		}
	},
	//判断是否在服务器上
	isInserver:function (){
		var cuurenturl = window.location.href;
		if(cuurenturl.indexOf("/ct10000/")>=0)return false;
		return true;
    },
	//网厅公告
	setAnnounce:function(){
		//$j(".marquee").each(function() {
		//   $j(this).marquee();
		//});
		$j(".marquee").marquee();
		$j("div.index_newsT_gundongimg a.a1>img").css("cursor","pointer");
		$j("div.index_newsT_gundongimg a.a1:nth-child(1)>img").click(function(){
			_marquee_stop = true
			//CT10000.prototype.changePause();
			_next = true;
			_marquee_stop = false;
		});
		
		//$j("div.announce div.announce_sub:nth-child(2)>img").click(function(){
		//	if(_marquee_stop){
		//		_marquee_stop = false;
		//	}else{
		//		_marquee_stop = true;
		//	}
		//	CT10000.prototype.changePause()
		//});
			
		$j("div.index_newsT_gundongimg a.a1:nth-child(2)>img").click(function(){
			_marquee_stop = true
			//CT10000.prototype.changePause();
			_prev = true;
			_marquee_stop = false;
		});
	},
	//更改公告状态
	/*
	changePause:function (){
		var pic = $j("div.index_newsT_gundongimg a.a1:nth-child(2)>img").attr("src");
		if(_marquee_stop){
			pic = pic.replace("pause","run");
		}else{
			pic = pic.replace("run","pause");
		}
		$j("div.index_newsT_gundongimg a.a1:nth-child(2)>img").attr("src",pic);
	},
	*/
	//初始化地区和业务点的编号
	initCityMap:function(){
		if(!this.cityMap) {
			var map = new hashMap();
			map.set("570001","qz/qz");
			map.set("570002","qz/js");
			map.set("570003","qz/cs");
			map.set("570004","qz/kh");
			map.set("570005","qz/ly");
			map.set("571001","hz/hz");
			map.set("571002","hz/xs");
			map.set("571003","hz/yh");
			map.set("571004","hz/fy");
			map.set("571005","hz/la");
			map.set("571006","hz/tl");
			map.set("571007","hz/jd");
			map.set("571008","hz/ca");
			map.set("572001","hu/hu");
			map.set("572002","hu/dq");
			map.set("572003","hu/cx");
			map.set("572004","hu/aj");
			map.set("573001","jx/jx");
			map.set("573002","jx/js");
			map.set("573003","jx/ph");
			map.set("573004","jx/hy");
			map.set("573005","jx/hn");
			map.set("573006","jx/tx");
			map.set("574001","nb/nb");
			map.set("574002","nb/zh");
			map.set("574003","nb/bl");
			map.set("574004","nb/cx");
			map.set("574005","nb/yy");
			map.set("574006","nb/fh");
			map.set("574007","nb/nh");
			map.set("574008","nb/xs");
			map.set("574009","nb/yz");
			map.set("575001","sx/sx");
			map.set("575002","sx/zj");
			map.set("575003","sx/sy");
			map.set("575004","sx/cz");
			map.set("575005","sx/xc");
			map.set("576001","tz/jj");
			map.set("576002","tz/hy");
			map.set("576003","tz/lq");
			map.set("576004","tz/wl");
			map.set("576005","tz/lh");
			map.set("576006","tz/tt");
			map.set("576007","tz/yh");
			map.set("576008","tz/xj");
			map.set("576009","tz/sm");
			map.set("577001","wz/ra");
			map.set("577002","wz/py");
			map.set("577003","wz/cn");
			map.set("577004","wz/yj");
			map.set("577005","wz/lq");
			map.set("577006","wz/dt");
			map.set("577007","wz/wc");
			map.set("577008","wz/ts");
			map.set("577009","wz/wz");
			map.set("578001","ls/ls");
			map.set("578002","ls/jy");
			map.set("578003","ls/qt");
			map.set("578004","ls/lq");
			map.set("578005","ls/qy");
			map.set("578006","ls/jn");
			map.set("578007","ls/sc");
			map.set("578008","ls/yh");
			map.set("578009","ls/sy");
			map.set("579001","jh/jh");
			map.set("579002","jh/lx");
			map.set("579003","jh/yw");
			map.set("579004","jh/pj");
			map.set("579005","jh/yk");
			map.set("579006","jh/pa");
			map.set("579007","jh/dy");
			map.set("579008","jh/wy");
			map.set("580001","zs/zs");
			map.set("580002","zs/pt");
			map.set("580003","zs/ds");
			map.set("580004","zs/ss");

			this.cityMap = map;
		};
	},
	//判断是否city_id_ip Cookie是否存在
	defCityUrlForCookie:function(point){
		//如果不是首页的地址 弹出选择窗
		var url = window.location.href;
		if(!/^http:\/\/(.+)\/index\//.exec(url))return false;
		var cookie_key_cityid_ip = $j.cookie(COOKIE_KEY_CITYID_IP);
		//如果存在，重构地址并跳转
		if(this.cityMap.contains(cookie_key_cityid_ip)){
			var cityUrl = this.cityMap.get(cookie_key_cityid_ip);
			var urlRoot = $j("#area .arealist > ul > li > a:nth-child(1)").attr("href");//网站首页地址
			//如果是业务地址
			var descUrl = (point.indexOf("yewu/") >= 0)?(cityUrl + "/" + point):(point + "/" + cityUrl);
			//替换index(首页为 / 不调用 )
			urlRoot = urlRoot.replace("index/","");
			//重构跳转地址
			urlRoot += (point.indexOf("{0}") > 0) ? point.replace("{0}", cityUrl) : descUrl;
			urlRoot += "/";
			
			location.href = urlRoot;
			return true;
		}
	}
};

//javacript 构造的hashMap
var hashMap = function(){
	this.set = function(key,value){this[key] = value};
	this.get = function(key){return this[key]};
	this.contains = function(key){return this.get(key) == null?false:true};
	this.remove = function(key){delete this[key]};
}


/*jquery cookie 扩展*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


//网厅公告类

var _marquee_stop = false;
var _prev = false;
var _next = false;

(function($) {
$.fn.marquee = function(o) {
   //获取滚动内容内各元素相关信息
   o = $.extend({
    speed:   parseInt($j(this).attr('speed')) || 100, // 滚动速度
    step:   parseInt($j(this).attr('step')) || 1, // 滚动步长=li宽度
    direction: $j(this).attr('direction') || 'up', // 滚动方向
    pause:   parseInt($j(this).attr('pause')) || 1000 // 停顿时长
   }, o || {});
   var dIndex = jQuery.inArray(o.direction, ['right', 'down']);
   if (dIndex > -1) {
    o.direction = ['left', 'up'][dIndex];
    o.step = -o.step;
   }
   var mid;
   var div    = $j(this); // 容器对象
   var divWidth = div.innerWidth(); // 容器宽
   var divHeight = div.innerHeight(); // 容器高
   var ul     = $j("ul", div);
   var li     = $j("li", ul);
   var liSize    = li.size(); // 初始元素个数
   var liWidth = li.width(); // 元素宽
   var liHeight = li.height(); // 元素高
   var width    = liWidth * liSize;
   var height    = liHeight * liSize;
   if ((o.direction == 'left' && width > divWidth) || 
    (o.direction == 'up' && height > divHeight)) {
    // 元素超出可显示范围才滚动
    if (o.direction == 'left') {
     ul.width(2 * liSize * liWidth);
     if (o.step < 0) div.scrollLeft(width);
    } else {
     ul.height(2 * liSize * liHeight);
     if (o.step < 0) div.scrollTop(height);
    }
    ul.append(li.clone()); // 复制元素
    mid = setInterval(_marquee, o.speed);
    div.hover(
     function(){clearInterval(mid);},
     function(){mid = setInterval(_marquee, o.speed);}
    );
   }
   function _marquee() {
	if(_next){
		goNext();
		return;
	}
	if(_prev){
		goPrev();
		return;
	}
	if(!_marquee_stop){
		_goMarquee();
	}
	//if(_prev) _prev = false;
	//if(_next) _next = false;
	
    
   }
   function _goMarquee(){
	// 滚动
    if (o.direction == 'left') {
     var l = div.scrollLeft();
     if (o.step < 0) {
      div.scrollLeft((l <= 0 ? width : l) + o.step);
     } else {
      div.scrollLeft((l >= width ? 0 : l) + o.step);
     }
     if (l % liWidth == 0) _pause();
    } else {
     var t = div.scrollTop();
     if (o.step < 0) {
      div.scrollTop((t <= 0 ? height : t) + o.step);
     } else {
      div.scrollTop((t >= height ? 0 : t) + o.step);
     }
     if (t % liHeight == 0) _pause();
    }
   }
   function goNext(){
	    var t = div.scrollTop();
		div.scrollTop((t <= 0 ? height : t) - liHeight);
		_next = false;
   }
   function goPrev(){
		var t = div.scrollTop();
		div.scrollTop((t <= 0 ? height : t) + liHeight);
		_prev = false;
   }

   function _stop(){
	   clearInterval(mid);
   }
   function _pause() {
    // 停顿
    if (o.pause > 0) {
     var tempStep = o.step;
     o.step = 0;
     setTimeout(function() {
      o.step = tempStep;
     }, o.pause);
    }
   }
};
})(jQuery);


function productTypeToPinyin(type) {
    switch(type) {
        case 1 : return "guhua";
        case 10 : return "xiaolingtong";
        case 15 : return "kuandai";
        case 18 :  return "shouji";
        default: return "";
    }
}
