function showHelp(OptionId,Type) {
	mywindow=open('/inc/admin_help.asp?HelpType='+Type+'&OptionId='+OptionId,'helpWindow','scrollbars=yes,resizable=yes,width=800,height=350');
	mywindow.location.href = '/inc/admin_help.asp?HelpType='+Type+'&OptionId='+OptionId;
	if (mywindow.opener == null) {
		mywindow.opener = self;
	}
	mywindow.focus();
}

/* Check filename function*/
function checkFilename(theField) {
  blnPass = true;
  strValue = theField.value;
  for(i=0; i<theField.value.length; i++){
	if ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_".indexOf(theField.value.charAt(i),0) == -1) {
		//alert(theField.value.charAt(i));
	 	if(theField.value.charAt(i) == ' ')
			strValue = strValue.replace(theField.value.charAt(i),'_');
		else
			strValue = strValue.replace(theField.value.charAt(i),'');
		blnPass = false;
	}
  }
  theField.value = strValue;
  if (!blnPass) {
	alert("A file must be only alpha or numeric characters. \nThe file has been automatically updated.") ;
	return false ;
  }
  return true ;
}

function toggle(showthis,hidethis){
	document.getElementById(showthis).style.display = '';
	document.getElementById(hidethis).style.display = 'none';
}

function showHide(theElement){
	if (document.getElementById(theElement).style.display == '')
		document.getElementById(theElement).style.display = 'none';
	else
		document.getElementById(theElement).style.display = '';
}

/* Validation function for purchase form mainly used for options */
function ValidateBuyForm(theForm) {
	var radioChecked, strClass, radioValue;
	for(i=0; i<theForm.elements.length; i++) {
		strId = theForm.elements[i].id.substring(0, 8);
		if (strId == 'Required') {
			if (theForm.elements[i].type == 'radio' || theForm.elements[i].type == 'checkbox') {
				radioObject = theForm.elements[i];
				radioChecked = false;
				for(r=0;r<radioObject.length; r++){
					if (radioObject[r].checked)
						radioChecked = true;
				}
				if (!radioChecked) {
					alert('Please check an option for ' + theForm.elements[i].id.substring(8) + '.');
					theForm.elements[i].className = 'FlashBG';
					return false;
				}
			}
			else if (theForm.elements[i].type == 'select-one') {
				if (theForm.elements[i].selectedIndex == 0) {
					alert('Please select a value for ' + theForm.elements[i].id.substring(8) + '.');
					return false;
				}
			}
			else {
				if (theForm.elements[i].value == '') {
					alert('Please fill in a value for ' + theForm.elements[i].id.substring(8) + '.');
					return false;
				}
			}
		}
	}
}
/* Generic check checkbox function*/
function selectCheckbox(strID) {
	document.getElementById(strID).checked = true;
}

/* Generic check email function*/
function checkEmail(emailAddy) {
  if (emailAddy.value.length==0)
  {
    return true ;
  }
  if (emailAddy.value.indexOf("@",0) < 1 || emailAddy.value.indexOf(".",0) < 1)
  {
    alert("Please check the field:\n The email address appears incorrectly formed") ;
    emailAddy.focus() ;
	return false ;
  }
  return true ;
}

function nospam(user,domain,suffix) {
	document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}

/* Function to check if year is valid ie. Initial value of "Year" or otherwise it must be a   numeric. Don't worry if the person believes they are a few centuries old! */
function checkYear(numberField) {
  allNumeric=true ;
  if (numberField.value.length==0 || numberField.value=="Year")
  {
    return true ;
  }

  for (i=0 ; i<numberField.value.length ; i++)  {    checkChar=numberField.value.charAt(i) ;
    if (checkChar<'0' || checkChar>'9')
	{
	  allNumeric=false ;
	}  
  }
  
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only numbers permitted");
	numberField.focus() ;
	return false ;
  }
  
  return true ;
}

/* generic check for number(ie 0-9) */
function checkNumber(numberField) {
  allNumeric=true ;
  if (numberField.value.length==0)
  {
    return true ;
  }

  for (i=0 ; i<numberField.value.length ; i++)  {    checkChar=numberField.value.charAt(i) ;
    if (checkChar<'0' || checkChar>'9')
	{
	  allNumeric=false ;
	}  
  }
  
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only numbers permitted");
	numberField.value = "";
	numberField.focus(numberField);
	return false ;
  }
  return true ;
}

