var yMobEvt = function(){ }; // Stub for Events and handlers
var yMobVal = function(){ }; // Stub for Validation
var urlargs=new Array(); 
yMobEvt.prototype = {
	globals: {
		'widthNarrow' : "300",
		'widthWide' : "600",
		'widthSel' : "300",
		'err':"出错啦: "
	},
	customGlobals: { //Default settings for customizable items
		'bg':'FFFFFF',
		'bc':'7E9DB9',
		'c':'666666',
		'w':'300',
		'f':'arial',
		'fs':'11',
		'ss':'n',
		'st':'classic',
		'sp':'false',
		'ds':'w',
		'sss':null,
		'colorSwatch':null,
		'colorInput':null,
		'yls':'default',
		'type':null
	},
	getRadios : function(){
		if(YMOB.customGlobals.type == 'design')
		{
			getRadios3 = document.getElementById('srpTheme').getElementsByTagName('input');
	                var srpRadios = [];
        	        srpRadios[0] = document.getElementById('srpThemeClassic');
                	srpRadios[1] = document.getElementById('srpThemeBlack');
                	srpRadios[2] = document.getElementById('srpThemePink');
	                YAHOO.util.Event.addListener(srpRadios, "click", YMOB.setSrpTheme);

		}
		else{
		getRadios = document.getElementById('searchBoxWidth').getElementsByTagName('input');
		//Get radios and assign onclick functions
		var sizeRadios = [];
		for(var y=0;y<getRadios.length;y++){
			if(getRadios[y].type=='radio'){
				sizeRadios[sizeRadios.length] = getRadios[y].id ;
			}
		}
		YAHOO.util.Event.addListener(sizeRadios, "click", YMOB.setSize);

		getRadios2 = document.getElementById('ylogoStyle').getElementsByTagName('input');
		var logoRadios = [];
		for(var z=0;z<getRadios2.length;z++){
			if(getRadios2[z].type=='radio'){
				logoRadios[logoRadios.length] = getRadios2[z];	
			}
		}
		YAHOO.util.Event.addListener(logoRadios, "click", YMOB.setYlogoStyle);
		}

	},
	reportinit: function(){	
		//getdata
		openresty.callback = function(res) 
		{	
			if (!openresty.isSuccess(res))
			{
				alert("请重新操作！！");
				return false;
			}else
			{
				if(res.length==0) 
				{
					alert("您没有定制搜索，没有访问报告！！");
					window.location="index.html";
				}
				var obj=document.getElementById('selectSearch');
				obj.options.length = 0;	
				for(var i=0;i<res.length;i++)
				{
					obj.options[obj.options.length] = new Option(res[i]["title"],res[i]["mob_id"]);
					if(res[i]["mob_id"]==urlargs["mobid"]) 
					{
						obj.options[obj.options.length-1].selected=true;
						var curr=res[i]["title"];
					}
				}	
				if(urlargs["type"]=="source")
				{
					YMOB.reportCurr("source");
				}else if(urlargs["type"]=="query"){
					YMOB.reportCurr("query");
				}else {
					YMOB.reportCurr("search");
				}
         $("exref").href="export.php?mobid="+$("selectSearch").value+"&retype="+$("selectReport").value+"&time="+$("daterange").value+"&type="+$("selectSearchType").value+"&id="+YAHOO.util.Cookie.get("session");
			}
		}
		openresty.get('/=/view/getmob/~/~');

	},
	init : function(){	
		YAHOO.util.Event.addListener("sb_customBoxWidth", "change", YMOB.setSize);
		YAHOO.util.Event.addListener("bgColor", "change", YMOB.changeColor);
		YAHOO.util.Event.addListener("bgColorSample", "click", YMOB.setColor);

		YAHOO.util.Event.addListener("bcColor", "change", YMOB.changeColor);
		YAHOO.util.Event.addListener("bcColorSample", "click", YMOB.setColor);
		//For the Banner form
		YAHOO.util.Event.addListener("bnrBgCo", "change", YMOB.changeColor);
		YAHOO.util.Event.addListener("bnrBgColorSample", "click", YMOB.setColor);

		YAHOO.util.Event.addListener("bnrTxCo", "change", YMOB.changeColor);
		YAHOO.util.Event.addListener("bnrTxColorSample", "click", YMOB.setColor);

		YAHOO.util.Event.addListener("bnrBrCo", "change", YMOB.changeColor);
		YAHOO.util.Event.addListener("bnrBrColorSample", "click", YMOB.setColor);

		YAHOO.util.Event.addListener("mob_sb_showpopular_", "click", YMOB.setshowPopular);

		YAHOO.util.Event.addListener("mob_default_vertical", "change", YMOB.setDefaultSearch);
		YAHOO.util.Event.addListener("mob_sb_ylogo_style", "click", YMOB.setYlogoStyle);
		YAHOO.util.Event.addListener("mob_sb_srp_theme", "click", YMOB.setSrpTheme);

		YAHOO.util.Event.addListener("siteSearch", "click", YMOB.setSiteSearch);
		YAHOO.util.Event.addListener("siteSearchUrl", "blur", YMOB.setSiteSearch);
		YMOB.globals.callback={
			success:YMOB.popCode,
			failure: function(o){ printfire('resCallBack Failure! ');},
			argument: null };

		YAHOO.util.Event.addListener("webQuery", "keydown", YMOB.getKeyPress);
		YAHOO.util.Event.addListener("newsQuery", "keydown", YMOB.getKeyPress);

		YAHOO.util.Event.addListener("webSearch", "click", YMOB.editVerticalsList);
		YAHOO.util.Event.addListener("siteSearch", "click", YMOB.editVerticalsList);
		YAHOO.util.Event.addListener("newsOptions", "click", YMOB.editVerticalsList);

		YAHOO.util.Event.addListener("addLogo", "click", YMOBV.showLogoRequirements);

	},
	SearchOne: function(){		
		openresty.callback =function(res)	{
							if (!openresty.isSuccess(res))
				{
					alert("失败！！请重新操作！！");
					return false;
				 }else
				 {
						//submit data	to tt
						var	html = Jemplate.process(
								 'search_1.tt',
								 { postlist: res[0]}
								);
						YMOB.init();
				 };				
			}	
		openresty.get('/=/view/getmobdetail/mob_id/'+urlargs["mobid"]);
	},
	setSize : function(e){
		//printfire("in setSize");
		var customBox = document.getElementById('sb_customBoxWidth');
		var size;
		//printfire("selected= " + this.value + " and this.id = " + this.id);
		switch(this.id){
			case'prvwSizeNarrow':
				YMOB.globals.widthSel = YMOB.globals.widthNarrow;
			break;
			case'prvwSizeWide':
				YMOB.globals.widthSel = YMOB.globals.widthWide;
			break;
			case'prvwSizeCustom':
				customBox.focus();
				if (customBox.value != '' )
					YMOB.globals.widthSel = customBox.value;
			break;
			case'sb_customBoxWidth':
				//printfire('VALIDATE ME!');
				document.getElementById('prvwSizeCustom').checked=true;
				if(YMOBV.checkRange(customBox.value,[300,600])){
					//printfire("************ PASS ***********");
					YMOB.globals.widthSel = customBox.value;
					customBox.value=YMOB.globals.widthSel;
					customBox.className="";
				} else {
					//printfire("************ FAIL ***********");
					customBox.className="error";
					//printfire('errord out?');
					setTimeout("document.getElementById('sb_customBoxWidth').focus()",100);
				}
			break;
		}
		YMOB.customGlobals.w=YMOB.globals.widthSel;
		YMOB.fetchCode();
		//printfire("out of setSize");
	},

	setSiteSearch : function(){
		//printfire('in setSiteSearch');
		//printfire('YMOB.customGlobals.v=' + YMOB.customGlobals.v);
		//When 'Add Site Search is checked, update code and preview
		var ss = document.getElementById('siteSearch');
		var ssUrl = document.getElementById('siteSearchUrl');
		var ssDefault = document.getElementById('mob_default_vertical');
		var showSiteSearch;
		switch(this.id){
			case'siteSearch':
				//printfire('ss is ' + this.checked);
				switch(this.checked){
					case true:
						showSiteSearch = '1';
						if(ss.checked && ssUrl.value != ''){
							YMOB.customGlobals.v='3';
							showSiteSearch = '1';
						}else {
							YMOB.customGlobals.v='1';
							showSiteSearch = '0';
						}
						//printfire("in ss id true, ssDefault is" + ssDefault.value);
						ssDefault.disabled=false;
						ssDefault.selectedIndex = 1;
						ssUrl.focus();
					break;
					case false:
						if(ss.checked && ssUrl.value != ''){
							YMOB.customGlobals.v='3';
							showSiteSearch = '1';
						}else {
							YMOB.customGlobals.v='1';
							showSiteSearch = '0';
						}
						ssDefault.disabled=true;
					break;
				}
			break;
			case'siteSearchUrl':
				//printfire('ssUrl=' + this.value);
				switch(this.value){
					case'':
						//ss.checked=false;
						ssDefault.disabled=true;
						if(ss.checked && ssUrl.value != ''){
							YMOB.customGlobals.v='3';
							showSiteSearch = '1';
						}else {
							YMOB.customGlobals.v='1';
							showSiteSearch = '0';
						}
					break;
					default:
						ss.checked=true;
						YMOB.customGlobals.sss=ssUrl.value;
						showSiteSearch = '1';
						ssDefault.disabled=false;
						if(ss.checked && ssUrl.value != ''){
							YMOB.customGlobals.v='3';
							showSiteSearch = '1';
						}else {
							YMOB.customGlobals.v='1';
							showSiteSearch = '0';
						}
					break;
				}
			break;
		}
		YMOB.customGlobals.ss=showSiteSearch;
		YMOB.customGlobals.v_site=showSiteSearch;
		YMOB.customGlobals.ds = ssDefault.value;
		if(YMOB.customGlobals.update!='no'){
			YMOB.fetchCode();
		}
		YMOB.editVerticalsList();
		//printfire('YMOB.customGlobals.v=' + YMOB.customGlobals.v + "because ssUrl = " + ssUrl);
		//printfire('out of setSiteSearch');
	},
	popCode : function(){
		//printfire("popCode with the YMOB.customGlobals.type= " + YMOB.customGlobals.type + " and sp= " + YMOB.customGlobals.sp + " and spc= " + YMOB.customGlobals.spc);
		if(YMOB.customGlobals.type=="searchbox" || YMOB.customGlobals.type=="basicsearchbox"){
		var tosBasic = document.getElementById('basCheck') ? document.getElementById('basCheck').checked : true;
		if (tosBasic) {
			document.getElementById('searchBoxCode').value = arguments[0].responseText;
		}
		else {
			document.getElementById('searchBoxCode').value = "\n\nTo view the code you must read and accept the Terms of Use above."
		}
			document.getElementById('previewCode').innerHTML = arguments[0].responseText.replace(/"GB2312"|"GBK"/i,'"UTF-8"');
			if(document.getElementById('pcbottom')){document.getElementById('pcbottom').style.position="relative";}
		} else if(YMOB.customGlobals.type=="design" ){
			document.getElementById('bannerCode').innerHTML = arguments[0].responseText;			
			YMOBV.checkLogoSize();
		}
	},
	countInputs : function(){
		var inputs = document.getElementsByTagName('input');
		YAHOO.util.Event.addListener(inputs,"change",YMOB.updateBannerParams);
	},
	updateBannerParams : function(){
		YMOB.globals.updated='no';
		//printfire("in updateBannerParams");
		YMOBV.checkLogoSize;
		//printfire('checkLogoSize test should be run');
		if(document.getElementById('bannerText')){			
			YMOB.customGlobals.bt = document.getElementById('bannerText').value;2008-11-24
			YMOB.customGlobals.tc = document.getElementById('bnrTxCo').value;
			YMOB.customGlobals.bbc = document.getElementById('bnrBgCo').value;
			YMOB.customGlobals.brd = document.getElementById('bnrBrCo').value;
			YMOB.customGlobals.ul = document.getElementById('addLogo').checked;
			YMOB.customGlobals.lurl = document.getElementById('logoUrl').value;
			YMOB.customGlobals.lh=document.getElementById('mob_logo_height').value;
			YMOB.customGlobals.lw=document.getElementById('mob_logo_width').value;
			YMOB.customGlobals.surl = document.getElementById('siteUrl').value;
			YMOB.customGlobals.at = document.getElementById('logoAlt').value;
		//printfire("logoalt = " + YMOB.customGlobals.at);
		}
		if(document.getElementById('logoUrl').value!=''){
			YMOB.makeTempLogo();
			YMOB.fetchResult();
		}else{
			YMOB.fetchResult();
		}
		//printfire("out of updateBannerParams");
	},
	makeTempLogo : function(){
		//printfire('in makeTempLogo' );

		logo = document.createElement('img');
		logo.src = document.getElementById('logoUrl').value;
		logo.id = "tempLogo";
		logo.style.position="absolute";
		logo.style.top="-99994px";
		logo.style.left="-99994px";
		document.body.appendChild(logo);
		YAHOO.util.Event.addListener("tempLogo", "load", YMOB.setLogoSizes);

		//printfire('out of makeTempLogo' );
	},
	setLogoSizes : function(){
		//printfire('in setLogoSizes' );
		if(document.getElementById('mob_logo_width').value==''){
			document.getElementById('mob_logo_width').value = document.getElementById('tempLogo').width;
		}
		if(document.getElementById('mob_logo_height').value==''){
			document.getElementById('mob_logo_height').value = document.getElementById('tempLogo').height;
		}
		YMOB.customGlobals.lurl = document.getElementById('logoUrl').value;
		YMOB.customGlobals.lh=document.getElementById('mob_logo_height').value;
		YMOB.customGlobals.lw=document.getElementById('mob_logo_width').value;
		YMOB.customGlobals.surl = document.getElementById('siteUrl').value;
		YMOB.customGlobals.at = document.getElementById('logoAlt').value;
		YMOB.fetchCode();
		//printfire('out of setLogoSizes' );
	},
	resetLogoSizes : function(){
		if(document.getElementById('tempLogo')){document.getElementById('mob_logo_width').value = document.getElementById('tempLogo').width};
		if(document.getElementById('tempLogo')){document.getElementById('mob_logo_height').value = document.getElementById('tempLogo').height};
		YMOB.customGlobals.lh=document.getElementById('mob_logo_height').value;
		YMOB.customGlobals.lw=document.getElementById('mob_logo_width').value;
		YMOBV.checkLogoSize();
		YMOB.fetchCode();
	},
	fetchCode : function(t){
		if(YMOB.customGlobals["type"]=="design") YMOB.fetchResult();else YMOB.fetchSearch();

	},
	getSimpleCode : function(t){
		var str="";
		str=str+'<div id="yahoodiy_searchbox"><br></div>\n';
		str=str+'<script type="text/javascript">\n<!--\n';
		str=str+'var params={"v_web"  :"'+YMOB.customGlobals["v_web"]+'","v_site" :"'+YMOB.customGlobals["v_site"]+'","m"   :"'+YMOB.customGlobals["m"]+'","bg"  :"'+YMOB.customGlobals["bg"]+'","bc"  : "'+YMOB.customGlobals["bc"]+'","w"   : "'+YMOB.customGlobals["w"]+'","yls" : "'+YMOB.customGlobals["yls"]+'"};\n// -->\n</script>\n';
		str=str+'<script type="text/javascript"  src="js/makecode.js"></script>';
		document.getElementById('simpleBoxCode').innerText = str;
	},
	fetchSearch : function(t){	
		var url="";
		var part="";
		switch(YMOB.customGlobals["yls"])
		{
			case 'default':
				part='powered by <span style="color: #ff0033;font-weight: bold;">YAHOO!</span> <span style="font-weight: bold;color: #545454">SEARCH</span>\n';	
			break;
			case 'bg':
				url="images/horiz_pwrlogo_red2.gif";
			break;
			case 'white':
				part='<span style="color: #FFFFFF">powered by <B>YAHOO! SEARCH</B></span>\n';
			break;
			default:
			break
		}
		var str='<div id="ysrchForm" style=" border:1px solid #'+YMOB.customGlobals["bc"]+';background:#'+YMOB.customGlobals["bg"]+';width:'+YMOB.customGlobals["w"]+'px;margin:0 auto;padding:20px;position:relative;">\n';
		str=str+'<form id="searchBoxForm_'+YMOB.customGlobals["m"]+'" action="http://diy.cn.yahoo.com/a/bouncer" style="padding:0;" >\n';
		str=str+'<input name="mobid" value="'+YMOB.customGlobals["m"]+'" type="hidden">\n';
		str=str+'<input name="ei" value="UTF8" type="hidden">\n';
		str=str+'<input name="fr" value="ystg-c" type="hidden"><div style="padding:0 80px 0 0;zoom:1;">\n';
		str=str+'<input type="text" id="searchTerm"onFocus="this.style.background=\'#fff\';"onBlur="if(this.value==\'\')this.style.background=\'#fff url('+url+') 3px center  no-repeat\'"	name="p" style=" margin:1px 0; width:100%; border:1px solid #'+YMOB.customGlobals["bc"]+'; color:#666666; height:18px; padding:0px 3px; background:#fff url('+url+') 3px center no-repeat; position:relative;">\n';
		str=str+'<input type="submit" id="btn_'+YMOB.customGlobals["m"]+'" value="雅虎搜索" style=" padding-bottom:2px; position:absolute; right:20px; top:20px; margin:0px; height:22px; width:70px; "></div>\n';
		if(YMOB.customGlobals["v_web"]==1&&YMOB.customGlobals["v_site"]==1)
		{
			str=str+'<ul style="color:#666666;font:11px/11px normal Arial, Helvetica, sans-serif;margin:0;padding:0; text-align:left;list-style-type:none;radios"><li style="display:inline;padding-right:10px;"><input name="mobvs" id="web_'+YMOB.customGlobals["m"]+'" value="0"    type="radio" style="vertical-align:middle;margin-right:5px; "><label for="web_'+YMOB.customGlobals["m"]+'" style="vertical-align:middle;;font-size:12px">网页</label></li><li style="display:inline;padding-right:10px;"><input name="mobvs" id="site_'+YMOB.customGlobals["m"]+'" value="1"   checked="checked" type="radio" style="vertical-align:middle;margin-right:5px; "><label for="'+YMOB.customGlobals["m"]+'" style="vertical-align:middle;font-size:12px">站内</label></li></ul>';
		}
		str=str+'</form><div style="font-family: verdana;font-size: 9px;color:#000;position:absolute;right:10px;bottom:5px">\n';
		str=str+part+'</div></div>\n';
		document.getElementById('previewCode').innerHTML = str;
	},
	getsearchBoxCode : function(t){	
		var url="";
		var part="";
		switch(YMOB.customGlobals["yls"])
		{
			case 'default':
				part='powered by <span style="color: #ff0033;font-weight: bold;">YAHOO!</span> <span style="font-weight: bold;color: #545454">SEARCH</span>\n';	
			break;
			case 'bg':
				url="images/horiz_pwrlogo_red2.gif";
			break;
			case 'white':
				part='<span style="color: #FFFFFF">powered by <B>YAHOO! SEARCH</B></span>\n';
			break;
			default:
			break
		}
		var str='<div id="ysrchForm" style=" border:1px solid #'+YMOB.customGlobals["bc"]+';background:#'+YMOB.customGlobals["bg"]+';width:'+YMOB.customGlobals["w"]+'px;margin:0 auto;padding:20px;position:relative;">\n';
		str=str+'<form id="searchBoxForm_'+YMOB.customGlobals["m"]+'" action="http://diy.cn.yahoo.com/a/bouncer" style="padding:0;" >\n';
		str=str+'<input name="mobid" value="'+YMOB.customGlobals["m"]+'" type="hidden">\n';
		str=str+'<input name="ei" value="UTF8" type="hidden">\n';
		str=str+'<input name="fr" value="ystg-c" type="hidden"><div style="padding:0 80px 0 0;zoom:1;">\n';
		str=str+'<input type="text" id="searchTerm"onFocus="this.style.background=\'#fff\';"onBlur="if(this.value==\'\')this.style.background=\'#fff url('+url+') 3px center  no-repeat\'"	name="p" style=" margin:1px 0; width:100%; border:1px solid '+YMOB.customGlobals["bc"]+'; color:#666666; height:18px; padding:0px 3px; background:#fff url('+url+') 3px center no-repeat; position:relative;">\n';
		str=str+'<input type="submit" id="btn_'+YMOB.customGlobals["m"]+'" value="雅虎搜索" style=" padding-bottom:2px; position:absolute; right:20px; top:20px; margin:0px; height:22px; width:70px; "></div>\n';
		if(YMOB.customGlobals["v_web"]==1&&YMOB.customGlobals["v_site"]==1)
		{
			str=str+'<ul style="color:#666666;font:11px/11px normal Arial, Helvetica, sans-serif;margin:0;padding:0; text-align:left;list-style-type:none;radios"><li style="display:inline;padding-right:10px;"><input name="mobvs" id="web_'+YMOB.customGlobals["m"]+'" value="0"    type="radio" style="vertical-align:middle;margin-right:5px; "><label for="web_'+YMOB.customGlobals["m"]+'" style="vertical-align:middle;;font-size:12px">网页</label></li><li style="display:inline;padding-right:10px;"><input name="mobvs" id="site_'+YMOB.customGlobals["m"]+'" value="1"   checked="checked" type="radio" style="vertical-align:middle;margin-right:5px; "><label for="'+YMOB.customGlobals["m"]+'" style="vertical-align:middle;font-size:12px">站内</label></li></ul>\n';
		}
		str=str+'</form><div style="font-family: verdana;font-size: 9px;color:#000;position:absolute;right:10px;bottom:5px">\n';
		str=str+part+'</div></div>\n';
		document.getElementById('searchBoxCode').innerText = str;
	},	

	fetchResult : function(t){
		str='<html>';
		str=str+'<head>';
		str=str+'<meta http-equiv="content-type" content="text/html; charset=UTF-8">';
		str=str+'<style>';
		str=str+'td {font-size:13px!important;}';
		str=str+'td a {color:#0000DE!important;text-decoration:underline!important;}';
		str=str+'a.sample-title {font-size:16px;padding-bottom:.2em;display:block;;text-decoration:underline;color:#0000DE;}';
		str=str+'#pg,#pg a {font-size:14px;}';
		str=str+'</style>';
		str=str+'</head>';
		str=str+'<body>';
		var fontSizeNum = '100%';
		switch(YMOB.customGlobals["fs"])
		{
			case 'small':
				fontSizeNum = '100%';
				break;
			case 'large':
				fontSizeNum = '136%';
				break;
			case 'medium':
				fontSizeNum = '122%';
				break;
			default:
				break;
			}

		var part="";
		switch(YMOB.customGlobals["st"])
		{
				case 'black':
					srpBgColor = '000000';
					part=part+'<div id="n" style="border-bottom:1px solid #000000;background:#34282C;">&nbsp;&nbsp;<strong><font color=white>全网搜索</font></strong></div><br>';
					part=part+'<div style="display:block;margin-bottom:6em;margin-left:2em;">';
					part=part+'<a href="#" target="_blank" class="sample-title">雅虎<font color=red>搜索DIY</font> - 免费自定义属于自己的搜索引擎</a>';
					part=part+'<table cellspacing="0" style="color:#6D7B8D">';
					part=part+'<tr><td>雅虎<font color=red>搜索DIY</font>首页 | 帮助 为您的站点定制<font color=red>搜索</font>引擎 在您的网站快捷的增加搜索功能 分析用户<font color=red>搜索</font>数据,使您更好的了解用户在您网站的<font color=red>搜索</font>热点 提高用户体验,增强用户粘合度。';
					part=part+'<div><font color=green>diy.cn.yahoo.com/m/promo  - 11k  - 2007年5月1日  - </font><a href="#" target="_blank">快照</a></div></td></tr></table><br>';
					part=part+'<a href="#" target="_blank" class="sample-title">雅虎<font color=red>搜索DIY</font> - 免费自定义属于自己的搜索引擎</a><table cellspacing="0" style="color:#6D7B8D">';
					part=part+'<tr><td>雅虎<font color=red>搜索DIY</font>首页 | 帮助 为您的站点定制<font color=red>搜索</font>引擎 在您的网站快捷的增加搜索功能 分析用户<font color=red>搜索</font>数据,使您更好的了解用户在您网站的<font color=red>搜索</font>热点 提高用户体验,增强用户粘合度。';
					part=part+'<div><font color=green>diy.cn.yahoo.com/m/promo  - 11k  - 2007年5月1日  - </font><a href="#" target="_blank">快照</a></div></td></tr></table></div>';
					part=part+'<div id="pg" style="color:white;text-align:center;font-family:arial;_font-family /* */:inherit;margin-bottom:1.2em;">&nbsp;<strong>1</strong>&nbsp;<a href="#">[2]</a>&nbsp;<a href="#" class="pl"><em>下一页 >></em></a></div>';
				break;
			case 'classic':
					srpBgColor = 'ffffff';
					part=part+'<div id="n" style="border-bottom:1px solid #b6cde0;background:#e6f2ff;">&nbsp;&nbsp;<strong>全网搜索</strong></div><br>';
					part=part+'<div style="display:block;margin-bottom:4em;margin-left:2em;">';
					part=part+'<a href="#" target="_blank" class="sample-title">雅虎<font color=red>搜索DIY</font> - 免费自定义属于自己的搜索引擎</a>';
					part=part+'<table cellspacing="0"><tr><td>雅虎<font color=red>搜索DIY</font>首页 | 帮助 为您的站点定制<font color=red>搜索</font>引擎 在您的网站快捷的增加搜索功能 分析用户<font color=red>搜索</font>数据,使您更好的了解用户在您网站的<font color=red>搜索</font>热点 提高用户体验,增强用户粘合度。';
					part=part+'<div><font color=green>diy.cn.yahoo.com/m/promo  - 11k  - 2007年5月1日  - </font><a href="#" target="_blank">快照</a></div></td></tr></table>';
					part=part+'<br><a href="#" target="_blank" class="sample-title">雅虎<font color=red>搜索DIY</font> - 免费自定义属于自己的搜索引擎</a>';
					part=part+'<table cellspacing="0"><tr><td>雅虎<font color=red>搜索DIY</font>首页 | 帮助 为您的站点定制<font color=red>搜索</font>引擎 在您的网站快捷的增加搜索功能 分析用户<font color=red>搜索</font>数据,使您更好的了解用户在您网站的<font color=red>搜索</font>热点 提高用户体验,增强用户粘合度。';
					part=part+'<div><font color=green>diy.cn.yahoo.com/m/promo  - 11k  - 2007年5月1日  - </font><a href="#" target="_blank">快照</a></div></td></tr></table>';
					part=part+'</div><div id="pg" style="color:black;text-align:center;font-family:arial;_font-family /* */:inherit;margin-bottom:1.2em;">&nbsp;<strong>1</strong>&nbsp;<a href="#">[2]</a>&nbsp;<a href="#" class="pl"><em>下一页 >></em></a></div>';
				break;
			case 'pink':
					srpBgColor = 'FFCCFF';
					part=part+'<div id="n" style="border-bottom:1px solid #FF0000;background:#FF99FF;">&nbsp;&nbsp;<strong>全网搜索</strong></div><br>';
					part=part+'<div style="display:block;margin-bottom:6em;margin-left:2em;">';
					part=part+'<a href="#" target="_blank" class="sample-title">雅虎<font color=red>搜索DIY</font> - 免费自定义属于自己的搜索引擎</a>';
					part=part+'<table cellspacing="0" style="color:#6D7B8D"><tr><td>雅虎<font color=red>搜索DIY</font>首页 | 帮助 为您的站点定制<font color=red>搜索</font>引擎 在您的网站快捷的增加搜索功能 分析用户<font color=red>搜索</font>数据,使您更好的了解用户在您网站的<font color=red>搜索</font>热点 提高用户体验,增强用户粘合度。<div><font color=green>diy.cn.yahoo.com/m/promo  - 11k  - 2007年5月1日  - </font><a href="#" target="_blank">快照</a></div></td></tr></table><br>';
					part=part+'<a href="#" target="_blank" class="sample-title">雅虎<font color=red>搜索DIY</font> - 免费自定义属于自己的搜索引擎</a>';
					part=part+'<table cellspacing="0" style="color:#6D7B8D"><tr><td>雅虎<font color=red>搜索DIY</font>首页 | 帮助 为您的站点定制<font color=red>搜索</font>引擎 在您的网站快捷的增加搜索功能 分析用户<font color=red>搜索</font>数据,使您更好的了解用户在您网站的<font color=red>搜索</font>热点 提高用户体验,增强用户粘合度。';
					part=part+'<div><font color=green>diy.cn.yahoo.com/m/promo  - 11k  - 2007年5月1日  - </font><a href="#" target="_blank">快照</a></div></td></tr></table>';
					part=part+'</div><div id="pg" style="color:black;text-align:center;font-family:arial;_font-family /* */:inherit;margin-bottom:1.2em;">&nbsp;<strong>1</strong>&nbsp;<a href="#">[2]</a>&nbsp;<a href="#" class="pl"><em>下一页 >></em></a></div>';
				break;
			default:
			break;
		}		
		str=str+'<div id="srpBgColor" style="background: #'+srpBgColor+';padding: 10px 15px;margin-bottom: 6px;">';
		str=str+'<div id="ymobPrtnrHdr" style="background: #'+YMOB.customGlobals["bbc"]+';border:1px solid #'+YMOB.customGlobals["brd"]+';color: #'+YMOB.customGlobals["tc"]+';font-size: '+fontSizeNum+';font-family: '+YMOB.customGlobals["f"]+';font-weight:bold;padding: 10px 15px;margin-bottom: 6px;"> ';
		if(YMOB.customGlobals["ul"])
		{
			str=str+'<div style="display: inline;">';
			str=str+'<a href="'+YMOB.customGlobals["surl"]+'">';
			str=str+'<img src="'+YMOB.customGlobals["lurl"]+'" alt="'+YMOB.customGlobals["at"]+'" title="'+YMOB.customGlobals["at"]+'" height="'+YMOB.customGlobals["lh"]+'" width="'+YMOB.customGlobals["lw"]+'" style="vertical-align:middle;" id="ymobPrtnrHdrLogo"></a>';
			str=str+'</div>';
		}
		str=str+YMOB.customGlobals["bt"];
		str=str+'<input type="text" width=20px value="搜索DIY">';
		str=str+'<button name="搜索">搜索</button>';
		str=str+'</div>';
		str=str+part;
		str=str+'</div></body></html>';
		document.getElementById('bannerCode').innerHTML = str;

	},		
	GetUrlParms : function(){
		var query=location.search.substring(1);
		var pairs=query.split("&");
		for(var i=0;i<pairs.length;i++)   
		{
			var pos=pairs[i].indexOf('=');
			if(pos==-1)   continue;
			var argname=pairs[i].substring(0,pos);
			var value=pairs[i].substring(pos+1);
			urlargs[argname]=unescape(value);
		}
		return urlargs;
	},
	changeColor : function(){
		var checkThis = document.getElementById(this.id);
		var checkThisVal = document.getElementById(this.id).value.toUpperCase();
		checkThis.value=checkThisVal.toUpperCase();
		if(YMOBV.checkHex(checkThisVal)){
			checkThis.className="";
			tSwatch = checkThis.id.substr(0,3)==='bnr'?checkThis.id+"lorSample":checkThis.id+"Sample";
			if(document.getElementById('bgColor')){YMOB.customGlobals.bg = document.getElementById('bgColor').value;}
			if(document.getElementById('bcColor')){YMOB.customGlobals.bc = document.getElementById('bcColor').value;}
			if(document.getElementById('ppColor')){YMOB.customGlobals.spc = document.getElementById('ppColor').value;}

			//update the swatch
			if(document.getElementById(tSwatch)){document.getElementById(tSwatch).style.background = "#" + this.value;}
	
			YMOB.fetchCode();
		} else {
			checkThis.className="error";
			return false;
		}
	},
	setColor : function(c){
		//printfire("pick color for: " + this.id);
		YMOB.customGlobals.colorSwatch = this.id;
		YMOB.customGlobals.colorInput = this.id.substr(0,7);
		//printfire(YMOB.customGlobals.colorSwatch + " target input =" + this.id.substr(0,7));
		YMOB.pickColor();
	},
	pickColor : function(){
		var d = document.getElementById('colorPicker');
		var who = YMOB.customGlobals.colorSwatch;
		var whereX = YAHOO.util.Dom.getX(who) + 30;
		var whereY = YAHOO.util.Dom.getY(who);
		YAHOO.util.Dom.setXY(d, [whereX,whereY]);
	},
	chooseThisColor : function(c){
		//printfire("choosing the color! " + c + " I choose you!");
		var d = document.getElementById('colorPicker');

		var swatch = document.getElementById(YMOB.customGlobals.colorSwatch);
		var input = document.getElementById(YMOB.customGlobals.colorInput);
		//printfire("input target= " + YMOB.customGlobals.colorInput);

		switch(YMOB.customGlobals.colorInput){
			case'bgColor':
				YMOB.customGlobals.bg = c;
			break;
			case'bcColor':
				YMOB.customGlobals.bc = c;
			break;
			case'ppColor':
				YMOB.customGlobals.spc = c;
				//printfire('got here, spc now =' + YMOB.customGlobals.spc);
			break;
		}
		swatch.style.background="#" + c;
		input.value= c;
		YAHOO.util.Dom.setXY(d, [-1000,-1000]);
		if(YMOB.customGlobals.type=="design"){YMOB.updateBannerParams();};
		YMOB.fetchCode();
		
	},
	setDefaultSearch : function(obj){
		//printfire("Setting default search to " + this.value);
		YMOB.customGlobals.ds = this.value;
		YMOB.fetchCode();
	},
	setYlogoStyle: function(obj){
		//printfire("Setting default search to " + this.value);
		YMOB.customGlobals.yls = this.value;
		YMOB.fetchCode();
	},
	setSrpTheme: function(obj){
                //printfire("Setting default search to " + this.value);
                YMOB.customGlobals.st= this.value;
		YMOB.updateBannerParams();
        },

	setshowPopular : function(obj){
		//printfire("Setting Popular Search display to " + this.checked +"(this.id=" + this.id +")");
		var showPopCheckBox = document.getElementById('mob_sb_showpopular_');
		var showHot= document.getElementById('mob_popular_blocked');
		var popColor= document.getElementById('mob_sb_pop_color');
		YMOB.customGlobals.sp = showPopCheckBox.checked?1:2;
		//printfire("Set sp to " + YMOB.customGlobals.sp);
		YMOB.fetchCode();
	},
	setBannerFont : function(){
		//printfire('in setBannerFont');
		YMOB.customGlobals.fs = document.getElementById('fontSize').value;
		YMOB.customGlobals.f = document.getElementById('font').value;
		YMOB.updateBannerParams();
		//printfire('changed font to size:' + YMOB.customGlobals.fs +' and face: ' + YMOB.customGlobals.f);
		//printfire('out of setBannerFont');
	},
	reportGO : function(e){
		//printfire('in reportGO');
		if(this.value=="source"||this.value=="query"||this.value=="search")
		{
			var obj=document.getElementById('daterange');
			obj.options.length = 0;	
			obj.options[obj.options.length] = new Option('本周','this_week');
			obj.options[obj.options.length] = new Option('最近7天','7days');
			obj.options[obj.options.length] = new Option('本月','this_month');
			obj.options[obj.options.length] = new Option('最近30天','30days');
			if(this.value=="search")	obj.options[obj.options.length] = new Option('最近12个月','12months');
		}
     $("exref").href="export.php?mobid="+$("selectSearch").value+"&retype="+$("selectReport").value+"&time="+$("daterange").value+"&type="+$("selectSearchType").value+"&id="+YAHOO.util.Cookie.get("session");
		//get data
		openresty.callback = function(res) 
		{	
			if (!openresty.isSuccess(res))
			{
				alert("请重新操作！！");
				return false;
			 }else
			 {
				document.getElementById('title').innerHTML="<strong>"+document.getElementById('selectSearch').options[document.getElementById('selectSearch').selectedIndex].text+"</strong>&nbsp;&nbsp;&nbsp;&nbsp;<b>报表类型:</b>"+document.getElementById('selectReport').options[document.getElementById('selectReport').selectedIndex].text+"&nbsp;&nbsp;&nbsp;&nbsp;<b>时间:</b>"+document.getElementById('daterange').options[document.getElementById('daterange').selectedIndex].text+"&nbsp;&nbsp;&nbsp;&nbsp;<b>搜索类型:</b>"+document.getElementById('selectSearchType').options[document.getElementById('selectSearchType').selectedIndex].text+"&nbsp;&nbsp;&nbsp;&nbsp;";
				if(document.getElementById('selectReport').value=="search"&&document.getElementById('daterange').value!="12months")
				{
					document.getElementById("retable").innerHTML="";
          if(res.length==0){alert("没有数据！");return;}
					YMOB.showPic(res);	
				}else
				{
					document.getElementById('chart').innerHTML="";
          if(res.length==0){alert("没有数据！");return;}
					YMOB.showTab(res,document.getElementById('selectReport').value);	
				}
				
			}
		};
		if(document.getElementById('selectReport').value=="search")
		{
			openresty.get('/=/view/search_report/mobid/'+$("selectSearch").value,{
			htag:document.getElementById('selectSearchType').value,
			ttag:document.getElementById('daterange').value,
			limit:50 
			});
		}else if(document.getElementById('selectReport').value=="source")
		{
			openresty.get('/=/view/dfk_report/mobid/'+$("selectSearch").value,{
			htag:document.getElementById('selectSearchType').value,
			ttag:document.getElementById('daterange').value,
			key:"referrer",
			limit:50 
			});
		}else
    {
			openresty.get('/=/view/dfk_report/mobid/'+$("selectSearch").value,{
			htag:document.getElementById('selectSearchType').value,
			ttag:document.getElementById('daterange').value,
			key:"query",
			limit:50 
			});
    }
	},
	reportCurr : function(type){
		//printfire('in reportGO');
		if(type=="source"||type=="query"||type=="search")
		{
			var obj=document.getElementById('daterange');
			obj.options.length = 0;	
			obj.options[obj.options.length] = new Option('本周','this_week');
			obj.options[obj.options.length] = new Option('最近7天','7days');
			obj.options[obj.options.length] = new Option('本月','this_month');
			obj.options[obj.options.length] = new Option('最近30天','30days');
			if(type=="search")	obj.options[obj.options.length] = new Option('最近12个月','12months');
		}
		//get data
		openresty.callback = function(res) 
		{	
			if (!openresty.isSuccess(res))
			{
				alert("请重新操作！！");
				return false;
			 }else
			 {
				document.getElementById('title').innerHTML="<strong>"+document.getElementById('selectSearch').options[document.getElementById('selectSearch').selectedIndex].text+"</strong>&nbsp;&nbsp;&nbsp;&nbsp;<b>报表类型:</b>"+document.getElementById('selectReport').options[document.getElementById('selectReport').selectedIndex].text+"&nbsp;&nbsp;&nbsp;&nbsp;<b>时间:</b>"+document.getElementById('daterange').options[document.getElementById('daterange').selectedIndex].text+"&nbsp;&nbsp;&nbsp;&nbsp;<b>搜索类型:</b>"+document.getElementById('selectSearchType').options[document.getElementById('selectSearchType').selectedIndex].text+"&nbsp;&nbsp;&nbsp;&nbsp;";
				if(document.getElementById('selectReport').value=="search"&&document.getElementById('daterange').value!="12months")
				{
					document.getElementById("retable").innerHTML="";
          if(res.length==0){alert("没有数据");return;}
					YMOB.showPic(res);	
				}else
				{
					document.getElementById('chart').innerHTML="";
          if(res.length==0){alert("没有数据");return;}
					YMOB.showTab(res,type);	
				}
				
			}
		};
		if(type=="search")
		{
			document.getElementById('selectReport').options[0].selected=true;
			openresty.get('/=/view/search_report/mobid/'+$("selectSearch").value,{
			htag:document.getElementById('selectSearchType').value,
			ttag:document.getElementById('daterange').value,
			limit:50 
			});
		}else if(type=="source")
		{
			document.getElementById('selectReport').options[2].selected=true;
			openresty.get('/=/view/dfk_report/mobid/'+$("selectSearch").value,{
			htag:document.getElementById('selectSearchType').value,
			ttag:document.getElementById('daterange').value,
			key:"referrer",
			limit:50 
			});
		}else {
			document.getElementById('selectReport').options[1].selected=true;
			openresty.get('/=/view/dfk_report/mobid/'+$("selectSearch").value,{
			htag:document.getElementById('selectSearchType').value,
			ttag:document.getElementById('daterange').value,
			key:"query",
			limit:50 
			});
		}
	},
	showTab: function(data,type){
		var str='<table border="0" cellspacing="1" cellpadding="0" class="reportData">';
		if(type=="search")
		{
			str=str+'<tr class="mc2tr1"><td>日期</td><td>搜索次数</td><td>搜索人数</td><td>平均搜索人次</td></tr>';
		}else if(type=="source")
		{
			str=str+'<tr class="mc2tr1"><td>来源</td><td>搜索次数</td></tr>';
		}else {
			str=str+'<tr class="mc2tr1"><td>搜索词</td><td>搜索次数</td></tr>';

		}
		for(var i=0;i<data.length;i++)
		{
			if(type=="search")
			{
				str=str+'<tr class="mc2tr2"><td>'+data[i]["count"]+'</td><td>'+data[i]["average"]+'</td><td>'+data[i]["num"]+'</td><td>'+data[i]["average"]+'</td></tr>';
			}else if(type=="source")
			{
        if(data[i]["key"]!=null)
        {
				   str=str+'<tr class="mc2tr2"><td><a href="'+data[i]["key"]+'" target="_blank">'+data[i]["key"].substring(0,80)+'....</a></td><td>'+data[i]["num"]+'</td></tr>';
        }
			}else
			{
        if(data[i]["key"]!=null)
        {
				  str=str+'<tr class="mc2tr2"><td><a href="'+data[i]["key"]+'" target="_blank">'+data[i]["key"]+'</td><td>'+data[i]["num"]+'</td></tr>';
        }
			}
		}
		//str=str+'<tr class="mc2tr2"><td colspan=4 align="right"><a href="http://diy.cn.yahoo.com/r/referrals?ei=UTF-8&mobid=U0SOrUX8vR4IoAALpwZpc&export=1"><font size="4 pt">导出报表查看所有数据</font></a></td><tr>';
		str=str+'</table>';
		document.getElementById("retable").innerHTML=str;
	},
	showPic: function(data){

		YAHOO.widget.Chart.SWFURL = "http://yui.yahooapis.com/2.6.0/build//charts/assets/charts.swf";	
    if(data.length==0) return;
		//--- data	
		var str='{ count: '+data[0]["count"]+', average: '+data[0]["average"]+', num: '+data[0]["num"]+', date: '+data[0]["date"]+' }';
		for(var i=1;i<data.length;i++)
		{
		 str=str+',{ count: '+data[i]["count"]+', average: '+data[i]["average"]+', num: '+data[i]["num"]+', date: "'+data[i]["date"]+'" }';
		}
		eval("YAHOO.example.monthlyExpenses =["+str+"]");
	
		var myDataSource = new YAHOO.util.DataSource( YAHOO.example.monthlyExpenses );
		myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
		myDataSource.responseSchema =
		{
			fields: ["count","average","num","date", ]
		};
	//--- chart
		var seriesDef = 
		[
			{ displayName: "count", yField: "count" },
			{ displayName: "average", yField: "average" },
			{ displayName: "num", yField: "num" }
		];

		YAHOO.example.formatCurrencyAxisLabel = function( value )
		{
			return YAHOO.util.Number.format( value,
			{
				prefix: "",
				thousandsSeparator: ",",
				decimalPlaces: 4
			});
		}
		
		var count_sh="搜索次数";
		var average_sh="平均搜索人次";
		var num_sh="搜索人数";

		YAHOO.example.getDataTipText = function( item, index, series )
		{

			var toolTipText = eval(series.displayName+"_sh") + " for " + item.date;
			toolTipText += "\n" + YAHOO.example.formatCurrencyAxisLabel( item[series.yField] );
			return toolTipText;
		}

		var currencyAxis = new YAHOO.widget.NumericAxis();
		currencyAxis.minimum = 0;
		currencyAxis.labelFunction = YAHOO.example.formatCurrencyAxisLabel;

		var mychart = new YAHOO.widget.LineChart( "chart", myDataSource,
		{
			series: seriesDef,
			xField: "date",
			yAxis: currencyAxis,
			dataTipFunction: YAHOO.example.getDataTipText,
			//only needed for flash player express install
			expressInstall: "assets/expressinstall.swf"
		});

	},
	
	getKeyPress : function(e){
		var kCode = e.keyCode;
		switch(kCode){
			case 13: //enter key
				switch(this.id){
					case'webQuery':
						YAHOO.util.Event.preventDefault(e);
						previewForm('webSearchPreviewButton');
					break;
					case'newsQuery':
						YAHOO.util.Event.preventDefault(e);
						previewForm('newsSearchPreviewButton');
					break;
				}
			break;
		}
	},
	editVerticalsList : function(){
		//printfire('in editVerticalsList, type = '+ YMOB.customGlobals.type);
		var theChecks = YAHOO.util.Dom.getElementsByClassName('selectVertical');
		var theOptions = document.getElementById('mob_default_vertical').getElementsByTagName('option');
		for(y=0;y<theOptions.length;y++){
			for(c=0;c<theChecks.length;c++){
				if((theOptions[y].value == theChecks[c].value)){
					if(theChecks[c].checked==true){
						theOptions[y].style.display='block';
						theOptions[y].selected=true;
					} else {
						theOptions[y].style.display='none';
						theOptions[y].selected=false;
				}
				}
			}
		}
		var numChecks = 0;
		for(y=0;y<theChecks.length;y++){
			if(theChecks[y].checked==true){
				numChecks++;
			}
		}
		if(numChecks<2 && YMOB.customGlobals.type!='basicsearchbox'){
			document.getElementById('mob_default_vertical').disabled=true;
		} else if(YMOB.customGlobals.type!='basicsearchbox') {
			document.getElementById('mob_default_vertical').disabled=false;
		} else {
			if(YMOB.customGlobals.type=='basicsearchbox'){
				document.getElementById('mob_default_vertical').disabled=false;
			}
			//printfire('******* hit basicsearchbox ********* - Dropdown enabled');
		}
		//printfire('numChecks = ' + numChecks);
		//printfire('out of editVerticalsList');
	}
};




