 function doEmailTagInsert(tagValue, target)
 { 
	var TagValue = document.getElementById(tagValue);
	for( var i=0; i < TagValue.options.length; i++ ){
		if (TagValue.options[i].selected){
			if (document.getElementById(target).value == ""){
				document.getElementById(target).value += "["+TagValue.options[i].value+"]";
			} else {
				document.getElementById(target).value += ",["+TagValue.options[i].value+"]";
			}
		}
	}
} 

function clickButton(e, buttonid)
{ 
	var bt = document.getElementById(buttonid); 
	if (typeof bt == 'object')
	{ 
		if(navigator.appName.indexOf("Netscape")>(-1))
		{ 
			if (e.keyCode == 13)
			{ 
				bt.click(); return false; 
			} 
		} 
		if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		{ 
			if (event.keyCode == 13)
			{ bt.click(); return false; } 
		} 
	}
} 

 function doTagInsert(tagValue, target)
 { 
	var TagValue = document.getElementById(tagValue);
	for( var i=0; i < TagValue.options.length; i++ ){
		if (TagValue.options[i].selected){
				document.getElementById(target).value += " ["+TagValue.options[i].value+"] ";
		}
	}
} 

function confirm_Archive()
{
if (confirm("Are you sure you want to archive this campaign?\n\nDoing so will prevent users from taking your survey,\nand you will NOT have any way to reactivate it. However,\nyour reporting will still be available.")==true)
	return true;
else
	return false;
}

function confirm_MassiveDelete()
{
if (confirm("Are you sure you want to delete this campaign?\n\nDoing so will DELETE ALL of the data below it, including \nall of the lists, surveys, questions, and survey\nresponses.\n\nNo reports will be available for this campaign and\nyou will NOT be able to recover any of this data after\nyou delete it.\n\nClick 'OK' to continue.")==true)
	return true;
else
	return false;
}

function confirm_delete()
{
if (confirm("Are you sure you want to delete this item?")==true)
	return true;
else
	return false;
}

function confirm_ControlDelete()
{
if (confirm("Are you sure you want to delete this control?\n\nAll instances of this control on any pages throughout the website will be permanently deleted.")==true)
	return true;
else
	return false;
}

function confirm_sendnewsletter()
{
if (confirm("Are you sure you want to send this newsletter?")==true)
	return true;
else
	return false;
}

function confirm_deactivate()
{
if (confirm("Are you sure you want to deactivate this item?")==true)
	return true;
else
	return false;
}

function confirm_deleteJobOpeningType()
{
if (confirm("Are you sure you want to delete this item?\nBy removing this item, you will be removing all\njob openings assigned to this type.")==true)
	return true;
else
	return false;
}

function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}else{
		document.getElementById(field.id+"_maxChar").value = maxlimit - field.value.length;
	}
} 


