
var win= null;
function ShowWindow(name, url, width, height){
  var mypage, myname, w, h, scroll, resize
	mypage = '' + url;
  myname = name + '_popup';
  w = '' + width;
  h = '' + height;
  scroll = 'Yes';
  resize = 'Yes';
  var bw, bh
  var winl, wint
  if (document.all) {
    /* the following is only available after onLoad */
    bw = document.body.clientWidth;
    bh = document.body.clientHeight;
    winl = window.screenLeft + bw  / 2 - w / 2;
    wint = window.screenTop + bh / 2 - h / 2 - 40;
  }
  else if (document.layers) {
    bw = window.innerWidth;
    bh = window.innerHeight;
    winl = pageXOffset + bw / 2 - w / 2;
    wint = pageYOffset + bh / 2 - h / 2 - 40;
  }
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable='+resize;
  win=window.open(mypage,myname,settings);
  if (win.opener == null) win.opener = self;
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


function showHideSpan(target){
	if (document.getElementById(target).style.display=="")
		document.getElementById(target).style.display="none";
	else
		document.getElementById(target).style.display="";
}


function trim(strText) {
   return ltrim(rtrim(strText));
}

function ltrim(strText) { 
    
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);   
   
   return strText;
}

function rtrim(strText) { 	
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
        
   return strText;
}

function checkValidEmail(adr,dispWarning){
	
	var myAtSymbolAt = adr.indexOf('@');
	var myLastDotAt = adr.lastIndexOf('.');	
	var myLength = adr.length;
	
	
	if(myLength <1){
		if (dispWarning) alert("Email address is required!");
		return false;
	}

	if (myAtSymbolAt < 1 ){
		if (dispWarning) alert("Email address needs an '@' sign! Please correct this.");
		return false;
	}

	if (myLastDotAt < myAtSymbolAt){
		if (dispWarning) alert("Invalid email address! Please use format jane@doe.com.");
		return false;
	}

	if (myLength - myLastDotAt <= 2){
		if (dispWarning) alert("Invalid email address! Please use format jane@doe.com.");
		return false;
	}
	return true;
}



function addbookmark()
{
	bookmarkurl=""
	bookmarktitle="Imaging Technologies"
	if (document.all)
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function formatMoney(value) 
{
	result = "$"+Math.floor(value)+".";
	var cents = 100*(value-Math.floor(value))+0.5;
	result += Math.floor(cents/10);
	result += Math.floor(cents%10);
	return result;
}

function AddOther0(SelectBox)
{
	var OtherText;
	OtherText = prompt("Describe the OTHER option.","")
	if ((OtherText != "") && (OtherText != null))
	{
		SelectBox.options[SelectBox.options.length]=new Option(OtherText, "0");
		SelectBox.selectedIndex = SelectBox.options.length-1;
	}
	return true;
}

function AddOther(SelectBox)
{
	var OtherText;
	OtherText = prompt("Describe the OTHER option.","")
	if ((OtherText != "") && (OtherText != null))
	{
		SelectBox.options[SelectBox.options.length]=new Option(OtherText, OtherText);
		SelectBox.selectedIndex = SelectBox.options.length-1;
	}
	return true;
}

function newWindow(URL, width, height)
{
	window.open(URL, "Sub", "scrollbars=no,width=" + width + ",height=" + height + ",menubar=no,toolbar=no,titlebar=no,status=no");
	return false;
}


var newwin;

function launchwin (winurl,winname,winfeatures)
{
newwin = window.open(winurl,winname,winfeatures);
}


function newScrollWindow(URL, width, height)
{
	window.open(URL, "Sub", "scrollbars=yes,width=" + width + ",height=" + height + ",menubar=no,toolbar=no,titlebar=no,status=no");
	return true;
}

function newScrollWindow2(URL, width, height)
{
	
	var d;
	d = new Date();
	window.open(URL, "Sub" + d.getSeconds(), "scrollbars=yes,width=" + width + ",height=" + height + ",menubar=no,toolbar=no,titlebar=no,status=no");
	return true;
}

function toggle_display(img, block)
{
	var imgSrc = String(img.src);
	if (imgSrc.indexOf("/media/icons/plus.gif") != -1)
	{
		block.style.display = "block";
		img.src = "/media/icons/minus.gif";
	}
	else
	{
		block.style.display = "none";
		img.src = "/media/icons/plus.gif";
	}
}



