

/* START:Flash Detect*/
var swf = false;
function hasFlash(ver) {
  if(!ver) ver = 0;
  var n = navigator;
  if(n.plugins && n.plugins.length > 0) {
    var m,t,d,v;
    m = n.mimeTypes;
    t = 'application/x-shockwave-flash';
    if(m && m[t] && m[t].enabledPlugin && m[t].enabledPlugin.description) {
      d = m[t].enabledPlugin.description;
      v = d.charAt(d.indexOf('.')-1);
      swf = (v >= ver) ? true : false;
    }
  } else if(n.appVersion.indexOf("Mac") == -1 && window.execScript) {
    for(var i=ver; i<=7&&i!=1&&swf!=true; i++) {
      execScript('on error resume next: swf=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash'+((i==0)?'':'.'+i)+'"))','VBScript');
    }
  } else {
    swf = false;
  }
  return swf;
}
/* END:Flash Detect*/


/* START:COMMON SCRIPT*/
function swapImg(imgid,id) {
  o = document.getElementById(imgid);
  o.src = o.src.replace(/_\d\./,'_'+id+'.');
}

/* OpenWindow
ACTION:
Open a new instance of browser
NOTES:
Multiple calls will re-use the same window;
Scrollable arg should be "scroll" or "no_scroll" for ease of reading(nothing cryptic)
*/
function OpenWindow(url,height,width,top,left,scrollable){
  var owcscroll = (scrollable=='scroll')?'yes':'no';
  cm_ow = window.open(url,'cm_ow','height='+height+',width='+width+',resizable=1,top='+ top +',left='+ left +',scrollbars='+owcscroll);
  cm_ow.focus();
}
/* END:COMMON SCRIPT*/



/* to avoid implementing section-based js files, include the js here. if it gets bulky separate it later */



/* START:INVESTOR SECTION JAVASCRIPT */
function ShowReport(ele){
  var val = ele.options[ele.selectedIndex].value;
  if(val!='') document.location.href=val;
}
//investor section also uses showNewsList() which is identical as in the news section

/* END:INVESTOR SECTION JAVASCRIPT*/


function selectList(ele) {
  var val = ele.options[ele.selectedIndex].value;
	if(document.location.toString().indexOf("abs_investorinformation")+1){
    val = '/abs_investorinformation/pressrelease/default.asp?'+val.split('?')[1];
  }
  if(val!='') document.location.href=val;
}



/* START:NEWS SECTION JAVASCRIPT */
function showNewsList(ele) { //also used in investor section
  var val = ele.options[ele.selectedIndex].value;
  if(val!='') document.location.href=val;
}
/* END:NEWS SECTION JAVASCRIPT*/

/* START: Force Numeric */
function ForceNumeric(field)
{
	var inputStr = field.value.toString();
	var strLength = inputStr.length;
	var newStr = "";
	for (var i = 0; i < strLength; i++) 
{
	var oneChar = inputStr.charAt(i); 
	if (!( isNaN(oneChar) || oneChar == ' ') || oneChar == '-' ) 
	{ 
		newStr = String(newStr) + String(field.value.substring(i,i+1));
	}
}
	if (newStr != field.value) 
	{
		field.value = newStr;
	}
}
function NumericKeyUp(fieldToEval,fieldToEvalLength,objToJumpTo) 
{
	ForceNumeric(fieldToEval);
	if ((fieldToEval.value.length == fieldToEvalLength)&& (fieldToEval.value != prevValue) && (objToJumpTo != null))
	{ 
		objToJumpTo.focus() 
	} 
		prevValue = fieldToEval.value;
}
/* END: Force Numeric */

/* START: Zip Code Validation */
function ValidateZip (sZip)
{
	var regZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/;

	if (sZip == '')
	{
		alert('Please Enter Your Zip Code');
		return false;
	}
	else if (!regZip.test(sZip))
	{
		alert('The Zip Code Entered Is Not Valid');
		return false;
	}
	else return true;
}
/* END: Zip Code Validation */

/* START: Validate PSC and Weekly Ads Form */
function ValidatePSCAdsForm (formName, fieldName, type)
{		
	var field = eval("document." + formName + "." + fieldName + ".value");
	var validated
			
	if (field.length == 0)
	{
		alert("Please Enter " + type + " Email Address");
		validated = EmailValidation (field);
	}
	else
	{	
		validated = EmailValidation (field);
	}	
	
	if (validated)
	{
		return true;
	}
	else
	{
		return false;
	}
}
/* END: Validate PSC and Weekly Ads Form */

/* START: Email Validation */
function EmailValidation (Email)
{
	var regEmail = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		
	if (!regEmail.test(Email))
	{
		alert('The Email Address Entered Is Not Valid');
		return false;
	}
	else return true;	
}
/* END: Email Validation */
