var LAR_PREFIX = "Ler";
var layerName1 = 'layerInquiry';
var sid='sLayer';
var did='divIframe';
var isIE=navigator.appVersion.split("MSIE");
var isIEv=parseFloat(isIE[1]);
function $(_sId) {return document.getElementById(_sId);}
function DT(b_ID) {var bpx = $(LAR_PREFIX + b_ID).style; bpx.visibility = (bpx.visibility == 'visible') ? 'hidden':'visible';}

function getMaxIndex(){var s=document.getElementsByTagName("DIV"); var temp=1; for(var i=0;i<s.length;i++) temp=Math.max(temp,s[i].style.zIndex); return temp;}
function getMaxLayer(){var s=document.getElementsByTagName("DIV"); if (!s) return null; var temp=0; var j=0; for(var i=0;i<s.length;i++) if(s[i].style.zIndex>temp) {temp=s[i].style.zIndex;j=i;} return s[j];}
function swaplayer(layer1,layer2){var t=layer2.style.zIndex; layer2.style.zIndex=layer1.style.zIndex; layer1.style.zIndex=t;}
function xx_SetTop(obj){var maxzindexlayer=getMaxLayer(); if (maxzindexlayer) swaplayer(maxzindexlayer,obj);}
function xx_BeginMove(id, event) {
var elementToDrag = $(id);
var startX = event.clientX, startY = event.clientY;
var origX = elementToDrag.offsetLeft, origY = elementToDrag.offsetTop;
var deltaX = startX - origX, deltaY = startY - origY;
if (document.addEventListener) {
document.addEventListener("mousemove", moveHandler, true);
document.addEventListener("mouseup", upHandler, true);
}
else if (document.attachEvent) {
elementToDrag.setCapture( );
elementToDrag.attachEvent("onmousemove", moveHandler);
elementToDrag.attachEvent("onmouseup", upHandler);
elementToDrag.attachEvent("onlosecapture", upHandler);
}
else {
var oldmovehandler = document.onmousemove;
var olduphandler = document.onmouseup;
document.onmousemove = moveHandler;
document.onmouseup = upHandler;
}
if (event.stopPropagation) event.stopPropagation( );
else event.cancelBubble = true;
if (event.preventDefault) event.preventDefault( );
else event.returnValue = false;
function moveHandler(e) {
if (!e) e = window.event;
if ((e.clientX - deltaX)<=0)
elementToDrag.style.left = "0px";
else
elementToDrag.style.left = (e.clientX - deltaX) + "px";
if ((e.clientY - deltaY)<=0)
elementToDrag.style.top = "0px";
else
elementToDrag.style.top = (e.clientY - deltaY) + "px";
if (e.stopPropagation) e.stopPropagation( );
else e.cancelBubble = true;
}
function upHandler(e) {
if (!e) e = window.event;
if (document.removeEventListener) {
document.removeEventListener("mouseup", upHandler, true);
document.removeEventListener("mousemove", moveHandler, true);
}
else if (document.detachEvent) {
elementToDrag.detachEvent("onlosecapture", upHandler);
elementToDrag.detachEvent("onmouseup", upHandler);
elementToDrag.detachEvent("onmousemove", moveHandler);
elementToDrag.releaseCapture( );
}
else {
document.onmouseup = olduphandler;
document.onmousemove = oldmovehandler;
}
if (e.stopPropagation) e.stopPropagation( );
else e.cancelBubble = true;
}
}

function xx_Layer(id,title,width,height,left,top,content,seeyn){
this.id=id;
this.title=title;
this.style="overflow:visible;";
this.titlestyle="overflow:hidden;cursor:move;";
this.left=left;
this.top=top;
this.width=width;
this.height=height;
this.zIndex=getMaxIndex()+1;
this.seeyn=seeyn;
this.innerHTML=content;
if (content) this.draw();
}

