﻿// JavaScript Document
<!--

function GetObjByID(id) {
    return document.getElementById(id);
}

function showMenu(baseID, divID,imgID){
    baseID = GetObjByID(baseID);
    baseID.className='currmenu';
    objImg=document.getElementById("imgx_"+imgID);
    objImg.src="images/menu_0" + imgID + ".jpg";
    divID  = GetObjByID(divID);
    if (showMenu.timer) clearTimeout(showMenu.timer);
	hideCur();
    divID.style.display = 'block';
	showMenu.cur = divID;
    if (!divID.isCreate) {
        divID.isCreate = true;
        //divID.timer = 0;
        divID.onmouseover = function () {
            if (showMenu.timer) clearTimeout(showMenu.timer);
			hideCur();
            divID.style.display = 'block';
        };
        function hide () {
            objImg.src="images/menu_" + imgID + ".jpg";
            showMenu.timer = setTimeout(function () {divID.style.display = 'none';}, 1000);
        }
        divID.onmouseout = hide;
        baseID.onmouseout = hide;
    }
	function hideCur () {
		showMenu.cur && (showMenu.cur.style.display = 'none');
	}
}

function ChangeMenuBgOver(n){
var obj=document.getElementById("imgx_"+n);
obj.src="images/menu_0" + n + ".jpg";
}

function ChangeMenuBgOut(n){
var obj=document.getElementById("imgx_"+n);
obj.src="images/menu_" + n + ".jpg";
}

function setTopTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}
function setRightTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hoverright":"";
con.style.display=i==cursel?"block":"none";
}
}
function setTab(name,cursel,n,hover){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("tab_"+name+"_"+i);
menu.className=i==cursel?hover:"";
con.style.display=i==cursel?"block":"none";
}
}
function ChangeMenu(name,cursel,n,hover){
for(i=1;i<=n;i++){
var con=document.getElementById("index_subcategory_item_"+i);
con.style.display=i==cursel?"block":"none";
var menu=document.getElementById(name+i);
menu.className=i==cursel?hover:"";
}
}
function ChangeMenuOver(name,cursel,n,hover){
for(i=1;i<=n;i++){
var con=document.getElementById("index_subcategory_item_"+i);
con.style.display="none";
var menu=document.getElementById(name+i);
menu.className=i==cursel?hover:"";
}
}
// Reload code
function reloadcode(id){
var verify=document.getElementById(id);
if(verify!=null)
{
verify.setAttribute('src','checkcode.aspx?'+Math.random());
}
}

// Sidemenu show
function show(no){
var Obj=eval("menusub" + no);
//var ImgObj=eval("menuimg"+ no);
var tempColl = document.getElementsByTagName("li");
 for(i=0; i<tempColl.length; i++)
 {
  if ((tempColl[i].id != Obj.id) && ((tempColl[i].className == "menusub"))){  
   tempColl[i].style.display = "none";
   }
   
 }
if(Obj.style.display=='none')
 {
   Obj.style.display='';
  // ImgObj.src='bbs_image/forum_parent_1.gif';
 }
else
 {
   Obj.style.display='none';
   //ImgObj.src='bbs_image/forum_parent_0.gif';
 }
}

// Scroll Img
function ScrollImgLeft(){
var speed=16
var scroll_begin = document.getElementById("scroll_begin_Left");
var scroll_end = document.getElementById("scroll_end_Left");
var scroll_div = document.getElementById("scroll_box_Left");
scroll_end.innerHTML=scroll_begin.innerHTML
  function Marquee(){
    if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0)
      scroll_div.scrollLeft-=scroll_begin.offsetWidth
    else
      scroll_div.scrollLeft++
  }
var MyMar=setInterval(Marquee,speed)
  scroll_div.onmouseover=function() {clearInterval(MyMar)}
  scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}

