/**
使用此文件必须要同时包含protype.js与public.js
**/
tab1 = function (id) {
switch (id)
   {
      case 2 :
        GetObj('id_weekshow').style.display= '';
        GetObj('id_monthshow').style.display= 'none';
        GetObj('id_totalshow').style.display= 'none';
        GetObj("td_week").className  = 'on';
        GetObj("td_month").className = '';
        GetObj("td_total").className = '';
        linkboard = 2;
        getAjaxData1('loadcontent_weekshow','blockdata.jsp?showtype=b&linkboard='+linkboard);
        break;
      case 3 :
        GetObj('id_weekshow').style.display= 'none';
        GetObj('id_monthshow').style.display= '';
        GetObj('id_totalshow').style.display= 'none';
        GetObj("td_week").className  = '';
        GetObj("td_month").className = 'on';
        GetObj("td_total").className = '';
        linkboard = 1;
        getAjaxData1('loadcontent_monthshow','blockdata.jsp?showtype=b&linkboard='+linkboard);
        break;
      case 4 :
        GetObj('id_weekshow').style.display= 'none';
        GetObj('id_monthshow').style.display= 'none';
        GetObj('id_totalshow').style.display= '';
        GetObj("td_week").className  = '';
        GetObj("td_month").className = '';
        GetObj("td_total").className = 'on';
        linkboard = 96;
        break;
   }
}
selectsearchtype = function (searchtype)
{
	var fm = document.searchringForm;
  fm.searchtype.value=searchtype;
  if(searchtype=='ringlabel'){
    GetObj('li_ringlabel').className = 'on';
    GetObj("li_ringid").className  = '';
    GetObj("li_singgername").className = '';
	  GetObj("li_musicbox").className = '';
	  GetObj("li_gift").className = '';			
    fm.searchkey.value='幸福来了';
  }else if(searchtype=='singgername'){
    GetObj('li_ringlabel').className = '';
    GetObj("li_ringid").className  = '';
    GetObj('li_singgername').className = 'on';
	  GetObj("li_musicbox").className = '';
	  GetObj("li_gift").className = '';			
    fm.searchkey.value='周杰伦';
  }else if(searchtype=='ringid'){
    GetObj('li_ringlabel').className = '';
    GetObj("li_ringid").className  = 'on';
    GetObj("li_singgername").className = '';
	  GetObj("li_musicbox").className = '';
	  GetObj("li_gift").className = '';		
    fm.searchkey.value='5800000001';
  }else if(searchtype=='musicbox'){
    GetObj('li_ringlabel').className = '';
    GetObj("li_ringid").className  = '';
    GetObj("li_singgername").className = '';
	  GetObj("li_musicbox").className = 'on';
	  GetObj("li_gift").className = '';
    fm.searchkey.value='音乐盒';
    fm.action='musicBox.jsp';
    fm.grouptype.value='1';
  }else if(searchtype=='gift'){
    GetObj('li_ringlabel').className = '';
    GetObj("li_ringid").className  = '';
    GetObj("li_singgername").className = '';
	  GetObj("li_musicbox").className = '';
	  GetObj("li_gift").className = 'on';	
    fm.searchkey.value='大礼包';
    fm.action='musicBox.jsp';
    fm.grouptype.value='2'; 
  }
}
submitsearch = function ()
{
	var fm = document.searchringForm;	
  if( fm.searchkey.value==''){
   alert("请输入搜索内容");
   fm.searchkey.focus();
   return;
 }
  var searchtype= fm.searchtype.value;
  if(searchtype=='musicbox')
  {
   fm.action='musicBox.jsp';
   fm.grouptype.value='1';  
  }else if(searchtype=='gift'){
   fm.action='musicBox.jsp';
   fm.grouptype.value='2';   
  }else if(searchtype=='discount'){
   fm.action='discount.jsp';
  }
 fm.submit();	
}
switchvisible=function(ele){
	if( !GetObj(ele)){return;}
	if(GetObj(ele).style.display=='none'){
		GetObj(ele).style.display = 'block';
	}else{
		GetObj(ele).style.display = 'none';
	}
}
var bgObj,msgObj,logMsgtitle;
removeObj = function (){//点击标题栏触发的事件		
	  try{	
		document.body.removeChild(bgObj);//删除背景层Div
		GetObj("msgDiv").removeChild(logMsgtitle);//删除提示框的标题栏
		document.body.removeChild(msgObj);//删除提示框层		
	  }catch(e){}
	  refreshloginfield();
	  try{
		  if( GetObj("fkmobilephone") ){	  	
		  	 GetObj("fkmobilephone").focus();	   
		  }
	  }catch(e){}
}
alertLoginForm = function(stitle,purl){	
	var msgw,msgh,bordercolor;
	msgw=260;//提示窗口的宽度
	msgh=200//提示窗口的高度
	titleheight=25 //提示窗口标题高度
	bordercolor="#9adae7";//提示窗口的边框颜色
	var sWidth,sHeight;
	sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度
	sHeight=screen.height;//屏幕高度（垂直分辨率）
	//背景层（大小与窗口有效区域相同，即当弹出对话框时，背景显示为放射状透明灰色）
	bgObj=document.createElement("div");//创建一个div对象（背景层）
	//定义div属性，即相当于
	//<div id="bgDiv" style="position:absolute; top:0; background-color:#777; filter:progid:DXImagesTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75); opacity:0.6; left:0; width:918px; height:768px; z-index:10000;"></div>
	bgObj.setAttribute('id','bgDiv');
	bgObj.style.position="absolute";
	bgObj.style.top="0";
	bgObj.style.background="#777";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50,finishOpacity=75";
	bgObj.style.opacity="1";
	bgObj.style.left="0";
	bgObj.style.width=sWidth + "px";
	bgObj.style.height=sHeight + "px";
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);//在body内添加该div对象
	
	msgObj=document.createElement("div")//创建一个div对象（提示框层）
	//定义div属性，即相当于
	//<div id="msgDiv" align="center" style="background-color:white; border:1px solid #336699; position:absolute; left:50%; top:50%; font:12px/1.6em Verdana,Geneva,Arial,Helvetica,sans-serif; margin-left:-225px; margin-top:npx; width:400px; height:100px; text-align:center; line-height:25px; z-index:100001;"></div>
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","center");
	msgObj.style.background="white";
	msgObj.style.border="1px solid " + bordercolor;
	msgObj.style.position = "absolute";
	msgObj.style.left = "50%";
	msgObj.style.top = "30%";
	msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
	msgObj.style.marginLeft = "-75px" ;
	msgObj.style.marginTop = -45+document.documentElement.scrollTop+"px";
	msgObj.style.width = msgw + "px";
	msgObj.style.height =msgh + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight ="25px";
	msgObj.style.zIndex = "10001";
	

	logMsgtitle=document.createElement("h4");//创建一个h4对象（提示框标题栏）
	//定义h4的属性，即相当于
	//< h4 id="msgTitle" align="right" style="margin:0; padding:3px; background-color: #336699; filter:progid:DXImageTransform.Microsoft.Alpha(startX=20, startY =20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100); opacity: 0.75; border:1px solid #336699; height:18px; font:12px Verdana,Geneva,Arial, Helvetica,sans-serif; color:white; cursor:pointer;" onclick="">关闭< /h4>
	logMsgtitle.setAttribute("id","msgTitle");
	logMsgtitle.setAttribute("align","right");
	logMsgtitle.style.margin="0";
	logMsgtitle.style.padding="3px";
	logMsgtitle.style.background=bordercolor;
	logMsgtitle.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
	logMsgtitle.style.opacity="0.75";
	logMsgtitle.style.border="1px solid " + bordercolor;
	logMsgtitle.style.height="18px";
	logMsgtitle.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
	logMsgtitle.style.color="white";
	logMsgtitle.style.cursor="pointer";
	logMsgtitle.innerHTML= stitle;
	logMsgtitle.onclick=removeObj;
		
	document.body.appendChild(msgObj);//在body内添加提示框div对象msgObj
	GetObj("msgDiv").appendChild(logMsgtitle);//在提示框div中添加标题栏对象title
	var txt=document.createElement("p");//创建一个p对象（提示框提示信息）
	txt.style.margin="1em 0"
	txt.setAttribute("id","msgTxt");
	txt.innerHTML="<iframe id=\"pop_iframe_id\" src='" + purl+ "' width='" + msgw+ "px'  height='" +msgh+ "px' frameborder='0' scrolling='no'></iframe>";//来源于函数调用时的参数值
	GetObj("msgDiv").appendChild(txt);//在提示框div中添加提示信息对象txt
}
showResponse = function (transport){	
  var result = transport.responseText;
  result = result.replace(/(^\s*)|(\s*$)/g, "");  
  if( result.indexOf(':') > 0){ 
  	var ret = result.split(':')[0];
  	var ssid= result.split(':')[1];  	
  	var purl = crbt_httpsHeader + "/colorring/enter.jsp?;jsessionid=" + ssid + "&sessionstr="+Math.random();  	
	  if( ret =='-1') {
	  	purl += "&model=showin";
	  	GetObj('loginfield').innerHTML= "<a href=\"javascript:alertLoginForm('关闭','" + purl + "');\"  target=\"\">登录</a>";    
	  }else{
	  	purl += "&model=showout";
	  	GetObj('loginfield').innerHTML= "<a href=\"javascript:alertLoginForm('关闭','" + purl + "');\" target=\"\">" + ret + ",退出请点这里</a>";
	  	if( GetObj('shoppingcart') ){
	  		var cartstr = result.split(':')[2];
	  		if( cartstr != null && cartstr != ''){
	  		 GetObj('shoppingcart').innerHTML = cartstr;
	  	 }
	  	}
	  }	  
  }
  window.status = '完毕';
}
refreshloginfield = function (){	
	window.status = '刷新登录信息';	
	//protype
  new Ajax.Request( 'passport.jsp?sessionstr='+Math.random(),{ method:'post',onSuccess:showResponse,onFailure:function(){}});   
}
remove_loading = function () {
	var targelem = GetObj('loader_container');
	if( targelem != null && targelem != 'undefined' && typeof(targelem) != 'undefined'){
		targelem.style.display='none';
		targelem.style.visibility='hidden';
	}
}
getAjaxData1 = function (dst,src){
	var ele = document.getElementById( dst );
  new Ajax.Updater(ele,src);   //protype  
}
showbulletin = function( i ){
	window.open('viewbulletin.jsp?bindex='+i,i,"height=500,width=700,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
updateDiscountMusicBox=function(){	
	var purl = "sessionstr="+Math.random()+"&showlink=true&showdel=false";
	new Ajax.Request("showCart.jsp?"+purl,{ method:"post",onSuccess:function(transport){GetObj('bag').innerHTML=transport.responseText;}}); 	
}
showresponseText=function(transport){
	var result = transport.responseText;
  result = result.replace(/(^\s*)|(\s*$)/g, "");
  if( result != ''){
  	alert(result);
  } 
}
addtoDiscountMusicBox=function(ringid,ringlabel,price,spindex,ifdiscount){
	if( ringid == ''){
		alert("请选择要添加的铃音");
		return;
	}
	if( ifdiscount != '1'){
		alert("抱歉，此铃音暂时不允许添加至打折音乐盒!");
		return;
	}	
	var purl = "sessionstr="+Math.random()+"&ringid="+ringid +"&ringlabel="+ringlabel+"&price="+price+"&spindex="+spindex;	
	new Ajax.Request("addCartEnd.jsp?" + purl,{ method:"post",onSuccess:showresponseText,contentType:'text/html',encoding:'GBK',onFailure:function(){}}); 
}
showDiscountMusicBox=function(){	
	updateDiscountMusicBox();
	switchvisible('bag');	
}
getHotSearchText=function(){
	getAjaxData1('hotSearch','getRingCataIndex.jsp');
}
onDefaultQuery=function(evn){
	var charCode = (navigator.appName == "Netscape") ? evn.which : evn.keyCode;
	if (charCode == 13){
	  submitsearch();
	}
}