xx_Layer.prototype.bG=function(pngurl){
var tempstyle = ((isIEv && isIEv<7) ? "position: absolute; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + pngurl + "', sizingMethod='scale'); background-repeat: no-repeat;" : "position: absolute; background-image:url(" + pngurl + "); background-repeat: repeat;");
return tempstyle;
};

xx_Layer.prototype.draw=function(){
var xlayer=$(this.id);
if (xlayer){alert("false");return false;}
xlayer=document.createElement("DIV");
xlayer.setAttribute("id",this.id);
xlayer.style.cssText=this.style + "width:" + this.width + ";height:" + this.height + ";left:" + this.left + ";top:" + this.top + ";z-index:" + this.zIndex + ";position:absolute;";
xlayer.style.display=(this.seeyn)?"none":"block";
xlayer.onclick=function(){xx_SetTop(xlayer);}
document.body.appendChild(xlayer);
var xlayer_title=document.createElement("DIV");
xlayer_title.style.cssText=this.titlestyle;
xlayer_title.innerHTML='\
<div style="font-size:12px; font-family:Arial, Helvetica, sans-serif;" onmousedown="xx_BeginMove(\'' + this.id + '\',event);">\
<div style="font-size:1px; margin-left:5px; margin-right:5px; height:5px; background-color:#989898;">\
<div style="left:0px; top:0px; width:5px; height:5px; ' + this.bG("../image/dlayer/corner-nw.png") + '"></div><div style="left:' + (this.width-5) + 'px; top:0px; width:5px; height:5px; ' + this.bG("../image/dlayer/corner-ne.png") + '"></div>\
</div>\
<div style="white-space:nowrap; position:absolute; right:5px; top:5px; z-index:' + ((this.zIndex)-1) + '">\
<div style="font-size:9px; float:right; cursor:pointer;"><img sr'+'c="../image/dlayer/panel-cross.gif" onclick="document.getElementById(\'' + this.id + '\').style.display=\'none\';" alt="Close" title="Close" height="15" width="15"></div>\
</div>\
<div style="overflow:hidden; height:1.6em; padding-top:0.1em; padding-left:10px; back'+'ground:url(../image/dlayer/header-gradient.gif) repeat-x center top #989898;">\
<div style="overflow:hidden; position:relative; margin-left:18px;"><div style="overflow:hidden; position:relative;"><a style="overflow:hidden; text-decoration:none; display:block; white-space:nowrap; font-size:12px; color:#000000; font-weight:bold; cursor:move;" id="' + this.id + '_title">' + this.title + '</a></div></div>\
</div>\
<div style="position:absolute; left:6px; top:5px; width:16px; height:16px;"><img sr'+'c="../image/tokenul.gif" border="0" height="16" width="16" style="' + this.bG("../image/direct.png") + '"></div>\
</div>\
';
xlayer.appendChild(xlayer_title);
var xlayer_child=document.createElement("DIV");
var temp1='\
<div style="overflow:hidden; position:relative; width:' + this.width + 'px; height:' + (this.height-30) + 'px;left:0px; top:0px; back'+'ground:url(../image/bgmail.gif) repeat-x #D9D9D7;">\
<div style="overflow:auto; margin:5px; padding:0px; position:absolute; left:0px; top:0px; width:' + (this.width-10) + 'px; height:' + (this.height-35) + 'px;">\
';
var temp2='\
</div></div>\
<div style="position:relative; margin-left:5px; margin-right:5px; height:5px; font-size:0.1px; background-color:#D9D9D7;">\
<div style="left:-5px; top:0px; width:5px; height:5px; ' + this.bG("../image/dlayer/corner-sw.png") + '"></div>\
<div style="left:' + (this.width-10) + 'px; top:0px; width:5px; height:5px; ' + this.bG("../image/dlayer/corner-se.png") + '"></div>\
</div>\
';
xlayer_child.innerHTML= temp1 + this.innerHTML + temp2;
xlayer.appendChild(xlayer_child);
var xlayer_bg=document.createElement("DIV");
xlayer_bg.style.cssText="overflow:visible;position:absolute;left:0px;top:0px;z-index:"+((this.zIndex)-10);
xlayer_bg.innerHTML='\
<div style="top:-5px;left:'+(this.width-5)+'px;width:13px;height:13px;font-size:1px;'+this.bG("../image/dlayer/3x-ne.png")+'"></div>\
<div style="top:-5px;left:-5px;width:13px;height:13px;font-size:1px;'+this.bG("../image/dlayer/3x-nw.png")+'"></div>\
<div style="top:-5px;left:8px;width:'+(this.width-13)+'px;height:13px;font-size:1px;'+this.bG("../image/dlayer/3x-n.png")+'"></div>\
<div style="top:'+(this.height-5)+'px;left:-5px;width:13px;height:13px;font-size:1px;'+this.bG("../image/dlayer/3x-sw.png")+'"></div>\
<div style="top:'+(this.height-5)+'px;left:8px;width:'+(this.width-13)+'px;height:13px;font-size:1px;'+this.bG("../image/dlayer/3x-s.png")+'"></div>\
<div style="top:'+(this.height-5)+'px;left:'+(this.width-5)+'px;width:13px;height:13px;font-size:1px;'+this.bG("../image/dlayer/3x-se.png")+'"></div>\
<div style="top:8px;left:'+(this.width-5)+'px;width:13px;height:'+(this.height-13)+'px;font-size:1px;'+this.bG("../image/dlayer/3x-e.png")+'"></div>\
<div style="top:8px;left:-5px;width:13px;height:'+(this.height-13)+'px;font-size:1px;'+this.bG("../image/dlayer/3x-w.png")+'"></div>\
';
xlayer.appendChild(xlayer_bg);
};

var Validator = {
Require : /.+/,
Email : /^\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
Group : "this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))",
ErrorItem : [document.forms[0]],
ErrorMessage : ["Please Fill Following Message:\t\t\t"],
Validate : function(theForm, mode){
var obj = theForm || event.srcElement;
var count = obj.elements.length;
this.ErrorMessage.length = 1;
this.ErrorItem.length = 1;
this.ErrorItem[0] = obj;
for(var i=0;i<count;i++){
with(obj.elements[i]){
var _dataType = getAttribute("dataType");
if(typeof(_dataType) == "object" || typeof(this[_dataType]) == "undefined")  continue;
this.ClearState(obj.elements[i]);
if(getAttribute("require") == "false" && value == "") continue;
switch(_dataType){
case "Group" : 
if(!eval(this[_dataType])){this.AddError(i, getAttribute("msg"));}
break;
default :
if(!this[_dataType].test(value)){this.AddError(i, getAttribute("msg"));}
break;
}
}
}
if(this.ErrorMessage.length > 1){
mode = mode || 1;
var errCount = this.ErrorItem.length;
switch(mode){
case 2 :
for(var i=1;i<errCount;i++) this.ErrorItem[i].style.color = "red";
case 1 :
alert(this.ErrorMessage.join("\n"));
this.ErrorItem[1].focus();
break;
default :
alert(this.ErrorMessage.join("\n"));
break;
}
return false;
}
return true;
},
ClearState : function(elem){
with(elem){
if(style.color == "red")
style.color = "";
var lastNode = parentNode.childNodes[parentNode.childNodes.length-1];
if(lastNode.id == "__ErrorMessagePanel")
parentNode.removeChild(lastNode);
}
},
AddError : function(index, str){
this.ErrorItem[this.ErrorItem.length] = this.ErrorItem[0].elements[index];
this.ErrorMessage[this.ErrorMessage.length] = this.ErrorMessage.length + ". " + str;
},
exec : function(op, reg){
return new RegExp(reg,"g").test(op);
},
MustChecked : function(name, min, max){
var groups = document.getElementsByName(name);
var hasChecked = 0;
min = min || 1;
max = max || groups.length;
for(var i=groups.length-1;i>=0;i--)
if(groups[i].checked) hasChecked++;
return min <= hasChecked && hasChecked <= max;
}
}
function m_s(obj) {
obj.style.background = "#ffffff";
}
function m_r(obj) {
obj.style.background = "#dfefff";
}
function getInfo() {
var now = new Date();
document.Form_mail.Date.value = now.toGMTString();
}
function setAttr() {
if($('Company_Name')){
var set_1 = $('in3');
set_1.setAttribute('dataType','Group');
set_1.setAttribute('msg','"Inquiry For" must check at least one.');
var set_2 = $('Company_Name');
set_2.setAttribute('dataType','Require');
set_2.setAttribute('msg','"Company Name" is required.');
var set_3 = $('Contaction_Person');
set_3.setAttribute('dataType','Require');
set_3.setAttribute('msg','"Contaction Person" is required.');
var set_4 = $('Phone');
set_4.setAttribute('dataType','Require');
set_4.setAttribute('msg','"Phone" is required.');
var set_5 = $('Country');
set_5.setAttribute('dataType','Require');
set_5.setAttribute('msg','"City/Country" is required.');
var set_6 = $('E_mail');
set_6.setAttribute('dataType','Email');
set_6.setAttribute('msg','"E-mail" is error, please check again.');
}
}

function send(stat) {if (stat) {$(sid).style.display='none'; $(did).style.display='block';}; return stat;}
function closeLayer(lid) {$(lid).style.display='none';}

function x_inquiry(lid,seeyn){
var wh=500;
var ht=500;
var lt=(document.body.clientWidth-wh)/2; lt=(lt<0)?10:lt;
var tp=108;
var locURL=document.location;
var ltitle='Buyers Inquiry Form &nbsp; - &nbsp; &copy; 2008 DIRECT';
var sTemp='\
<table width="438" border="0" cellspacing="0" align="center"><tr><td align="center" height="38"><span class="wel"><i>Welcome</i> <img sr'+'c="../image/log_mail_1.gif" alt="" border="0"> <b style="font:bold 15px Arial;">Buyers Inquiry Form</b></span></td></tr><tr><td align="center" height="38"><span style="font:bold 13px verdana;">Please fill out this form and we will answer you right away.<br></span><span style="font-size:11px">( <font style="color:#F06">*</font> is required )</span></td></tr></table>\
<form act'+'ion="../email_page.php?submit" target="tokeninquiry" method="post" name="Form_mail" onsubmit="getInfo();stat=Validator.Validate(this,2);return send(stat);"> <input name="Date" type="hidden"> <input name="Product" type="hidden" value="' + productName + '"> <input name="URL" type="hidden" value="' + locURL +'">\
<table width="436" border="0" cellpadding="0" cellspacing="0" align="center" class="table_form"><tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0">\
<tr class="trow"><td colspan="2">The product you inquiry:<br><div class="protd">' + productName + '</div></td></tr>\
<tr><td width="125">Inquiry for:<br><font style="color:#F00;font-weight:normal;font-size:10px;">(Multiple Check)</font></td><td valign="top" class="chlab"><input type="checkbox" name="Inquiry_for[]" id="in1" value="Detail of Specifications"> <label for="in1">Specifications</label> <input type="checkbox" name="Inquiry_for[]" id="in2" value="Sample Stocking"> <label for="in2">Samples</label> <input type="checkbox" name="Inquiry_for[]" id="in3" value="Product Quoting"> <label for="in3">Quotation</label></td></tr>\
<tr class="trow"><td>Company Name:</td><td><input id="Company_Name" name="Company_Name" type="text" class="text_form" size="45" onFocus="m_r(this)" onBlur="m_s(this)"> <span class=requ>*</span></td></tr>\
<tr><td>Contaction person:</td><td><input id="Contaction_Person" name="Contaction_Person" type="text" class="text_form" size="36" onFocus="m_r(this)" onBlur="m_s(this)"> <span class=requ>*</span></td></tr>\
<tr class="trow"><td>Phone:</td><td><input id="Phone" name="Phone" type="text" class="text_form" size="36" onFocus="m_r(this)" onBlur="m_s(this)"> <span class=requ>*</span></td></tr>\
<tr><td>FAX:</td><td><input id="Fax" name="Fax" type="text" class="text_form" size="36" onFocus="m_r(this)" onBlur="m_s(this)"></td></tr>\
<tr class="trow"><td>City/Country:</td><td><input id="Country" name="Country" type="text" class="text_form" size="36" onFocus="m_r(this)" onBlur="m_s(this)"> <span class=requ>*</span></td></tr>\
<tr><td>Website URL:</td><td><input id="Website_URL" name="Website_URL" type="text" class="text_form" size="36" onFocus="m_r(this)" onBlur="m_s(this)"></td></tr>\
<tr class="trow"><td>E-mail:</td><td><input id="E_mail" name="E_mail" type="text" class="text_form" size="36" onFocus="m_r(this)" onBlur="m_s(this)"> <span class=requ>*</span></td></tr>\
<tr><td valign="top">Comments:</td><td><textarea id="Remark" name="Remark" class="text_form" rows="4" cols="48" onFocus="m_r(this)" onBlur="m_s(this)"></textarea></td></tr>\
<tr align="center"><td height="35" colspan="2"><input type="submit" value="Send" class="send" onmouseover="this.style.background=\'#fdd\'" onmouseout="this.style.background=\'#dfd\'" onfocus="this.blur()"> <input type="reset" value="Reset" class="send" onmouseover="this.style.background=\'#fdd\'" onmouseout="this.style.background=\'#dfd\'" onfocus="this.blur()"></td></tr>\
</table></td></tr></table>\
</form>\
';
var divIframe='<iframe name="tokeninquiry" width="' + (wh-10) + '" height="' + (ht-35) + '" sr'+'c="../email_page.htm" frameborder="0" style="margin:0;padding:0;border:0;overflow:hidden;"></iframe>';
var s='<div id="' + sid + '" class="' + sid + '">' + sTemp + '</div><div id="' + did + '" class="' + did + '">' + divIframe + '</div>';
var newlayer1=new xx_Layer(lid,ltitle,wh,ht,lt,tp,s,seeyn);
setAttr();
}
function MM_openBrWindow() {if($(layerName1)) {$(layerName1).style.display="block";} else {x_inquiry(layerName1);} return false;}

//remark begin
function makeNode(str){
var newParagraph = document.createElement("div");
//var newText = document.createTextNode(str);
//newParagraph.appendChild(newText);
newParagraph.setAttribute("id","notice");
newParagraph.style.cssText="border:1px solid #999;margin:0 0 16px 0;background:#ffffe8;";
newParagraph.innerHTML = str;
return newParagraph;
}
function appendBefore(nodeId, str){
var node = document.getElementById(nodeId);
var newNode = makeNode(str);
if (node.parentNode)
node.parentNode.insertBefore(newNode,node);
}
function getTagHr(){
var rdivr=document.getElementsByTagName("HR");
if (rdivr){
rdivr[0].id="innerHR";
appendBefore("innerHR","<table cellspacing='0' cellpadding='0' style='border-left:2px solid #fcc;'><tr><td style='border-left:3px solid #faa;vertical-align:top;font-weight:bold;padding:2px 4px;'>Notice:</td><td style='padding:3px 1px;'>Specification Changed or Version Updated will be posted at irregular intervals. <br>All Updated and Final Specifications, Please Confirm with DIRECT ELECTRONICS REPRESENITIVES.</td></tr></table>");
}
}

if (parent.location.href != window.location.href) parent.location.href=window.location.href;
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var a,b,c; a='<a hr'; b='rfq'; c='">'; a+='ef="mai'; b+='@'; a+='lto:'; b+='4-direct.com';
function M_ss(msir,msie){return '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Image0\',\'\',\'' + msie + '\',1)"><img sr' + 'c="' + msir + '" alt="Email" border="0" name="Image0"></a>';}
function egemail(){return a+b+M_ss('../image/email1.gif','../image/email.gif');}
function MM_omov(mhref,idname,malt,msir,msie){return '<a hr' + 'ef="' + mhref + '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'' + idname + '\',\'\',\'' + msie + '\',1)"><img sr' + 'c="' + msir + '" alt="' + malt + '" border="0" name="' + idname + '"></a>';}
function M_hc(){return headcontent='\
<table width="100%" border=0 cellspacing=0 cellpadding=0>\
<tr><td id="headlt" rowspan="3"></td>\
<td id="headrt" colspan="11"><div id="ejf"><ul><li><a class="th" hr'+'ef="../index.html">English</a></li><li><a hr'+'ef="../big5/index.html">&#32321;&#39636;</a></li><li><a hr'+'ef="../gb/index.html">&#31616;&#20307;</a></li></ul></div><div style="clear:both"></div></td></tr><tr id="hedtr2" align="center">\
<td width="55">'+MM_omov("../product.htm","Image1","Products","../image/po.gif","../image/po1.gif")+'</td>\
<td width="17">|</td>\
<td width="41">'+MM_omov("../inquiry.php","Image2","Inquiry","../image/in.gif","../image/in1.gif")+'</td>\
<td width="17">|</td>\
<td width="71">'+MM_omov("../order/buy-resistor.htm","Image3","Order&nbsp;Form","../image/or.gif","../image/or1.gif")+'</td>\
<td width="17">|</td>\
<td width="39">'+MM_omov("../profile/token-profile.htm","Image5","Profile","../image/ab.gif","../image/ab1.gif")+'</td>\
<td width="17">|</td>\
<td width="34">'+egemail()+'</td>\
<td width="17">|</td>\
<td width="36">'+MM_omov("../index.html","Image7","Home","../image/home.gif","../image/home1.gif")+'</td>\
</tr><tr><td height="5" colspan="11"></td></tr></table>';}
window.onload=MM_preloadImages('../image/po1.gif','../image/in1.gif','../image/or1.gif','../image/ab1.gif','../image/email.gif','../image/home1.gif');