
/* Apply Text box CSS and Error Text Box CSS */

function resetTextBoxCSS(object)
{
	object.style.border='1px solid #7f9db9';
	object.style.background='#ffffff';
}
function applyErrorTextBoxCSS(object)
{
	object.style.border='1px solid red';
	object.style.background='#FFDDDD';
}
/*is valid content type*/
function isValidFile (str)
{
  // Return immediately if an invalid value was passed in
  if (str+"" == "undefined" || str+"" == "null")
   return false;
   else
   	{
	  if (str+"" == "")
	  	return true; //word doc not required
	  else
	  	str +="";
		//Rules:
		//str must contain .doc or must contain .PDF
		if ((str.indexOf(".doc") <= 0)&&(str.indexOf(".pdf") <= 0))
		return false;
	}
		return true;
   
}

/* is a Valid Email */
function isValidEmail (str)
{
  // Return immediately if an invalid value was passed in
  if (str+"" == "undefined" || str+"" == "null")
   return false;

  else
  {
   if (str+"" == "")
 return true;  // email is not required
   else

  str += "";
  namestr = str.substring(0, str.indexOf("@"));  // everything before the '@'
  domainstr = str.substring(str.indexOf("@")+1, str.length); // everything after the '@'

  // Rules:
  // namestr must contain something before the '@'
  // domainstr must contain a period that is not the first character (i.e. right after
  // the '@').
  if ((namestr.length == 0) || (domainstr.indexOf(".") <= 0) || (domainstr.indexOf("@") != -1))
   return false;
  }

 return true;
}


function isValidDate(dateStr, format) {
   if (format == null) { format = "MDY"; }
   format = format.toUpperCase();
   if (format.length != 3) { format = "MDY"; }
   if ( (format.indexOf("M") == -1) || (format.indexOf("D") == -1) || (format.indexOf("Y") == -1) ) { format = "MDY"; }
   if (format.substring(0, 1) == "Y") { // If the year is first
      var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
      var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
   } else if (format.substring(1, 2) == "Y") { // If the year is second
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
   } else { // The year must be third
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
   }
   // If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
   if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) { return false; }
   var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
   // Check to see if the 3 parts end up making a valid date
   if (format.substring(0, 1) == "M") { var mm = parts[0]; } else if (format.substring(1, 2) == "M") { var mm = parts[1]; } else { var mm = parts[2]; }
   if (format.substring(0, 1) == "D") { var dd = parts[0]; } else if (format.substring(1, 2) == "D") { var dd = parts[1]; } else { var dd = parts[2]; }
   if (format.substring(0, 1) == "Y") { var yy = parts[0]; } else if (format.substring(1, 2) == "Y") { var yy = parts[1]; } else { var yy = parts[2]; }
   if (parseFloat(yy) <= 50) { yy = (parseFloat(yy) + 2000).toString(); }
   if (parseFloat(yy) <= 99) { yy = (parseFloat(yy) + 1900).toString(); }
   var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
   if (parseFloat(dd) != dt.getDate()) { return false; }
   if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
   return true;
}

function show_div(div_id) {
    // hide all the divs
    document.getElementById('email_friend').style.display = 'none';
    document.getElementById('empty_div').style.display = 'none';

    // show the requested div
    document.getElementById(div_id).style.display = 'block';
}