function ScrollImgTop(){
var speed=16
var scroll_begin = document.getElementById("scroll_begin_Top");
var scroll_end = document.getElementById("scroll_end_Top");
var scroll_div = document.getElementById("scroll_box_Top");
scroll_end.innerHTML=scroll_begin.innerHTML
  function Marquee(){
    if(scroll_end.offsetHeight-scroll_div.scrollTop<=0)
      scroll_div.scrollTop-=scroll_begin.offsetHeight
    else
      scroll_div.scrollTop++
  }
var MyMar=setInterval(Marquee,speed)
  scroll_div.onmouseover=function() {clearInterval(MyMar)}
  scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
}

//other

function initMenu(obj,list) {
var cobj=document.getElementById(list);
if(cobj != null){
cobj.style.display=(cobj.style.display=="none") ? "" : "none";
}
}

function Winopen(Url)
{
	window.open(Url,"facility","left=0,top=0,width=700,height=600,toolbar=1,status=1,scrollbars=1");
}
function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}
	
function showLargePic (pic) { 	
	if (document.getElementById) { 		
	document.getElementById('LargePic').src = pic.href;
	return false; 	
	} 
	  else { return true; } 
}
	
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

// Add to Favorites
function bookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera  &&  window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}

// Feedback
function CheckFeedbackForm()
{
	if(document.myformfeedback.username.value=="")
	{
		alert("Error: please fill the required fields (Name).");
		document.myformfeedback.username.focus();
		return false;
	}
	if(document.myformfeedback.tel.value=="")
	{
		alert("Error: please fill the required fields (Tel).");
		document.myformfeedback.tel.focus();
		return false;
	}
 if(document.myformfeedback.email.value.length!=0)
  {
    if (document.myformfeedback.email.value.charAt(0)=="." ||        
         document.myformfeedback.email.value.charAt(0)=="@"||       
         document.myformfeedback.email.value.indexOf('@', 0) == -1 || 
         document.myformfeedback.email.value.indexOf('.', 0) == -1 || 
         document.myformfeedback.email.value.lastIndexOf("@")==document.myformfeedback.email.value.length-1 || 
         document.myformfeedback.email.value.lastIndexOf(".")==document.myformfeedback.email.value.length-1)
     {
      alert("Error: please enter a valid email address.");
      document.myformfeedback.email.focus();
      return false;
      }
   }
 else
  {
   alert("Error: please fill the required fields (Email).");
   document.myformfeedback.email.focus();
   return false;
   }
	if(document.myformfeedback.title.value=="")
	{
		alert("Error: please fill the required fields (Title).");
		document.myformfeedback.title.focus();
		return false;
	}
	if(document.myformfeedback.content.value=="")
	{
		alert("Error: please fill the required fields (Content).");
		document.myformfeedback.content.focus();
		return false;
	}
}

//登陆验证
function CheckLoginForm()
{
   if (document.LoginForm.uid.value =="")
	{
		alert("请输入您的用户名！");
		document.LoginForm.uid.focus();
		return false;
	}
	if (document.LoginForm.upwd.value =="") 
	{
		alert("请输入您的密码！");
		document.LoginForm.upwd.focus();
		return false; 
	}
	return true;
}
//注册验证
function CheckRegForm()
{   
    var filter=/^\s*[A-Za-z0-9]{6,16}\s*$/;
	if (document.RegForm.uid.value =="")
	{
		alert("请输入您的用户名！");
		document.RegForm.uid.focus();
		return false;
	}
	if (document.RegForm.upwd.value =="") 
	{
		alert("请输入您的密码！");
		document.RegForm.upwd.focus();
		return false; 
	}
    if (!filter.test(document.RegForm.upwd.value)) 
	{ 
		alert("密码填写不正确,请重新填写！可使用的字符为(A-Z a-z 0-9)长度不小于6个字符，不超过16个字符，注意不要使用空格。"); 
		document.RegForm.upwd.focus();
		document.RegForm.upwd.select();
		document.RegForm.confirm_upwd.value="";
		return false; 
	} 
	if (document.RegForm.confirm_upwd.value =="") 
	{
		alert("请输入您的确认密码！");
		document.RegForm.confirm_upwd.focus();
		return false; 
	}
	if (document.RegForm.upwd.value !=document.RegForm.confirm_upwd.value) 
	{
		alert("您输入的的确认密码不一致！");
		document.RegForm.confirm_upwd.focus();
		document.RegForm.confirm_upwd.select();
		return false; 
	}
	if (document.RegForm.checkcode.value=="") 
	{
		alert("请确认验证码！");
		document.RegForm.upwd.focus();
		return false; 
	}
	return true;
}


