
///////////////////////////////////////////////////
function fnGotoURL(sURL){
	document.location.href = sURL;
}

function fnCookiesEnabled(){
	var acceptsCookies = false; 
	if(document.cookie == '') { 
	    document.cookie = 'acceptsCookies=yes'; // Try to set a cookie. 
	    if(document.cookie.indexof('acceptsCookies=yes') != -1) { 
	        acceptsCookies = true; 
	    }// If it succeeds, set variable
	} else { // there was already a cookie 
	  acceptsCookies = true; 
	}
	return acceptsCookies;
}

function fnValidateKeyPress(t){
	t.value = t.value.replace(/[^0-9]/g, '');
}

function fnPopupWindow(sURL){
	window.open (sURL, "", "scrollbars=yes,resizable=yes,toolbar=no,directories=no");
	return false;
}

function fnPopupMovie(sURL){
	window.open (sURL, "", "scrollbars=yes,resizable=yes,toolbar=no,directories=no,width=400,height=400");
	return false;
}

function fnValidateEmail(eMail) { 
	return /(\S+@\S+\.\S+)/.test(eMail); 
}

function fnValidateKeyPressChar(t){
	t.value = t.value.replace('\'', '');
}

function fnCleanFormValue(s){
	return s.replace (/[=\|\;\'\"\\\/]/g, "_");
}

function fnPopulateSelectFromArray(eleName, aData, sSelectedValue){

  // If using select replace, then divert processing to custom procedure
  if (fUsingSelectReplaceYN = true){
    fnSR_PopulateSelectReplaceFromArray(eleName, aData, sSelectedValue);
    return true;
  }

	var ele = document.getElementById(eleName);
	var sValue = "";
	var sDisplay = "";
	
	// Delete all existing options
	ele.options.length = 0;
						
	// Create options from specified array
	for (var i = 0; i < aData.length; i++){
	  sValue = aData[i] [0];
	  sDisplay = aData[i] [1];
	  ele.options[i] = new Option(sDisplay, sValue);
	  if (sSelectedValue == sValue){
	  	ele.options[i].selected = true;
	  }
  } 
	
}

function fnChangeSelectControlStatus(eleName, fDisableYN){
  if (fUsingSelectReplaceYN = true){
    fnSR_ChangeSelectControlStatus(eleName, fDisableYN);
  }else{
	  fnChangeControlStatus(eleName, fDisableYN);
	}
}

function fnChangeControlStatus(eleName, fDisableYN){
  document.getElementById(eleName).disabled = fDisableYN;
}

function fnSetElementText(ele, sText){
  if (ele.value.length == 0){
    ele.value = sText;
  }
}
function Mid(str, start, len)
{
  // Make sure start and len are within proper bounds
  if (start < 0 || len < 0) return "";
  var iEnd, iLen = String(str).length;
  if (start + len > iLen)
        iEnd = iLen;
  else
        iEnd = start + len;
  return String(str).substring(start,iEnd);
}

function fnToolTips(){
  $$('a.a-row').each(function(element){
    if (element.rel.length != 0){
      new Tip(element, element.rel,{className: 'nowhere'});
      element.rel = "";
    }
  });
  $$('img').each(function(element){
    if (element.title.length != 0){
      new Tip(element, element.title);
      element.title = "";
    }
  });
  $$('area').each(function(element){
    if (element.title.length != 0){
      new Tip(element, element.title);
      element.title = "";
    }
  });
  $$('a').each(function(element){
    if (element.title.length != 0){
      new Tip(element, element.title);
      element.title = "";
    }
  });
  $$('span').each(function(element){
    if (element.title.length != 0){
      new Tip(element, element.title);
      element.title = "";
    }
  });
  $$('input').each(function(element){
    if (element.title.length != 0){
      new Tip(element, element.title);
      element.title = "";
    }
  });
  
}

function isFormDirtyYN(oForm)
{
	var el, opt, hasDefault, i = 0, j;
	while (el = oForm.elements[i++]) {
		switch (el.type) {
			case 'text' :
                   	case 'textarea' :
                   	case 'hidden' :
                         	if (!/^\s*$/.test(el.value) && el.value != el.defaultValue) return true;
                         	break;
                   	case 'checkbox' :
                   	case 'radio' :
                         	if (el.checked != el.defaultChecked) return true;
                         	break;
                   	case 'select-one' :
                   	case 'select-multiple' :
                         	j = 0, hasDefault = false;
                         	while (opt = el.options[j++])
                                	if (opt.defaultSelected) hasDefault = true;
                         	j = hasDefault ? 0 : 1;
                         	while (opt = el.options[j++]) 
                                	if (opt.selected != opt.defaultSelected) return true;
                         	break;
		}
	}
	return false;
}

function fnShowSlideshow(
  sPathToSWF,
  sSlideshowID,
  sWidth,
  sHeight,
  sVersion,
  oFlashVars,
  oParams,
  oAttributes ){

  // If IE7 then write out specific markup
  var fIE7YN = (Prototype.Browser.IE);
  if(fIE7YN){
    // Replace fall-back markup with Object tag + classid
    var sBuffer = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + sWidth + 
      '" height="' + sHeight + '" id="' + sSlideshowID + '">' + 
      '<param name="movie" value="' + sPathToSWF + '" />';
    for (var oProp in oParams){
      sBuffer += '<param name="' + oProp + '" value="' + oParams[oProp] + '">';
    }
     sBuffer += '<param name="flashvars" value="file=' + oFlashVars.file + '">';  
    Element.replace(sSlideshowID, sBuffer);
  }else{
    // Call SWFObject
    swfobject.embedSWF( 
      sPathToSWF, 
      sSlideshowID, 
      sWidth, 
      sHeight, 
      sVersion, 
      '/include/expressInstall.swf', 
      oFlashVars, 
      oParams, 
      oAttributes
    );
  }

}

function fnShowGallery(
  sPathToSWF,
  sGalleryID,
  sWidth,
  sHeight,
  sVersion,
  oFlashVars,
  oParams,
  oAttributes ){

  // If IE7 then write out specific markup
  var fIE7YN = (Prototype.Browser.IE);
  if(fIE7YN){
    // Replace fall-back markup with Object tag + classid
    var sBuffer = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + sWidth + 
      '" height="' + sHeight + '" id="' + sGalleryID + '">' + 
      '<param name="movie" value="' + sPathToSWF + '" />';
    for (var oProp in oParams){
      sBuffer += '<param name="' + oProp + '" value="' + oParams[oProp] + '">';
    }
     sBuffer += '<param name="flashvars" value="file_to_load=' + oFlashVars.file_to_load + '">';  
    Element.replace(sGalleryID, sBuffer);
  }else{
    // Call SWFObject
    swfobject.embedSWF( 
      sPathToSWF, 
      sGalleryID, 
      sWidth, 
      sHeight, 
      sVersion, 
      '/include/expressInstall.swf', 
      oFlashVars, 
      oParams, 
      oAttributes
    );
  }

}