function makeArray(n) {
   for (var i = 1; i <= n; i++) {
	  this[i] = 0
   }
   return this
}

function isEmpty(s)
{	return ((s == null) || (s.length == 0))
}

function isDigit (c)
{	return ((c >= "0") && (c <= "9"))
}

function isInteger (s)
{
	
	var i;
	if (isEmpty(s))
	   if (isInteger.arguments.length == 1) return defaultEmptyOK;
	   else return (isInteger.arguments[1] == true);

	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}

	return true;
}

function isFloat (theField, decimalPlaces, acceptComma, maxVal)
{
	if (isFloat.arguments.length == 3) maxVal = -1;

	var i;
	var seenDecimalPoint = false;
	var s;
	s = theField.value;

	if (isEmpty(s)) {
		return defaultEmptyOK;
	}

	//if (s == ".") return false;

	var decimalCount = 0;

	for (i = 0; i < s.length; i++)
	{
		// Check that current character is number.
		var c = s.charAt(i);

		if (seenDecimalPoint) {
			decimalCount++;
		}

		if ((c == ".") && !seenDecimalPoint) seenDecimalPoint = true;
		else if ((acceptComma) && (!seenDecimalPoint) && (c == ",")) {
		} else if ((!isDigit(c)) || (decimalPlaces >0) && (decimalCount > decimalPlaces)) {
			theField.value = "";
			theField.focus();
			theField.select();
            if ((decimalPlaces >0) && (decimalCount > decimalPlaces)) {
                alert(COM_EVV_mes0 + decimalPlaces + "!");
            } else {
			    alert(COM_EVV_mes1);
            }
			return false;
		}
	}

    if (maxVal > -1) {
        if (s > maxVal) {
			theField.value = "";
			theField.focus();
			theField.select();
			alert(COM_EVV_mes2 + maxVal + "!");
			return false;
        }
    }

	//return true;
}
 

  function img_on(imgName) {
  if (capable) {
  imgOn = eval(imgName + "_on.src")
  document [imgName].src = imgOn
  }
  }

  function img_off(imgName) {
  if (capable) {
  imgOff = eval(imgName + "_off.src")
  document [imgName].src = imgOff
  }
  }

  function chng_MarkerButton(imgName) {
  if (capable) {
  chngMarkerButton = eval(imgName + "_selected.src")
  // document.MarkerButton.src = chngMarkerButton
  document.MarkerButton.src = chngMarkerButton
  }
  }

  function updateMarkerButton() {
  var tmp;

  tmp = QueryString('mb')
  if (tmp != '') {
  chng_MarkerButton(tmp)
  }
  }

  function QueryString( param )
  {
  var begin,end;
  if(self.location.search.length>1)
  {
    begin=self.location.search.indexOf(param) +param.length+1;
    end=self.location.search.indexOf("&",begin);
    if(end==(-1)) end=self.location.search.length;
    return(self.location.search.substring(begin,end));
  }
  else if(self.location.hash.length>1)
  {
    begin=self.location.hash.indexOf(param) +param.length+1;
    end=self.location.hash.indexOf("&",begin);
    if(end==(-1)) end=self.location.hash.length;
    return(self.location.hash.substring(begin,end));
  }
  else return("");
  }

  var windowJP=0;
  var windowSX=0;
    function handler()
    {
  windowSX=window.open('','chsx1','top=75,left=100,width=795,height=455,toolbar=yes,status=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes');
            windowSX.focus();        
        if (windowSX.history.length==0){
                windowSX.location.href="http://catalog.ch.cutler-hammer.com/sx/.actraApp?dosu=Extranet";
        windowSX.focus();
        return windowSX;
        }
        else {
            windowSX.focus();
            return windowSX;
        }
    
    windowSX.focus();
    return windowSX;        
    
    }//end function
  function openWindow(aURL, aTitle, winWidth, winHeight, resize, scrollbar, menubar, statusbar, locationbar, toolbar, directories) {
    if (navigator.appName == "Netscape") {
        if (winWidth == null)
            winWidth = top.window.outerWidth;
        if (winHeight == null)
            winHeight = top.window.outerHeight;
        widthFeature = "outerWidth=";
        heightFeature = ",outerHeight=";
    } else {
        widthFeature = "width=";
        heightFeature = ",height=";
        if (winWidth == null) {
            winWidth = "";
            widthFeature = "";
        }
        if (winHeight == null) {
            winHeight = "";
            heightFeature = "";
        }
    }

    maxWidth = screen.availWidth;
    maxHeight = screen.availHeight;

    width = ((winWidth > maxWidth) ? maxWidth : winWidth);
    height = ((winHeight > maxHeight) ? maxHeight : winHeight);

    if (width == "") {
        xOffset = "";
        yOffset = "";
    } else {
        xOffset = ",left=" + Math.floor((maxWidth - width)/2);
        yOffset = ",top=" + Math.floor((maxHeight - height)/2);
    }

    windowDef = widthFeature + width +
                    heightFeature + height +
                    ",resizable=" + ((resize != null) ? resize : 1) +
                    ",scrollbars=" + ((scrollbar != null) ? scrollbar : 1) +
                    ",menubar=" + ((menubar != null) ? menubar : 1) +
                    ",status=" + ((statusbar != null) ? statusbar : 1) +
                    ",location=" + ((locationbar != null) ? locationbar : 1) +
                    ",toolbar=" + ((toolbar != null) ? toolbar : 1) +
                    ",directories=" + ((directories != null) ? directories : 1) +
                    xOffset +
                    yOffset;

    openWindowWin = window.open(aURL, aTitle, windowDef);
    openWindowWin.focus();
    return openWindowWin;
  }

  var sellerXWin = "0";
  function openSellerX () {
         
    if ( (sellerXWin == 0) || (windowSX.closed) ) {
        sellerXWin = handler();//openWindow("http://catalog.ch.cutler-hammer.com/sx/.actraApp?dosu=Extranet", "chsx1", 800, 600);
    }
    sellerXWin.focus();
  }