yMobVal.prototype = {
	checkRange : function(o,r){
		//printfire('checking width: 0bj= ' + o + ' and range = ' + r);
		if( isNaN(o)){
		YMOB.globals.err += "您输入的内容不是数字";
			//printfire(YMOB.globals.err);
			return false;
		}
		if (o<r[0]){
			YMOB.globals.err += "您输入的数值太小";
			//printfire(YMOB.globals.err);
			return false;
		}
		if (o>r[1]){
			YMOB.globals.err += "您输入的数值太大";
			//printfire(YMOB.globals.err);
			return false;
		}
		return true;
		return false;
	},
	checkHex : function(o){
		//printfire('in checkHex - testing ' + o);
		if (!/^[A-F\d]{6}$/.test(o)) {
			return false;
		} else {
			return true;
		}
	},
	checkNull : function(v){
		//printfire("v= " + v + " it will be: " + (v >''));
		return (v > "")? true : false;
	},
	checkInvalid : function(v) {
		var invalids = Array('<', '>');
		for (var i = 0; i < invalids.length; i++) {
			if (v.lastIndexOf(invalids[i]) > -1) return false;
		}	
		return true;
	},
	checkMobTitle : function(){
		//printfire("Checking mob_title");
		var obj = document.getElementById('mob_title');
		if(!YMOBV.checkNull(obj.value)){
			obj.className="error";
			return false;
		} else if (!YMOBV.checkInvalid(obj.value)) {
			if (obj.className != "error") alert('搜索名称含有非法字符。');
			obj.className="error";
			return false;
		} else {
			obj.className="";
			return true;
		}
	},
	checkSearchBoxSize : function(){
		//printfire("in checkSearchBoxSize");
		var customBox = document.getElementById('prvwSizeCustom');
		var customBoxVal = document.getElementById('sb_customBoxWidth');
		if(customBox.checked){
				if(YMOBV.checkRange(customBoxVal.value,[300,600])){
                                        //printfire("************ PASS ***********");
                                        YMOB.globals.widthSel = customBoxVal.value;
                                        customBoxVal.value=YMOB.globals.widthSel;
                                        customBoxVal.className="";
                                } else {
                                        //printfire("************ FAIL ***********");
                                        customBoxVal.className="error";
                                        //printfire('errord out?');
                                        setTimeout("document.getElementById('sb_customBoxWidth').focus()",100);
					return false;
                                }
		}
		return true;
		//printfire("out of checkSearchBoxSize");
	},
	checkVerticalSelected : function(){
		var inputs = document.getElementsByTagName('input');
		var checkboxes = new Array(); 
		for(var y=0;y<inputs.length;y++){
			if(inputs[y].type=='checkbox'&&inputs[y].className=='selectVertical'&&inputs[y].checked==true){
				checkboxes[checkboxes.length] = inputs[y].id ;
			}
		}
		if(checkboxes.length<=0){
			document.getElementById('verticalError').innerHTML="请至少选择一种搜索类型";
			document.getElementById('verticalError').style.display="block";
			return false;
		}
			document.getElementById('verticalError').style.display="none";
			return true;
	},
	showLogoRequirements : function(){
		var required = document.getElementById('addLogo').checked?true:false;
		printfire('make required= ' + required);
		switch(required){
			case true:
				document.getElementById('logoUrlReq').style.display="inline";
				document.getElementById('siteUrlReq').style.display="inline";
				document.getElementById('logoAltUrlReq').style.display="inline";
			break;
			default:
				document.getElementById('logoUrlReq').style.display="none";
				document.getElementById('siteUrlReq').style.display="none";
				document.getElementById('logoAltUrlReq').style.display="none";
			break;
		}
	},
	checkLogoSize : function(){
		printfire('In checkLogoSize');
		var theLogoUrl = document.getElementById('logoUrl').value;
		var addLogoChecked = document.getElementById('addLogo').checked;
		var logoHeight = document.getElementById('mob_logo_height').value
		var logoWidth = document.getElementById('mob_logo_width').value
		if(isNaN(logoHeight)) {
			YMOB.globals.logoWidthErr = "\n * logo大小包含非法字符";
			document.getElementById('mob_logo_height').className='error';
			return false;
		};
		if(isNaN(logoWidth)) {
			YMOB.globals.logoWidthErr = "\n * logo大小包含非法字符";
			document.getElementById('mob_logo_width').className='error';
			return false;
		};
		if(addLogoChecked && theLogoUrl!=''){
			//printfire('set it');
			YMOB.customGlobals.lurl=theLogoUrl;
			YMOB.customGlobals.ul=true;
		} else {
			YMOB.customGlobals.lUrl=theLogoUrl;
			YMOB.customGlobals.ul=false;
		}
		function checkHeight(){
			if(logoHeight>60){
				YMOB.globals.logoWidthErr = "\n * 请确认你的Logo大小在允许范围内. (最大宽度: 400px 最大高度: 60px)";
				document.getElementById('mob_logo_height').className='error';
				return false;
			} else {
				document.getElementById('mob_logo_height').className='';
				return true;
			}
		}

		function checkWidth(){
			if(logoWidth>400){
                        YMOB.globals.logoWidthErr = "\n * 请确认你的Logo大小在允许范围内. (最大宽度: 400px 最大高度: 60px)";
                        document.getElementById('mob_logo_width').className='error';
                        return false;
			} else {
				document.getElementById('mob_logo_width').className='';
				return true;
			}
		}


		printfire("theLogoUrl= " + theLogoUrl + " - and checked = " + addLogoChecked);

		var le = document.getElementById('logoErrorDiv');
		    le.innerHTML = "";
		var isValid = true;
		var heightIsGood = checkHeight();
		var widthIsGood = checkWidth();
		if(!heightIsGood || ! widthIsGood){isValid = false;}
		printfire('out of checkLogoSize (isValid = ' + isValid + ') and heightIsGood = ' + heightIsGood + "and widthidgood = " + widthIsGood);
		return isValid;
	},
	checkBannerText : function(){
		var logoChecked = document.getElementById('addLogo').checked;
		var theBannerText = document.getElementById('bannerText').value;
		if (theBannerText==''){
			document.getElementById('bannerText').className = 'error';
			YMOB.globals.bannerTextErr = "\n * 请输入你的页头文字.";
			return false;
		} else if (theBannerText.length > 20) {
			document.getElementById('bannerText').className = 'error';
			YMOB.globals.bannerTextErr = "\n * 页头文字长度不能超过20.";
			return false;
		} else if (!YMOBV.checkInvalid(theBannerText)) {
			document.getElementById('bannerText').className = 'error';
			YMOB.globals.bannerTextErr = "\n * 页头文字含有非法字符.";
			return false;
		} else {
			document.getElementById('bannerText').className = '';
			return true;
		}
	},
	checkAltText : function(){
		var logoChecked = document.getElementById('addLogo').checked;
		var logoAlt = document.getElementById('logoAlt').value;
		if (logoChecked && logoAlt==''){
			document.getElementById('logoAlt').className = 'error';
			YMOB.globals.altTextErr = "\n * 请输入Logo的描述文字.";
			return false;
		} else {
			document.getElementById('logoAlt').className = '';
			return true;
		}
	},
	checkColorValue: function(obj) {
		var checkThisVal = obj.value.toUpperCase();
		var checkThis = obj;
		if (!YMOBV.checkHex(checkThisVal)) {
			checkThis.className = 'error';
			YMOB.globals.colorValueErr = '颜色数值错误';
			return false;
		}	
		else 
			return true;
	},
	checkLogoUrl : function(){
		var logoChecked = document.getElementById('addLogo').checked;
		var logoUrl = document.getElementById('logoUrl').value;
		if (logoChecked && logoUrl==''){
			document.getElementById('logoUrl').className = 'error';
			YMOB.globals.logoErr = "\n *  请输入Logo的URL路径";
			return false;
		} else {
			document.getElementById('logoUrl').className = '';
			return true;
		}
	},
	checkLogoTargetUrl : function(){
		var logoChecked = document.getElementById('addLogo').checked;
		var siteUrl = document.getElementById('siteUrl').value;
		if (logoChecked && siteUrl==''){
			document.getElementById('siteUrl').className = 'error';
			YMOB.globals.logoTargetErr = "\n * 请输入Logo的链接地址";
			return false;
		} else {
			document.getElementById('siteUrl').className = '';
			return true;
		}
	},
	checkVerticalDomain : function(){
		//printfire("Checking Domain Checkbox");
		var domainCheckBox = document.getElementById('siteSearch');
		var siteToSearch = document.getElementById('siteSearchUrl');
		//printfire("is it checked? " + domainCheckBox.checked);
		//printfire("domain to search = " + siteToSearch.value);
		if(domainCheckBox.checked && (siteToSearch.value=='' && siteToSearch.value=='') ){
			document.getElementById('verticalError').innerHTML="请输入站内搜索的域名";
			document.getElementById('verticalError').style.display="block";
			return false;
		} else {
			document.getElementById('verticalError').style.display="none";
			return true;
		}
	},
	checkPopBlocked : function(){
		//printfire("in checkPopBlocked");
		var showPop = document.getElementById('mob_sb_showpopular');
		var block = document.getElementById('mob_popular_blocked');

		if(block.value != ''){
		//printfire('in here : ' + showPop.checked);
			document.getElementById('mob_sb_showpopular').checked;
				//printfire("sending " + showPop + " to YMOB.setshowPopular");
				YMOB.setshowPopular(showPop);
			} else {
				//What other tests do we need in here?
			}
			
		}

	}


YMOB = new yMobEvt();
YMOBV = new yMobVal();
YMOB.GetUrlParms();
var str=window.location;
//var str="http://www.yahoo.com/test.html#session/CE5F3B64-BB92-11DD-87C5-427B07D7E024/yid/tjuan20
var re=/#session\/(.+)\/yid\/(\w+)/;
var cid=re.exec(str);
if(cid) 
{
	var session=cid[1];
	var yid=cid[2];
	YAHOO.util.Cookie.set("session",session);
YAHOO.util.Cookie.set("yid",yid);
}else
{
	if(!YAHOO.util.Cookie.get("session")||!YAHOO.util.Cookie.get("yid"))
	{
	alert("请登录！！");
	window.location=logurl;
	}
}
openresty.session=YAHOO.util.Cookie.get("session");
