function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function pop_productdetails(url)
{
	newwindow=window.open(url,'pdetails','height=500,width=470');
	if (window.focus) {newwindow.focus()}
	return false;
}

function pop_image(ur,he,wi)
{
	newwindow=window.open(ur,'pimage','height='+he+',width='+wi);
	if (window.focus) {newwindow.focus()}
	return false;
}

function pop_checkstock(url)
{
	newwindow=window.open(url,'cstock','height=190,width=290');
	if (window.focus) {newwindow.focus()}
	return false;
}

function pop_glossary(url)
{
	newwindow=window.open(url,'gloss','height=300,width=350,scrollbars=auto');
	if (window.focus) {newwindow.focus()}
	return false;
}

function none() {}

function em(email, inline) {

	find = new Array()
	replace = new Array()
	
	find[0] 	= "\\s*\\[\\s*dot\\s*\\]\\s*"
	replace[0] 	= '.'
	find[1] 	= "\\s*\\[\\s*at\\s*\\]\\s*"
	replace[1] 	= '@'

	for ( i = 0; i < find.length; i++ ) {
		eval("regexp = /" + find[i] + "/ig")
		email = email.replace(regexp, replace[i])
	}
	
	if(inline)
		return email
	else {
		if ( email.indexOf('mailto') < 0 ) 
			email = 'mailto:'  + email
		location.href = email
	}
}
			
			//onclick=\"return confirmSubmit('Are you sure you wish to pay selected commissions?');\"
function confirmSubmit(msg){
  
  var agree=confirm(msg);
  if (agree)
  	return true ;
  else
  	return false ;
}

function Get_Cookie( name ) {
  	
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) &&
  ( name != document.cookie.substring( 0, name.length ) ) )
  {
  return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

// menu

<!--//--><![CDATA[//><!--

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//--><!]]>


///////////////////////////////////////////

/// PRECARGA IMG dreamweaver
<!--
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];}}
}
//-->


//over riga
function overRIGA ()
{
	if (document.getElementById && document.createTextNode)
	{
		var tables=document.getElementsByTagName('table');
		for (var i=0;i<tables.length;i++)
		{
			if(tables[i].className=='grid')
			{
				var trs=tables[i].getElementsByTagName('tr');
			
				
				for(var j=0;j<trs.length;j++)
				{
					if(trs[j].parentNode.nodeName=='TBODY')
					{
						/*if(trs[j].className=='riga-a')
						{
							trs[j].onmouseover=function(){this.className='riga-o';return false}
							trs[j].onmouseout=function(){this.className='riga-a';return false}	
							trs[j].onclick=function(){this.className='riga-sel';return false}	
						}*/						
						/*if(trs[j].className=='riga-b')
						{
							trs[j].onmouseover=function(){this.className='riga-o';return false}
							trs[j].onmouseout=function(){this.className='riga-b';return false}
							trs[j].onclick=function(){this.className='riga-sel';return false}
						}*/	
						if(trs[j].className=='riga-a')
						{
							trs[j].onmouseover=function()
							{
								if (this.className!='riga-sel-a')
								{
									this.className='riga-o';
									return false
								}
							}
							trs[j].onmouseout=function()
							{
								if (this.className!='riga-sel-a')
								{								
									this.className='riga-a';
									return false
								}
							}
							/*
							trs[j].onclick=function()
							{
								if (this.className=='riga-sel-a')
								{								
									this.className='riga-a';
									return false
								}
								else 
								{
									this.className='riga-sel-a';
									return false
								}
							}
							*/
						}						
						if(trs[j].className=='riga-b')
						{
							trs[j].onmouseover=function()
							{
								if (this.className!='riga-sel-b')
								{
									this.className='riga-o';
									return false
								}
							}
							trs[j].onmouseout=function()
							{
								if (this.className!='riga-sel-b')
								{								
									this.className='riga-b';
									return false
								}
							}
							/*
							trs[j].onclick=function()
							{
								if (this.className=='riga-sel-b')
								{								
									this.className='riga-b';
									return false
								}
								else 
								{
									this.className='riga-sel-b';
									return false
								}
							}
							*/
						}	
					}
				}
			}
		}
	}
}
/*********************************/
//over CAMPO
function overINPUT()
{
	if (document.getElementById && document.createTextNode)
	{
		var inputs=document.getElementsByTagName('input');
		for (var i=0;i<inputs.length;i++)
		{
			if(inputs[i].className=='campo')
			{
				inputs[i].onfocus=function(){
						this.className='campo-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo';
						return false
					}		
			}
			if(inputs[i].className=='campo02')
			{
				inputs[i].onfocus=function(){
						this.className='campo02-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo02';
						return false
					}		
			}			
		}
	}
}
function overTEXTAREA()
{
	if (document.getElementById && document.createTextNode)
	{
		var inputs=document.getElementsByTagName('textarea');
		for (var i=0;i<inputs.length;i++)
		{
			if(inputs[i].className=='campo')
			{
				inputs[i].onfocus=function(){
						this.className='campo-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo';
						return false
					}		
			}
			if(inputs[i].className=='campo02')
			{
				inputs[i].onfocus=function(){
						this.className='campo02-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo02';
						return false
					}		
			}			
		}
	}
}
function overSELECT()
{
	if (document.getElementById && document.createTextNode)
	{
		var inputs=document.getElementsByTagName('select');
		for (var i=0;i<inputs.length;i++)
		{
			if(inputs[i].className=='campo')
			{
				inputs[i].onfocus=function(){
						this.className='campo-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo';
						return false
					}		
			}
			if(inputs[i].className=='campo02')
			{
				inputs[i].onfocus=function(){
						this.className='campo02-foc';
						return false
					}
				inputs[i].onblur=function(){
						this.className='campo02';
						return false
					}		
			}			
		}
	}
}
/****************************/
/****************** ROLLOVER ****************/
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
function overEvents ()
{
	//overITEM();
	initRollovers();
	overRIGA();
	overINPUT();
	overSELECT();
	overTEXTAREA();
	//overMENU();
}

window.onload=function()
{
	overEvents();
} 

function em(email, inline) {

	find = new Array()
	replace = new Array()
	
	find[0] 	= "\\s*\\[\\s*dot\\s*\\]\\s*"
	replace[0] 	= '.'
	find[1] 	= "\\s*\\[\\s*at\\s*\\]\\s*"
	replace[1] 	= '@'

	for ( i = 0; i < find.length; i++ ) {
		eval("regexp = /" + find[i] + "/ig")
		email = email.replace(regexp, replace[i])
	}
	
	if(inline)
		return email
	else {
		if ( email.indexOf('mailto') < 0 ) 
			email = 'mailto:'  + email
		location.href = email
	}
}


function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    var form     = document.forms['products_search1'];
    var word = form.key.value;
    qstr = 'key=' + escape(word);  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str){
    document.getElementById("result").innerHTML = str;
}