//vip 
function checkuserinfo()
{
	if(checkspace(document.userinfo.UserQuestion.value))
  {
   alert("请输入提示问题");
   document.userinfo.UserQuestion.focus();
   return false;
   }  
    if(checkspace(document.userinfo.UserAnswer.value))
  {
   alert("请输入提示答案");
   document.userinfo.UserAnswer.focus();
   return false;
   }  
	 if(checkspace(document.userinfo.firstname.value))
  {
   alert("请输入姓名");
   document.userinfo.firstname.focus();
   return false;
   }  
    if(checkspace(document.userinfo.lastname.value))
  {
   alert("请输入昵称");
   document.userinfo.lastname.focus();
   return false;
   }  
 if(document.userinfo.useremail.value.length!=0)
  {
    if (document.userinfo.useremail.value.charAt(0)=="." ||        
         document.userinfo.useremail.value.charAt(0)=="@"||       
         document.userinfo.useremail.value.indexOf('@', 0) == -1 || 
         document.userinfo.useremail.value.indexOf('.', 0) == -1 || 
         document.userinfo.useremail.value.lastIndexOf("@")==document.userinfo.useremail.value.length-1 || 
         document.userinfo.useremail.value.lastIndexOf(".")==document.userinfo.useremail.value.length-1)
     {
      alert("错误的Email格式");
      document.userinfo.useremail.focus();
      return false;
      }
   }
 else
  {
   alert("请输入Email地址!");
   document.userinfo.useremail.focus();
   return false;
   }
}

function check0()
{
   if(checkspace(document.shop0.username.value)) {
	document.shop0.username.focus();
    alert("请输入帐号");
	return false;
  }
  }
  function check1()
{
   if(checkspace(document.shop1.UserAnswer.value)) {
	document.shop1.UserAnswer.focus();
    alert("请输入答案");
	return false;
  }
  }
   function check2()
{
   if(checkspace(document.shop2.UserPassword1.value)) {
	document.shop2.UserPassword1.focus();
    alert("请输入新密码");
	return false;
  }
  if(checkspace(document.shop2.UserPassword2.value)) {
	document.shop2.UserPassword2.focus();
    alert("请输入确认密码");
	return false;
  }
  if(document.shop2.UserPassword1.value != document.shop2.UserPassword2.value) {
	document.shop2.UserPassword1.focus();
	document.shop2.UserPassword1.value = '';
	document.shop2.UserPassword2.value = '';
    alert("请确认密码输入是否一致");
	return false;
  }
}

