﻿//FLASH
function insertFlash(elm, url, w, h) {
if (!document.getElementById(elm)) return;
var str = '';
str += '<object width="'+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
str += '<param name="movie" value="'+ url +'">';
str += '<param name="wmode" value="opaque">';
str += '<param name="quality" value="autohigh">';
str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
str += '</object>';
document.getElementById(elm).innerHTML = str;
}

//search
     function funcSearch()
     {
        var words = "";
        var words1 = document.getElementById("seachName").value;
        var words2 = document.getElementById("seachNo").value;
        var words3 = document.getElementById("seachPrice").value;
        var words4 = document.getElementById("seachPrice2").value;
        if ((words1 == null || Trim(words1) == "") && (words2 == null || Trim(words2) == "") && (words3 == null || Trim(words3) == "") && (words4 == null || Trim(words4) == ""))
        {
            alert("请输入要搜索的产品的关键字！");
            document.getElementById("seachName").focus();
            return false;
        }
        else if( (words3 != null && Trim(words3) != "") && (words4 != null && Trim(words4) != "") && (CheckNum(words3) || CheckNum(words4)))
        {
            alert("输入的价格必须是数字！");
            document.getElementById("seachPrice").value = "";
            document.getElementById("seachPrice2").value = "";
            document.getElementById("seachPrice").focus();
            return false;
        }
        else
        {
            if(words1 != null && Trim(words1) != "")
            {
                words1 = escape(words1);
                words += "&kw=" + words1;
            }
            if(words2 != null && Trim(words2) != "")
            {
                words2 = escape(words2);
                words += "&kn=" + words2;
            }
            if(words3 != null && Trim(words3) != "" && words4 != null && Trim(words4) != "")
            {
                    words3 = escape(words3);
                    words += "&kp=" + words3;
                    words4 = escape(words4);
                    words += "&kp2=" + words4;
            }
            window.location.href="productsearch.aspx?0=0" + words;
        }
     }
    function funcEnter()
    {
        if(event.keyCode == 13)
        {
            funcSearch();
        }
    }
    function Trim(str)
    {
        if(str.charAt(0) == " ")
        {
            str = str.slice(1);
            str = Trim(str);
        }
        return str;
    }
    
    function CheckNum(InputValue)
    {		   
	           var reg=/^[1-9]+(\d*$)/; 
	           var isValid
	           isValid=reg.exec(InputValue)
	           if (!isValid) {
	             return true
	           }
	           return false
    }
    
//login2
function login2Enter()
{
    if(event.keyCode == 13)
    {
        login2();
    }
}
    
//login
function loginEnter()
{
    if(event.keyCode == 13)
    {
        login();
    }
}

//foundsn
function foundsn1Enter()
{
    if(event.keyCode == 13)
    {
        foundsn1();
    }
}
function foundsn2Enter()
{
    if(event.keyCode == 13)
    {
        foundsn2();
    }
}
function foundsn3Enter()
{
    if(event.keyCode == 13)
    {
        foundsn3();
    }
}

  
    
//屏蔽键盘相关事件  <body onkeydown="keydown()">
    function keydown(){
	if(event.keyCode==8){
		event.keyCode=0;
		event.returnValue=false;
		alert("当前设置不允许使用退格键");
	  }if(event.keyCode==13){
		event.keyCode=0;
		event.returnValue=false;
		alert("当前设置不允许使用回车键");
	  }if(event.keyCode==116){
		event.keyCode=0;
		event.returnValue=false;
		alert("当前设置不允许使用F5刷新键");
	  }if((event.altKey)&&((window.event.keyCode==37)||(window.event.keyCode==39))){
		event.returnValue=false;
		alert("当前设置不允许使用Alt+方向键←或方向键→");
	  }if((event.ctrlKey)&&(event.keyCode==78)){
	   event.returnValue=false;
	   alert("当前设置不允许使用Ctrl+n新建IE窗口");
	  }if((event.shiftKey)&&(event.keyCode==121)){
	   event.returnValue=false;
	   alert("当前设置不允许使用shift+F10");
	  }
}


//无提示关闭窗口
function closepage()
{
    window.opener=null; 
    window.open('','_self'); 
    window.close();
}


//屏闭图片右键保存图片
var clickmessage="广州金币版权所有！" 
function disableclick(e)
{
  if (document.all)
  {
      if (event.button==2||event.button==3)
      {
          if (event.srcElement.tagName=="IMG")
          {
              alert(clickmessage);
              return false;
          }
      }
  }
  else if (document.layers)
  {
      if (e.which == 3)
      {
          alert(clickmessage);
          return false;
      }
  }
  else if (document.getElementById)
  {
      if (e.which==3&&e.target.tagName=="IMG")
      {
          alert(clickmessage)
          return false
      }
  }
} 
function associateimages()
{
  for(i=0;i<document.images.length;i++)
  document.images[i].onmousedown=disableclick;
} 
if (document.all||document.getElementById)
{
  document.onmousedown=disableclick;
}
else if (document.layers)
{
  associateimages();
}
  
  
document.onselectstart=function()
                        {
                            event.returnValue=false;
                            
//                            var obj= event.srcElement;
//                            if(obj.tagName== "input" && obj.type.toLowerCase() == "text" )
//                            {
//                                return true;
//                            }
//                            else
//                            {
//                                return false;
//                            }
                        }