function OpenWin( location )
{

  var ieDHTML = document.all !=null;
  var nsDHTML = document.layers;

  if (ieDHTML) {
    var xWidth = document.body.clientWidth;
    var yHeight = document.body.clientHeight;
  }
  if (nsDHTML) {
    var xWidth = window.innerWidth;
    var yHeight = window.innerHeight;
  }

  if (xWidth >= 1000) {
    xWidth = 800;
  } else if (xWidth >= 800) {
    xWidth = 750;
  } else {
    xWidth = 650;
  }

  if (yHeight >= 1000) {
    yHeight = 900;
  } else if (yHeight >= 750) {
    yHeight = 700;
  } else {
    yHeight = 600;
  }
  if (window.name == "popup") {
    if (ieDHTML) {
      window.open(location, "newPopup",
        "width=" + xWidth +",height=" + yHeight +",toolbar=no,status=no,menubar=no,top=60,left=135,scrollbars=yes,resizable=yes");
    } else {
      window.open(location, 'newPopup',
        'menubar=yes,scrollbars=yes,toolbar=yes,status=yes,width=' + xWidth + ',height=' + yHeight +',top=60,left=135');
    }
  } else {
    if (ieDHTML) {
      window.open(location, "popup",
        "width=" + xWidth +",height=" + yHeight +",toolbar=no,status=no,menubar=no,top=45,left=120,scrollbars=yes,resizable=yes");

    } else {
      window.open(location, 'popup',
        'width=' + xWidth + ',height=' + yHeight +',menubar=no,toolbar=no,scrollbars=no,status=no,top=45,left=120');
    }
  }
}
<!-- Used by the SetDefaultButton Function -->
function fnTrapKD(btn, event)
{
	if (document.all){
		if (event.keyCode == 13){
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
	else if (document.getElementById){
		if (event.which == 13){
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
	else if(document.layers){
		if(event.which == 13){
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
}

//Function to count text remaining
function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}else{
		document.getElementById(field.id+"_maxChar").value = maxlimit - field.value.length;
	}
} 

//Function to Show/Hide layer based on the style of the layer
function showHideLayers(LayerName, imageOpen, imageClose) {
    var myLayer = document.getElementById(LayerName);
    var imageOpen = document.getElementById(imageOpen);    
    var imageClose = document.getElementById(imageClose);
       
    if (myLayer.style.display == "none"){
        myLayer.style.display = "inline";
        imageOpen.style.display = "none";
        imageClose.style.display = "inline";
    }
    else {
        myLayer.style.display = "none";
        imageOpen.style.display = "inline";
        imageClose.style.display = "none";
    }
}

function FormatPhone(textField)
{
    var PhoneField = document.getElementById(textField);
    var num = PhoneField.value
        
    var re= /\D/;
    // test for this format: (xxx)xxx-xxxx
    var re2 = /^\({1}\d{3}\)\d{3}-\d{4}/; 
    // test for this format: xxx-xxx-xxxx
    //var re2 = /^\d{3}-\d{3}-\d{4}/;
    
   
    var newNum;
    if (num != "" && re2.test(num)!=true){
        if (num != ""){
            while (re.test(num)){
                num = num.replace(re,"");
        }
    }

    if (num.length != 10){
        //alert('Please enter a 10 digit phone number');
        //eval(PhoneField).select();
    }
    else {
     // for format (xxx)xxx-xxxx
     newNum = '(' + num.substring(0,3) + ') ' + num.substring(3,6) + '-' + num.substring(6,10);
     eval(PhoneField).value=newNum;
     }
  }
}

function formatCurrency(textField) 
{
    var CurrencyField = document.getElementById(textField);
    var num = CurrencyField.value
    num = num.toString().replace(/\$|\,/g,'');
   
    if(isNaN(num))
        num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+
        num.substring(num.length-(4*i+3));
    
    eval(CurrencyField).value = (((sign)?'':'-') + '$' + num + '.' + cents);
}

var HoldRowColor;
function setMouseOverColor(element) {
	HoldRowColor = element.style.backgroundColor;
    element.style.backgroundColor='#D4D8D2';
    element.style.Color='#D4D8D2';
}

function setMouseOverColorWithGivenColor(element, passedcolor) {
	HoldRowColor = element.style.backgroundColor;
    element.style.backgroundColor=passedcolor;
    element.style.Color=passedcolor;
}

function setMouseOutColor(element) {
	// = element.style.backgroundColor;
	element.style.backgroundColor= HoldRowColor;
//	element.style.textDecoration='normal'; 

}	

//Show Popup when hovering over an item
function ShowPopup(hoveritem, clientID)
{
hp = document.getElementById(clientID);

// Set position of hover-over popup
var coords = findPos(hoveritem)
hp.style.top = coords[1] + 50 + 'px';
hp.style.left = coords[0] + 10 + 'px';

// Set popup to visible
hp.style.visibility = "Visible";
}

function HidePopup(clientID)
{
hp = document.getElementById(clientID);
hp.style.visibility = "Hidden";
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
//--------------------------------------------------------------------------------
//Function to Show / Hide DivElement to popup at a fixed place 

function ShowPopupAtStaticPos(hoveritem, clientID)
{
divelement = document.getElementById(clientID);
// Set popup to visible
divelement.style.visibility = "Visible";
}
function HidePopupAtStaticPos(clientID)
{
divelement = document.getElementById(clientID);
divelement.style.visibility = "Hidden";
}


function IncreaseSize(obj, size)
{

    cnt = 0;
    
    while(cnt <= size)
    {
        obj.width++;
        obj.height++;
        cnt++;
    }
}

function DecreaseSize(obj, size)
{
    
    while(size >=0)
    {
        obj.width--;
        obj.height--;
        size--;
    }
}

function ClearTextBox(textField, textValue){
var Field = document.getElementById(textField);
if (Field.value  == textValue){
   Field.value  = "";    
  }
} 

function OpenMovieWindow(myURL)
{
	myleftVal = (screen.width - 570 ) / 2;
	mytopVal = (screen.height - 435) / 2;

	window.open(myURL,"mywindow","resizable=yes,left=" + myleftVal + ",top=" + mytopVal + ",status=1,scrollbars=0,width=570,height=435");
}

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_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_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_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];}
}

//For refrence, needed to be also declared in image rotator, ???
function getRandomNumberRange(minimum, maximum) {
    return Math.floor((maximum-minimum) * Math.random()) + (minimum + 1);
}


