<!--Hide JavaScript from old browsers
/*****************************newsletter email field validation***************************************************/
if (document.images) 
{
 img1 = new Image();
 img1.src = "http://img.better-holidays.com/images/misc/loading.gif";	
}

function sScreen() {
	var bTag=document.getElementsByTagName("body");
	var divH = document.getElementById("Wrapper").style.display='none'; 
	var dElm1 = document.createElement("div");
		dElm1.id = 'doGlobal';
	var dElm2 = document.createElement("div");
		dElm2.id = 'doTop';
	var dElm3 = document.createElement("div");
		dElm3.id = 'doCenter';
	var dElm4 = document.createElement("div");
		dElm4.id = 'doText';
	var dElm5 = document.createElement("div");
		dElm5.id = 'doBottom';							
	
	var oText = document.createTextNode("searching.....");
		
		bTag[0].appendChild(dElm1);
		dElm1.appendChild(dElm2);
		dElm1.appendChild(dElm3);
		dElm1.appendChild(dElm4);
		dElm4.appendChild(oText);
		dElm1.appendChild(dElm5);
	
}

function checkEmail(form) {
	if (isBlank(form.email.value) || !isEmailValid(form.email.value) ) {
		alert("Invalid\u00A0email\u00A0address");
		form.email.focus();
		return false;
	}
return true;

}

function isBlank(fieldValue) {
	var blankSpaces = / /g;
	fieldValue = fieldValue.replace(blankSpaces, "");
	return (fieldValue == "") ? true : false;
}

function isEmailValid(fieldValue) {
	var emailFilter = /^.+@.+\..{2,4}$/;
	var atSignFound = 0;
	for (var i = 0; i <= fieldValue.length; i++)
		if ( fieldValue.charAt(i) == "@" )
			atSignFound++;
	if ( atSignFound > 1 )
		return false;
	else
		return ( emailFilter.test(fieldValue) && !doesEmailHaveInvalidChar(fieldValue) ) ? true : false;
}

function doesEmailHaveInvalidChar(fieldValue) {
	var illegalChars = /[\(\)\<\>\,\;\:\\\/\"\[\] ]/;
	return ( illegalChars.test(fieldValue) ) ? true : false;
}

//********************************change Class on Over and out*****************************//
function changeClass(Object,Class)
{
	var Item=document.getElementById(Object);
 	Item.className = Class;
}
//Round Numbers *************************************************************************//
	function roundVal(n) {//round value to 2 decimals
    n = Math.round(n * 100) / 100;
    n = (n + 0.001) + '';
    return n.substring(0, n.indexOf('.') + 3);
	}
	
	function roundVal1(n) {//round value to 1 decimals
    n = Math.round(n * 10) / 10;
    return n;
	}		
	
//Open Window ***************************************************************************//
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}	
//Date Check Day and Month **************************************************************//
//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "4" || WhichMonth == "6" || WhichMonth == "9" || WhichMonth == "11") DaysInMonth = 30;
  if (WhichMonth == "2" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "2" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months***************************************//
function ChangeOptionDays(Which)
{
CurrentDay = document.getElementById(''+Which+'D').value;
DaysObject = document.getElementById(''+Which+'D');
MonthObject = document.getElementById(''+Which+'M');
YearObject = document.getElementById(''+Which+'Y');
	
  Month = MonthObject[MonthObject.selectedIndex].value
  Year = YearObject[YearObject.selectedIndex].value

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length -1;
  
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }

  }
  

  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length ,DaysObject.options.length);
      DaysObject.add(NewOption);
    }
  }
  
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
    
    if(CurrentDay!=DaysObject.selectedIndex){
		alert('Invalid\u00A0Date !');  
    }
    
}
	
//function to get and display the day of the week**************************************************//
function getWeekDay(dd,mm,yy,obj){
	
 var DaysObject = document.getElementById(dd).value;
 var MonthObject = document.getElementById(mm).value-1;
 var YearObject = document.getElementById(yy).value;
 var currDate= new Date ( YearObject, MonthObject, DaysObject );
 
 DayOfWeek = currDate.getDay();
	if(DayOfWeek==0){dWeek="Sun";}
	if(DayOfWeek==1){dWeek="Mon";}
	if(DayOfWeek==2){dWeek="Tue";}
	if(DayOfWeek==3){dWeek="Wed";}
	if(DayOfWeek==4){dWeek="Thu";}
	if(DayOfWeek==5){dWeek="Fri";}
	if(DayOfWeek==6){dWeek="Sat";}

document.getElementById('wDay').value=dWeek;
}

//************************************************************************************************//
function hiChk () {
   for (var c = 0; c < document.search.elements.length; c++)
   if (document.search.elements[c].type == 'checkbox' && document.search.elements[c].checked ==true){
      document.search.elements[c].className ='radioOn';
   }
}


//************************************************************************************************//
function valInp(emlField,formName){
var theForm=formName.form;
emlRegxp = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
var cEml=document.getElementById(emlField).value;
msg='Please\u00A0enter\u00A0all\u00A0required\u00A0fields :\n\n';

if (emlRegxp.test(cEml) != true ){var error=1;msg+='* Email\u00A0Address\n';}
	if(error==1){alert(msg);}
	else{theForm.submit();}
}


//***********************************************************************************************//
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // the highlightStartTag and highlightEndTag parameters are optional
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<span style='border-bottom: dashed 1px  #000000'>";
    highlightEndTag = "</span>";
  }
  
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


function txtHiLgt(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
	if(searchText!=''){
	  // if the treatAsPhrase parameter is true, then we should search for 
	  // the entire phrase that was entered; otherwise, we will split the
	  // search string so that each word is searched for and highlighted
	  // individually
	  if (treatAsPhrase) {
	    searchArray = [searchText];
	  } else {
	    searchArray = searchText.split(" ");
	  }
	  
	  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
	    if (warnOnFailure) {
	     // alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
	    }
	    return false;
	  }
	  
	  var bodyText = document.body.innerHTML;
	  for (var i = 0; i < searchArray.length; i++) {
	    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
	  }
	  
	  document.body.innerHTML = bodyText;
	  return true;
	}
}


//End hiding JavaScript-->