function checkrepass()
{
   if(checkspace(document.userpass.UserPassword.value)) {
	document.userpass.UserPassword.focus();
    alert("错误: 请输入旧密码!");
	return false;
  }
     if(checkspace(document.userpass.UserPassword1.value)) {
	document.userpass.UserPassword1.focus();
    alert("错误:请输入新密码");
	return false;
  }
     if(checkspace(document.userpass.UserPassword2.value)) {
	document.userpass.UserPassword2.focus();
    alert("错误:请输入确认密码");
	return false;
  }
   if(document.userpass.UserPassword1.value != document.userpass.UserPassword2.value) {
	document.userpass.UserPassword1.focus();
	document.userpass.UserPassword1.value = '';
	document.userpass.UserPassword2.value = '';
    alert("错误: 请确认输入的确认密码一致");
	return false;
  }
}

  function checkUserLogin()
{
    if(checkspace(document.loginfo.username.value)) {
	document.loginfo.username.focus();
    alert("错误: 请输入帐号");
	return false;
  }
    if(checkspace(document.loginfo.UserPassword.value)) {
	document.loginfo.UserPassword.focus();
    alert("错误: 请输入密码");
	return false;
  }
   /*
    if(checkspace(document.loginfo.passcode.value)){
	document.loginfo.passcode.focus();
	alert("Error: please fill the required fields (Pass Code).");
	return false;
	}*/
	
  }
  
  
 //order 
 function OrderCheckForm()
{
	if(document.order_myform.username.value=="")
	{
		alert("Error: please fill the required fields (Username).");
		document.order_myform.username.focus();
		return false;
	}
	if(document.order_myform.firstname.value=="")
	{
		alert("请输入姓名");
		document.order_myform.firstname.focus();
		return false;
	}
	if(document.order_myform.lastname.value=="")
	{
		alert("请输入昵称");
		document.order_myform.lastname.focus();
		return false;
	}
	if(document.order_myform.street.value=="")
	{
		alert("请输入地址");
		document.order_myform.street.focus();
		return false;
	}
	if(document.order_myform.city.value=="")
	{
		alert("城市不能空");
		document.order_myform.city.focus();
		return false;
	}
	if(document.order_myform.province.value=="")
	{
		alert("省份不能空");
		document.order_myform.province.focus();
		return false;
	}
	if(document.order_myform.country.value=="")
	{
		alert("请输入国家");
		document.order_myform.country.focus();
		return false;
	}
	if(document.order_myform.postcode.value=="")
	{
		alert("请输入邮编");
		document.order_myform.postcode.focus();
		return false;
	}
	if(document.order_myform.tel.value=="")
	{
		alert("请输入电话");
		document.order_myform.tel.focus();
		return false;
	}
if(document.order_myform.email.value.length!=0)
  {
    if (document.order_myform.email.value.charAt(0)=="." ||        
         document.order_myform.email.value.charAt(0)=="@"||       
         document.order_myform.email.value.indexOf('@', 0) == -1 || 
         document.order_myform.email.value.indexOf('.', 0) == -1 || 
         document.order_myform.email.value.lastIndexOf("@")==document.order_myform.email.value.length-1 || 
         document.order_myform.email.value.lastIndexOf(".")==document.order_myform.email.value.length-1)
     {
      alert("请输入正确的Email地址");
      document.order_myform.email.focus();
      return false;
      }
   }
 else
  {
   alert("请输入Email");
   document.order_myform.email.focus();
   return false;
   }
	
if(document.order_myform.msn.value.length!=0)
  {
    if (document.order_myform.msn.value.charAt(0)=="." ||        
         document.order_myform.msn.value.charAt(0)=="@"||       
         document.order_myform.msn.value.indexOf('@', 0) == -1 || 
         document.order_myform.msn.value.indexOf('.', 0) == -1 || 
         document.order_myform.msn.value.lastIndexOf("@")==document.order_myform.msn.value.length-1 || 
         document.order_myform.msn.value.lastIndexOf(".")==document.order_myform.msn.value.length-1)
     {
      alert("请输入正确的MSN");
      document.order_myform.msn.focus();
      return false;
      }
   }
 else
  {
   alert("请输入MSN");
   document.order_myform.msn.focus();
   return false;
   }
      if(document.order_myform.shipment.value=="") {
	document.order_myform.shipment.focus();
    alert("请选择配送方式");
	return false;
  }
      if(document.order_myform.payment.value=="") {
	document.order_myform.payment.focus();
    alert("请选择支付方式");
	return false;
  }
}

//鼠标移到小图在大图显示
function DisplaySmallPicOnBigPic(imgObj,imgSrc) {
var cobj=document.getElementById(imgObj);
if(cobj != null){
cobj.src=imgSrc;
}
}
function DisplaySmallPicOnBigPic1(imgObj,imgObj1) {
var cobj=document.getElementById(imgObj);
var cobj1=document.getElementById(imgObj1);
if(cobj != null){
if(cobj1!=null)
{
cobj.src=cobj1.src;
}
}
}

function AddFavorite(sURL,sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败");
        }
    }
}
//-->