function openSellerXProduct (productURL) {
	if ( (sellerXWin == 0) || (sellerXWin.closed) ) {
		sellerXWin = openWindow(productURL, "chsx1", "800, 600");
	}
	else {open_window(productURL,"chsx1", 800, 600) }
	sellerXWin.focus();
}

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.0
  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 && document.getElementById) x=document.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];}
}



// This function is used to submit forms to the Stellent WCM Email Component
function emailFormOnSubmit(form)
{
	// Capture values of important hidden variables
	var baseRedirect = form.elements['baseRedirect'].value;
	var baseString = form.elements['baseString'].value;
	var tempReport = baseString;
	var sendEmail = form.elements['checkbox1'].checked;

	// Capture form elements we want to work with
	var currURL = form.elements['currURL'];
	var report = form.elements['report'];
	var emailaddress = form.elements['emailaddress'];
	var companyname = form.elements['companyname'];
	var strLocation = form.elements['location'];
	var phone = form.elements['phonenum'];
	var comment = form.elements['comment'];

	// Determine if they want to send the email or just complete participation
	var sendEmail = form.checkbox1.checked;
	if (!sendEmail)
	{
		window.location.href = baseRedirect + "&emailSent=N";
		return false;
	}

	if (emailaddress != null && emailaddress.value != null)
	{		
		tempReport += "Customer E-mail: " + emailaddress.value + "<br />";
		currURL.value = baseRedirect + "&emailSent=" + emailaddress.value;
	}

	if (companyname != null && companyname.value != null)
	{
		tempReport += "Company: " + companyname.value + "<br />";
	}

	if (strLocation != null && strLocation.value != null)
	{
		tempReport += "Location: " + strLocation.value + "<br />";
	}

	if (phone != null && phone.value != null)
	{
		tempReport += "Phone: " + phone.value + "<br />";
	}

	if (comment != null && comment.value != null)
	{
		tempReport += "Comment: " + comment.value + "<br />";
	}
	report.value = tempReport;
	return true;
}