//====================================================================================
//	Multibrowser compatible get element function
//====================================================================================
function getObj(name)
{
	if(document.getElementById)
	{
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
 	}
	else if(document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers)
	{
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}

//====================================================================================
//	Function used for trimming the white spaces from control value
//====================================================================================
function Trim(control)
{
	var str = control.value;

	// Triming spaces on the left
	str = str.replace(/^\s+/, "");

	// Triming spaces on the right
	str = str.replace(/\s+$/, "");

	return str;
}

//====================================================================================
//	Function checks if the control value is empty
//====================================================================================
function CheckEmpty(control, ctrlTitle)
{
	var str = Trim(control);

	//	If the length of control value after trim is zero
	if(control.disabled == true || str.length == 0)
	{
		if(ctrlTitle.length > 0)
		{
		   alert("Please enter "+ctrlTitle);
		   control.focus();
		}

		return false;
	}

	return true;
}

//====================================================================================
//	Function to check if the email value entered is valid
//====================================================================================
function CheckEmail(control, ctrlTitle)
{
	control.value = Trim(control);

	if(control.value.length > 0 )
	{
		var supported = 0;
		if(window.RegExp)
		{
			var tempStr = "a";
			var tempReg = new RegExp(tempStr);
			if(tempReg.test(tempStr))
			{
				supported = 1;
			}
		}

		if(!supported)
		{
			return (control.value.indexOf(".") > 2) && (control.value.indexOf("@") > 0);
		}

		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r3 = new RegExp("^.+ .+$");
//		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,6}|[0-9]{1,3})(\\]?)$");
		var r2 = new RegExp("^[-_.a-z0-9]+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,6}|[0-9]{1,3})(\\]?)$");

		if((!r1.test(control.value) && r2.test(control.value) && !r3.test(control.value)) == false)
		{
			alert("\'" + control.value + "\' is an invalid email address.");
			control.focus();
			control.select();
			return false;
		}
	}

	return true;
}

//====================================================================================
//	Function checks if list box value is selected
//====================================================================================
function CheckSelected(control, ctrlTitle)
{
	if(control.multiple == false)
	{
		if(control.selectedIndex <= 0)
		{
			alert("Please select " + ctrlTitle);
			control.focus();
			
			return false;
		}

		return true;
	}
	else if(control.multiple == true)
	{
		for(i = 0; i < control.length; i++)
		{
			if(control.options[i].selected == true)
				return true;
		}
		alert("Please select " + ctrlTitle);
		control.focus();

		return false;
	}
}

//====================================================================================
//	Function checks if the control value is numeric
//====================================================================================
function CheckNumeric(control, ctrlTitle)
{
	var str = Trim(control);

	
	if(str.length != 0)
	{
		if(isNaN(control.value))
		{
			alert(ctrlTitle+" must be numeric.");
			control.focus();
			control.select();
			return false;
		}

		if(control.value < 0)
		{
			alert(ctrlTitle+" must be positive.");
			control.focus();
			control.select();
			return false;
		}
	}

	return true;
}



///***///

//======================================================================
//	Function CheckPhone() validates the phone Number
//======================================================================

function CheckPhone(control, ctrlTitle)
{
var phone = Trim(control);

		if(phone != "")
		if (checkInternationalPhone(phone)==false){
			phone="";
			control.focus();
			alert("Please Enter a Valid "+ctrlTitle);
			return false;
	}
	return true;

}


function checkInternationalPhone(strPhone){

return ((!isNaN(strPhone)) && (strPhone.length >= 8 &&  strPhone.length <= 15));
}


function Check_for_all_digit(control,ctrTitle)
{
		
	if(!isNaN(control.value)){
		alert(ctrTitle+" cannot contain only digits");
		control.value = '';
		control.focus();
		return false;	
	}
	return true;

}



///***///


//====================================================================================
//	Function checks for alphanumeric value
//====================================================================================
function CheckAlphaNumeric(control, ctrlTitle)
{
	var str = Trim(control);

	if (str.length!=0)
	{
		//	writing regular expression
		var regexp = new RegExp("[^A-Za-z0-9\-_]");
		if ((regexp.test(str)))
		{
			alert(ctrlTitle+" has invalid characters");
			control.focus();
			return false;
		}
	}
	return true;
}


//====================================================================================
//	Function checks for alphabetic value
//====================================================================================
function CheckAlphabet(control, ctrlTitle)
{
	var str = control.value;
	if (str.length!=0)
	{
		//writing regular expression
		var regexp = new RegExp("^[a-zA-Z \.\-]+$");
		if (!(regexp.test(control.value)))
		{
			alert(ctrlTitle+" has to be alphabetic");
			control.focus();
			return false;
		}
	}
	return true;
}

//====================================================================================
//	Function to check the zip number
//====================================================================================
function chkzip(control, ctrlTitle)
{
	var str = control.value;

	//triming spaces on the left of the string
	str = str.replace(/^\s+/, "");

	//triming spaces on the right of the string
	str = str.replace(/\s+$/, "");

if(str.length != "")
	if((str.length==10) || (str.length==5)) ///***///
	{
		//writing regular expression
		var regexp1 = new RegExp("^[0-9]+$");
		var regexp2 = new RegExp("^[0-9]+-[0-9]+$");

		if (regexp1.test(str) || regexp2.test(str))
			return true;
		else
		{
			alert("\'" + str + "\' is an invalid Zip Code.");
			control.focus();
			control.select();
			return false;
		}
	}
	///***///
	else
	{
	alert("Please enter the zip code correctly.");
		return false;
	}
	///***///

	return true;
}

/*
function CheckPhoneNo(control) 
{
 
    // Check for correct phone number
    rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
    str = control.value;	

	if (!rePhoneNumber.test(str)) {
		alert("Phone Number Must Be Entered As: (555) 555-1234");
		control.focus();
		control.select();
		return false;
    }
 
return true;
}

*/

//====================================================================================
//	Function to check valid year
//====================================================================================
function CheckYear(control, ctrlTitle)
{
	control.value = Trim(control);

	var str = control.value;

	if (str.length!=0)
	{
		//writing regular expression
		var regexp1 = new RegExp("^[0-9]{4}$");

		if (regexp1.test(str))
		{
			return true;
		}
		else
		{
			alert(ctrlTitle+" has to be a 4 digit number.");
			control.focus();
			control.select();
			
			return false;
		}

	}
	return true;
}

//===================================================================================
// Function to check for a valid credit card
//====================================================================================
function ValidateCreditCard(control, s)
{
	var v = "0123456789";
	var w = "";
	for (var i=0; i < s.length; i++) {
	x = s.charAt(i);
	if (v.indexOf(x,0) != -1)
	w += x;
	}
	var j = w.length / 2;
	if (j < 6.5 || j > 8 || j == 7)
	{
		control.focus();
		return false;
	}
	var k = Math.floor(j);
	var m = Math.ceil(j) - k;
	var c = 0;
	for (var i=0; i<k; i++) {
	a = w.charAt(i*2+m) * 2;
	c += a > 9 ? Math.floor(a/10 + a%10) : a;
	}
	for (var i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
	return (c%10 == 0);
}

var isNetscape = (navigator.appName=="Netscape");
var mouse_x = 0;
var mouse_y = 0;
var help_mouse_x = 0;
var help_mouse_y = 0;
var help_win_name = 'help_window';
var help_content_name = 'help_content';

if(isNetscape)
{
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = getMouseCoordinatesNetscape;
}
else
{
	document.onmousemove = getMouseCoordinatesIE;
}

function show_help_window(helpText)
{
	// Make Sure Window Is Hidden
	hide_help_window();
	var help_win = new getObj(help_win_name);

	// Populate Window
	WriteIntoLayer(help_content_name, helpText);

	// Position Window
	help_window_width = help_win.obj.scrollWidth;
	help_window_height = help_win.obj.scrollHeight;
	browser_width = document.body.clientWidth;
	browser_height = document.body.clientHeight;
	help_win_pos = 'right';
	tmp_space_right = browser_width - mouse_x;
	tmp_space_left = mouse_x;

	if(tmp_space_right < (help_window_width + 10) && tmp_space_left >= (help_window_width + 10))
	{
		help_win_pos = 'left';
	}

	if(help_win_pos == 'right')
	{
		help_win_left = help_mouse_x + 10;
		help_win_top = help_mouse_y;
	}
	else if(help_win_pos == 'left')
	{
		help_win_left = help_mouse_x - help_window_width - 10;
		help_win_top = help_mouse_y;
	}

	if(help_win_top >= 10)
	{
		help_win_top = help_win_top - 10;
	}
	help_win.obj.style.top = help_win_top;
	help_win.obj.style.left = help_win_left;

	// Show Window
	help_win.obj.style.visibility = 'visible';
}

function getMouseCoordinatesNetscape(e)
{
   mouse_x = e.pageX - document.body.scrollLeft;
   mouse_y = e.pageY - document.body.scrollTop;
   help_mouse_x = e.pageX;
   help_mouse_y = e.pageY;
   return true;
}

function getMouseCoordinatesIE()
{
   mouse_x = window.event.x;
   mouse_y = window.event.y;
   help_mouse_x = window.event.x + document.body.scrollLeft;
   help_mouse_y = window.event.y + document.body.scrollTop;
}

function hide_help_window()
{
   // Hide Window
   var help_win = new getObj(help_win_name);
   help_win.style.visibility = 'hidden';
}

//===================================================================================
//	Multibrowser compatible function to write into div layer
//====================================================================================
function WriteIntoLayer(id, text)
{
	if(document.getElementById)
	{
		x = document.getElementById(id);
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if(document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if(document.layers)
	{
		x = document.layers[id];
		text2 = '<P>' + text + '</P>';
		x.document.open();
		x.document.write(text2);
		x.document.close();
	}
}

function IsValid(obj)
{
    strString  = obj.value;
    validCharactersRegExp = /[^a-zA-Z0-9' ]/i;

  var iValid = (validCharactersRegExp.test(strString));
  if(strString != "")
  { 
	 if(iValid)
	 { 
		alert("Invalid data");
 		obj.focus();
	 }
  }
}

//this function checks URL Validation
function UrlCheck(control)
{
	var v = new RegExp(); 
    v.compile("[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
    if (!v.test(control.value)) { 
        alert("\'" + control.value + "\' is an invalid URL."); 
        control.focus();
	    control.select();
	
        return false; 
    } 
    return true;
}

// function to put control on the first input field on loading
function focustofirstcontrol(comp_name)
{

	/*focus to company name*/
	if(comp_name)
	{
		document.getElementById("company_name").focus();
		return true;
	}

	/*focus to first element*/
	if(document.forms.length)
	{
		
		for(var i=0; i<document.forms[0].elements.length; i++)
		{
			 if(document.forms[0].elements[i].type!='hidden' && document.forms[0].elements[i].disabled==false && document.forms[0].elements[i].readOnly==false)
			 {
				document.forms[0].elements[i].focus();
				return true;
			 }
	    }
    }
}

function NotListed(selectedobj,id)
{

  if (selectedobj.value == "" )
  {
 	document.getElementById(id).style.display  = "block";
  }
  else
  {
 	document.getElementById(id).style.display  = "none";
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var dFilterStep

function dFilterStrip(dFilterTemp, dFilterMask)
{
    dFilterMask = replace(dFilterMask,'#','');
    for (dFilterStep = 0; dFilterStep < dFilterMask.length++; dFilterStep++)
		{
		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}
		return dFilterTemp;
}

function dFilterMax (dFilterMask)
{
 		dFilterTemp = dFilterMask;
    for (dFilterStep = 0; dFilterStep < (dFilterMask.length+1); dFilterStep++)
		{
		 		if (dFilterMask.charAt(dFilterStep)!='#')
				{
		        dFilterTemp = replace(dFilterTemp,dFilterMask.charAt(dFilterStep),'');
				}
		}
		return dFilterTemp.length;
}

function dFilter(key, textbox, dFilterMask)
{
		dFilterNum = dFilterStrip(textbox.value, dFilterMask);
		
		if (key==9)
		{
		    return true;
		}
		else if (key==8&&dFilterNum.length!=0)
		{
		 	 	dFilterNum = dFilterNum.substring(0,dFilterNum.length-1);
		}
 	  else if ( ((key>47&&key<58)||(key>95&&key<106)) && dFilterNum.length<dFilterMax(dFilterMask) )
		{
        dFilterNum=dFilterNum+String.fromCharCode(key);
		}

		var dFilterFinal='';
    for (dFilterStep = 0; dFilterStep < dFilterMask.length; dFilterStep++)
		{
        if (dFilterMask.charAt(dFilterStep)=='#')
				{
					  if (dFilterNum.length!=0)
					  {
				        dFilterFinal = dFilterFinal + dFilterNum.charAt(0);
					      dFilterNum = dFilterNum.substring(1,dFilterNum.length);
					  }
				    else
				    {
				        dFilterFinal = dFilterFinal + "";
				    }
				}
		 		else if (dFilterMask.charAt(dFilterStep)!='#')
				{
				    dFilterFinal = dFilterFinal + dFilterMask.charAt(dFilterStep); 			
				}
//		    dFilterTemp = replace(dFilterTemp,dFilterMask.substring(dFilterStep,dFilterStep+1),'');
		}


		textbox.value = dFilterFinal;
    return false;
}

function replace(fullString,text,by) {
// Replaces text with by in string
    var strLength = fullString.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return fullString;

    var i = fullString.indexOf(text);
    if ((!i) && (text != fullString.substring(0,txtLength))) return fullString;
    if (i == -1) return fullString;

    var newstr = fullString.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(fullString.substring(i+txtLength,strLength),text,by);

    return newstr;
}

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}
function GetToolTipTxt(val)
 {
 var tooltxt;
 
switch(val.toUpperCase())
{
	case 'CROSS-SELL' : 
	tooltxt = "Ability to Cross-Sell products.";
	break;

	case 'BRANDING' : 
	tooltxt = "Ability to increase Brand Awareness.";
	break;

	case 'ATTENTION' : 
	tooltxt = "Ability to capture the customer\'s Attention.";
	break;

	case 'ENGAGEMENT' : 
	tooltxt = "Ability to Actively Engage the customer.";
	break;

	case 'TRIAL' : 
	tooltxt = "Ability to Drive Trial.";
	break;

	case 'INFORM' : 
	tooltxt = "Ability to Communicate Information.";
	break;

	case 'OFFER' : 
	tooltxt = "Ability to provide an Offer.";
	break;

	

}


  var txt = '';
  txt += '<div align="left" STYLE="background-color:#214083">';
  txt += tooltxt;
  txt += '</div>';
  return txt;
 }



// pop up window array
var w = Array();

///***///
var flag_cnt = Array(10);
for(var i=0;i<10;i++)
	flag_cnt[i] = 0;
///***///


<!-- function to open new window -->
function MM_openBrWindow(theURL,winName,w1,h,features,cnt)
{ //v2.0

	if(w1 != "") {   var winl = (screen.width-w1)/2; } 
	if(h != "") {   var wint = (screen.height-h)/2; }  
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
   var settings = 'height=' + h + ',';
  settings += 'width=' + w1 + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;

  w[cnt]=window.open(theURL,winName,settings);
  w[cnt].focus();  
      
}



<!-- FUNCTION TO CLOSE WINDOW   -->
function closeall()
{ 
  for(var i=0;i<8;i++) {
    if(w[i] && !w[i].closed) { 
      w[i].closewin();
    }
  }
}

<!-- FUNCTION TO SHOW LAYER (DIV) -->
function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.style.display = "block";
}

<!-- FUNCTION TO HIDE LAYER  -->
function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.style.display = "none";
}

<!-- FUNCTION TO RETURN ID -->
function getElemRefs(id) {

	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

 function submit_form(formname)
 {
    eval("document."+formname+".submit()");  

 }
 

 
 //This is only to allow numeric entries.  VP [07-july-08]
function isNumberKey(evt){
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57)){
		 alert('Only numeric entry allowed!!');
		return false;
	 }

	 return true;
  }