/* generic phone number checker allowing brackets for prefix */
function checkPhone(phoneField) {
  allNumeric=true ;
  if (phoneField.value.length==0)
  {
    return true ;
  }
  
  for (i=0 ; i<phoneField.value.length ; i++)  {    checkChar=phoneField.value.charAt(i) ;
    if (checkChar!=' ' && checkChar!='\(' && checkChar!='\)'  && (checkChar<'0' || checkChar>'9') )
	{
	  allNumeric=false ;
	}  
  }
  
  if (allNumeric==false)
  {
    alert("Please check the field:\n Only numbers, spaces and \(\) permitted");
	phoneField.focus() ;
	return false ;
  }
  return true ;
}

//confirm delete message
function confirmDelete(theMessage,theDirect) {
  if( confirm(theMessage) ) {
    canClose = false;
 	document.location.replace(theDirect);
  }
}

function myfunc()
{
	document.location.href=document.fmSearch.strSearchType.options[document.fmSearch.strSearchType.selectedIndex].value + "?strKeyword=" + document.fmSearch.strKeyword.value;
	return false;
}

function activate(showthis, iconshow, iconhide){
		if (document.getElementById(showthis).style.display == '')
			document.getElementById(showthis).style.display = 'none';
		else
			document.getElementById(showthis).style.display = '';
			
		if (iconshow != null){
			document.getElementById(iconshow).style.display = '';
			document.getElementById(iconhide).style.display = 'none';
		}
	}
	function initialise(hidethis, display){
		if (display == 'hide'){
			//alert(hidethis);
			document.getElementById(hidethis).style.display = 'none';
		}
		if (display == 'show'){
			//alert(hidethis);
			document.getElementById(hidethis).style.display = '';
		}
	}

//function used for currency change
function menudirect(curchange){
var URL = document.curchange.currencyid.options[document.curchange.currencyid.selectedIndex].value;
window.location.href = URL;
}

function killAutofill(){
  is = document.getElementsByTagName("INPUT");
  for(i=0;i<is.length;i++)
    is[i].style.backgroundColor = "";
  ss = document.getElementsByTagName("SELECT");
  for(i=0;i<ss.length;i++)
    ss[i].style.backgroundColor = "";
}

//Newsletter subscribe form
function focusName(element) {
  if (element.value == " name...") {
    element.value = "";
  }
}

function blurName(element) {
  if (element.value == "") {
    element.value = " name...";
  }
}

function focusEmail(element) {
  if (element.value == " email...") {
    element.value = "";
  }
}

function blurEmail(element) {
  if (element.value == "") {
    element.value = " email...";
  }
}

function checkName(str)
{
        var vname = str
		if (vname == " name...")
             return false;
        if (vname == "")
             return false;
        return true;
}
function checkEmailF(str)
{
        var apos = str.indexOf("@");
        var dpos = str.indexOf(".");
        var epos = str.indexOf("]");
        var fpos = str.indexOf("[");     
        if (apos<=0 || dpos<=0 || epos>0 || fpos>0 )
             return false;
        if (dpos+1>=str.length)
             return false;
        return true;
}
function ValidateForm()
{
        if (!checkName(document.theForm.name.value)){
                alert("Please enter your first name.");
                return false;
        }
		if (!checkEmailF(document.theForm.email.value)){
                alert("Please enter a valid email address.");
                return false;
        }
	return true;
}

//netscape css fix

function WM_netscapeCssFix() {
   if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn()

//popup windows for references

function popupWindow(referenceHTML, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	windowProperties = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable'
	reference = window.open(referenceHTML, 'refName', windowProperties)
	if (parseInt(navigator.appVersion) >= 4) { reference.window.focus(); }
}

function overture()
{
  var OpenWindow=window.open('http://inventory.overture.com/d/searchinventory/suggestion/', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=320, height=480');
}  
  
function google()
{
  var OpenWindow=window.open('https://adwords.google.com/select/KeywordToolExternal', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=600');
}  