﻿var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
// Add by Shania 2009-04-13 Favicon
document.write("<link rel=icon href=http://www.moxa.com/images/favicon.ico type=image/x-icon>" );
document.write("<link rel=shortcut icon href=http://www.moxa.com/images/favicon.ico type=image/x-icon>");
// add end


document.write("\<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>\<\/script>" );
document.write('<SCRIPT type="text/javascript" src="https://lct.salesforce.com/sfga.js"></SCRIPT>');


	function google_search(){
	  
	  var ckq = document.getElementById('q');
	 
	 if(document.form1.as_q.value != 'search'){
	 ckq.value = document.form1.as_q.value ;
	 }
	
if (document.formx.Submit) {
     
    document.formx.Submit();
}
else {
   
    document.formx.submit();
}

	  
	}
	function txtbox_ck(){
	  if(document.form1.as_q.value == 'search' || document.form1.as_q.value == ''){
	     document.form1.as_q.value = 'search';
	     
	  } 
	}
	function txtbox_null(){
	 if(document.form1.as_q.value == 'search'){
	document.form1.as_q.value = '';
	}
	}
	
	function set_google_form(){
	    
	    
	  var aq = document.form1.as_q;
      
	    
if(window.addEventListener){ // Mozilla, Netscape, Firefox
	    
	    if(aq != null){
	     document.addEventListener("keypress", dispatch,false);
	     //alert('is set');
	    }   
}
else{ // IE
	    if(aq != null){
	   aq.attachEvent("onkeydown", google_enter);//IE use enter enable;
	     //aq.attachEvent("onkeydown", dispatch);// FireFox enetr enable
	    }
  }	    
	   // var aq = document.getElementById('as_q');
	   // if(aq != null){
	   //  aq.attachEvent("onkeydown", google_enter);
	   // }
		  var tmp = '<form action="http://www.moxa.com/search.htm" name="formx" id="formx" method="GET">';

	  tmp += '<input type="hidden" name="cx" value="017133840702386478730:qkjzhee2ijq" /><input type="hidden" name="cof" value="FORID:11" /><input type="hidden" name="q" id="q" size="25" /><input type="submit" name="submitz" style="display:none">   </form>';

	  tmp += '<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_017133840702386478730%3Aqkjzhee2ijq&lang=en"></script><INPUT type="hidden" name="sfga" value="00D200000001JNh" />';
	 
 var gform = document.getElementById('google_form');
	  gform.innerHTML = tmp;
var pageTracker = _gat._getTracker("UA-297123-1");
pageTracker._initData();
pageTracker._trackPageview();
 __sfga();  
	  
	}
	
	function set_google_link_analy(links){
	
var pageTracker = _gat._getTracker("UA-297123-1");
pageTracker._initData();
pageTracker._trackPageview("'" + links + "'");	
	
	}	
	
function google_enter(){
  
  if(event.keyCode == 13){
    google_search();
    return false;
  }
 // return false;
}


//============================================================
function Browser(){
 var d_ = document,n_ = navigator,t_ = this,s_= screen;
 
    var b = n_.appName;
    var ua = n_.userAgent.toLowerCase();
    
 t_.name = "Unknow";
 
 t_.safari = ua.indexOf("safari")>-1;  // always check for safari & opera
    t_.opera = ua.indexOf("opera")>-1;    // before ns or ie
 t_.firefox = !t_.safari && ua.indexOf('firefox')>-1; // check for gecko engine 
    t_.ns = !t_.firefox && !t_.opera && !t_.safari && (b=="Netscape");
    t_.ie = !t_.opera && (b=="Microsoft Internet Explorer");
 
 t_.name = (t_.ie ? "IE" : (t_.firefox ? "Firefox" : (t_.ns ? "Netscape" : (t_.opera ? "Opera" : (t_.safari ? "Safari" : "Unknow")))));
}

//=============================================================

 var dispatch = function (evt){
  evt = evt || event;
   var brw = new Browser();
               var   isie   =   (document.all)   ?   true   :   false;
                var   key;
                if   (isie)
                        key   =   window.event.keyCode;
                else
                        key   =   evt.which;   
    
    try{
     var xxname = document.activeElement.name;
    }catch(e){
      var xxname = "";
      
      if(document.form1.as_q.value != 'search' && document.form1.as_q.value != '')  xxname = "as_q";
    }
  
   if(key == 13 && xxname == 'as_q'){
   
   
    switch(brw.name){
     case "IE":
      evt.returnValue = false;
      evt.keyCode = 0;
      break;
     case "Firefox":
      //evt.returnValue = false;
      evt.preventDefault();
      
      break;
     case "Opera":
      evt.returnValue = false;
      evt.preventDefault();
      break;
     case "Safari":
      evt.preventDefault();
      evt.returnValue = false;
      }
      google_search();
      //for(o in evt)
      // document.write(o," ",typeof(eval("evt." + o))," = ",eval("evt." + o),"<br />");
      
    }
    
 
 
 }
	
