/*********************************************************************
	Mouseover effects for regional webs sites.  Moved to this page, 
	so that all code is hidden, and doesn't clutter the output
*********************************************************************/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function P7_autoLayers() { //v1.2 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;
 var a = parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc) {p7c=new Array();document.p7setc=true;
  for (var u=0;u<10;u++) {p7c[u] = new Array();}}
 for(k=0; k<p7c[a].length; k++) {
  if((g=MM_findObj(p7c[a][k]))!=null) {
   b=(document.layers)?g:g.style;b.visibility="hidden";}}
 for(k=1; k<args.length; k++) {
  if((g=MM_findObj(args[k])) != null) {
   b=(document.layers)?g:g.style;b.visibility="visible";f=false;
   for(j=0;j<p7c[a].length;j++) {
    if(args[k]==p7c[a][j]) {f=true;}}
  if(!f) {p7c[a][p7c[a].length++]=args[k];}}}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



/**************************************************************************
	A Simple utility to trim white spaces (leading / ending)
	can be used in any client-side Javascript routines
**************************************************************************/
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
/************************************************************************************
	autoComplete is a function for simulating a lookup in a select. 
	Inputs: field - the name of the textbox used as the search criteria.
			select - The name of the select object.
			property - "Text" - the text property of the select, "Value"- the value property of the select.
			forcematch - "true" - forces a match in the property selected above.
	Comment: Called on the "onkeyup" property of the textbox used as "field" above.
**************************************************************************************/
function autoComplete (field, select, property, forcematch) {
	var found = false;
	for (var i = 0; i < select.options.length; i++) {
	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { select.selectedIndex = i; }
	else { select.selectedIndex = -1; }
	if (field.createTextRange) {
		if (forcematch && !found) {
			field.value=field.value.substring(0,field.value.length-1); 
			return;
			}
		var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			var r1 = field.createTextRange();
			var oldValue = r1.text;
			var newValue = found ? select.options[i][property] : oldValue;
			if (newValue != field.value) {
				field.value = newValue;
				var rNew = field.createTextRange();
				rNew.moveStart('character', oldValue.length) ;
				rNew.select();
				}
			}
		}
	}


function UpdateReportDisplay() {
parent.location.href = "/default.asp?page=991&report=0&prod=" + window.document.forms[0].ProdTypes.value;
}
function UpdateReportGuideDisplay() {
parent.location.href = "/default.asp?page=991&report=1&guide=" + window.document.forms[0].GuideTypes.value + "&gyear=" + window.document.forms[0].GuideYear.value;
}
function UpdateReportDateDisplay(OnBefore) {
parent.location.href = "/default.asp?page=991&report=2&RDate=" + window.document.forms[0].dReport.value + "&OnBeforeDate=" + OnBefore;
}
/******************************************************************************
* Name      : bGetFileExtension()
* Author    : TMC - Daenna Currie
* Purpose   : get the file extension
* Parameters: 
* Returns   : a string 
*			: the file extension of the string submitted
* Description: returns everything after the last occurance of "."
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function bGetFileExtension(sFileName)
{
	var sLength = sFileName.length
	var nIndex = sFileName.lastIndexOf(".")+1
	var sExtension = sFileName.substr(parseInt(nIndex), parseInt(sLength))
	return sExtension;
}
/************************************************************************************
* Name      : validateEmail()
* Author    : TMC - Daenna Currie
* Purpose   : validate emailCorrespondance.asp
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for required values
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
************************************************************************************/
function OpenWindow(p_OPID) 
{
	Notebook = window.open("TravelFrames.asp?opid=" + p_OPID , "TravelNotebook", "status=no,location=no,toolbar=no,width=350,height=520,resizable=yes,scrollbars=yes,left=600,top=0");
	Notebook.focus();
}
function changeImage(sImgName, sImg) 
{
	document.images[sImgName].src = sImg;
}
function ProdImagePopUp(URL) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, \'" + id + "\', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=450\');");
}

function validateEmail()
{
	if(document.frmEmail.cmbTo.selectedIndex == 0)
	{
		alert("The field \"To:\" is required in order to send.");
		document.frmEmail.cmbTo.focus();
	}
	else if(document.frmEmail.txtSubject.value == 0)
	{
		alert("The field \"Subject:\" is required in order to send.");
		document.frmEmail.txtSubject.focus();
	}
	else if(document.frmEmail.txtBody.value == 0)
	{
		alert("The field \"Body:\" is required in order to send.");
		document.frmEmail.txtBody.focus();
	}
	else if(document.frmEmail.txtFile.value != 0)
	{
		if(bGetFileExtension(document.frmEmail.txtFile.value.toLowerCase()) == "exe" || 
	       bGetFileExtension(document.frmEmail.txtFile.value.toLowerCase())== "dll" || 
	       bGetFileExtension(document.frmEmail.txtFile.value.toLowerCase())== "bat")
		{
			alert("This file extension is not permitted. Please choose another file.");
			document.frmEmail.txtFile.focus();
		}
		else
		{
			document.frmEmail.txtEmailSubmitted.value = true
			document.frmEmail.submit();
		}
	}
	else
	{
		document.frmEmail.txtEmailSubmitted.value = true
		document.frmEmail.submit();
	}
}

/******************************************************************************
* Name      : validateMemberEmail()
* Author    : TMC - Daenna Currie
* Purpose   : validate memberCorrespondance.asp 
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for required values
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function validateMemberEmail()
{
	if (!document.frmMemberEmail.chkNoEmail.checked)
	{
		document.frmMemberEmail.txtSendEmail.value = "true"
		if(document.frmMemberEmail.txtSubject.value == 0)
		{
			alert("The field \"Subject:\" is required in order to send.");
			document.frmMemberEmail.txtSubject.focus();
			return;
		}
		else if(document.frmMemberEmail.txtBody.value == 0)
		{
			alert("The field \"Body:\" is required in order to send.");
			document.frmMemberEmail.txtBody.focus();
			return;
		}
		else if(document.frmMemberEmail.txtFile.value != 0)
		{
			if(bGetFileExtension(document.frmMemberEmail.txtFile.value.toLowerCase()) == "exe" || 
	           bGetFileExtension(document.frmMemberEmail.txtFile.value.toLowerCase())== "dll" || 
	           bGetFileExtension(document.frmMemberEmail.txtFile.value.toLowerCase())== "bat")
			{
				alert("This file extension is not permitted. Please choose another file.");
				document.frmMemberEmail.txtFile.focus();
				return;
			}
		}
	}
	else
	{
		document.frmMemberEmail.txtSendEmail.value = "false"
	}
	document.frmMemberEmail.txtEmailSubmitted.value = true
	document.frmMemberEmail.submit();
}
/******************************************************************************
* Name      : validateMemberEmail()
* Author    : TMC - Daenna Currie
* Purpose   : validate memberCorrespondance.asp 
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for required values
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function validateIndustryEmail()
{
	if (document.frmIndustryEmail.chkDebug.checked)
	{
		document.frmIndustryEmail.txtDebug.value = "true"
	}
	else
	{
		document.frmIndustryEmail.txtDebug.value = "false"
	}
	if (!document.frmIndustryEmail.chkNoEmail.checked)
	{
		document.frmIndustryEmail.txtSendEmail.value = "true"
		if(document.frmIndustryEmail.txtSubject.value == 0)
		{
			alert("The field \"Subject:\" is required in order to send.");
			document.frmIndustryEmail.txtSubject.focus();
			return;
		}
		else if(document.frmIndustryEmail.txtBody.value == 0)
		{
			alert("The field \"Body:\" is required in order to send.");
			document.frmIndustryEmail.txtBody.focus();
			return;
		}
		else if(document.frmIndustryEmail.txtFile.value != 0)
		{
			if(bGetFileExtension(document.frmIndustryEmail.txtFile.value.toLowerCase()) == "exe" || 
	           bGetFileExtension(document.frmIndustryEmail.txtFile.value.toLowerCase())== "dll" || 
	           bGetFileExtension(document.frmIndustryEmail.txtFile.value.toLowerCase())== "bat")
			{
				alert("This file extension is not permitted. Please choose another file.");
				document.frmIndustryEmail.txtFile.focus();
				return;
			}
		}
	}
	else
	{
		document.frmIndustryEmail.txtSendEmail.value = "false"
	}
	document.frmIndustryEmail.txtEmailSubmitted.value = true
	document.frmIndustryEmail.submit();
}
function SayOK(strWhereToGo) 
{
	//3000 - is the amount of time to wait before redirecting the user
	//I think it's in ,milliseconds or something, you can change that  as required.
	objTimer = window.setTimeout(strWhereToGo,500);
}

/******************************************************************************
* Name      : validateContact()
* Author    : TMC - Daenna Currie
* Purpose   : validate contact.asp 
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for required values only
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function validateContact()
{
	if (document.frmContact.txtFirstName.value == 0) 
	{
		alert("The field \"First Name\" is required in order to save.");
		document.frmContact.txtFirstName.focus();
	}
	else if (document.frmContact.txtLastName.value == 0) 
	{
		alert("The field \"Last Name\" is required in order to save.");
		document.frmContact.txtLastName.focus();
	}
	else if (document.frmContact.txtAddress.value == 0) 
	{
		alert("The field \"Address\" is required in order to save.");
		document.frmContact.txtAddress.focus()
	}
	else if (document.frmContact.txtCity.value == 0) 
	{
		alert("The field \"City\" is required in order to save.");
		document.frmContact.txtCity.focus();
	}
	else if (document.frmContact.txtProvince.value == 0) 
	{
		alert("The field \"Province\" is required in order to save.");
		document.frmContact.txtProvince.focus();
	}
	else if (document.frmContact.txtPostalCode.value < 6) 
	{
		alert("The field \"Postal Code\" is required in order to save.");
		document.frmContact.txtPostalCode.focus();
	}
	else if (document.frmContact.txtCountry.value == 0) 
	{
		alert("The field \"Country\" is required in order to save.");
		document.frmContact.txtCountry.focus();
	}
	else if (document.frmContact.txtPassword.value == 0) 
	{
		alert("The field \"Password\" is required in order to save.");
		document.frmContact.txtPassword.focus();
	}
	else
	{
		document.frmContact.txtSubmitted.value = true;
		document.frmContact.submit();
	}
}

/******************************************************************************
* Name      : addNewContact()
* Author    : TMC - Daenna Currie
* Purpose   : reset contact.asp 
* Parameters: 
* Returns   : 
* Description: Sets the values to what they were when the page loaded
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function addNewContact()
{	
	strURL = "default.asp?page=" + 
			  document.frmContact.txtPage.value + 
			  "&menu=" +
			  document.frmContact.txtMenu.value + 
			  "&contactID=add"
	window.location = strURL;
}

/******************************************************************************
* Name      : resetContact()
* Author    : TMC - Daenna Currie
* Purpose   : reset contact.asp 
* Parameters: 
* Returns   : 
* Description: Sets the values to what they were when the page loaded
*
* Maintenance Log
* -----------------------------------------------------------------------------
*           Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function resetContact()
{
	document.frmContact.reset();
}

/************************************************************************************
* Name      : validDate()
* Author    : James C. Schubert
* Purpose   : validate dates passed
* Parameters: a date string as strDate
* Returns   : True if all tests pass, false otherwise
* Description: Validate the date in several ways.
*   1.  Check for correct format.
*   2.  Check if February.
*   	a.  If it's February, check for leap year.
*   	b.  Check for maximum day number for that year.
*   3.  Check for 30-day month.
*   	a.  If it's a 30-day month, make sure the day is <= 30
*   4.  If the first digit of the month or date is zero or not there:
*   	a.  Make sure the second digit is not 0
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*           Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*                       |                   |
************************************************************************************/
function validDate(strDate)
{
	blnValidDate = true
	//Set up the regular expression format
	rxpRegExDate = /(\d?\d)\/(\d?\d)\/(20\d\d)$/
	//Test strDate to make sure it's in the right basic format
	if (rxpRegExDate.test(strDate))
	{
		//Test for legitimate Month
		if (RegExp.$1.valueOf() > 12)
			{ return false }
		//Test for February
		if (RegExp.$1 == "02" || RegExp.$1 == "2")
		{
			blnLeapYear = false
			//Check for leap year
			if (RegExp.$3.valueOf() % 4 == 0)
			{
				blnLeapYear = true
			}
			//Check for maximum date based on leap year test
			if (blnLeapYear & (RegExp.$2.valueOf() > 29))
				{ blnValidDate = false }
			else if (RegExp.$2.valueOf() > 28)
				{ blnValidDate = false }
		}
		//Check for 30-day months (There are only 4)
		else if (RegExp.$1 == "04" || RegExp.$1 == "4" ||
					RegExp.$1 == "06" || RegExp.$1 == "6" ||
					RegExp.$1 == "09" || RegExp.$1 == "9" ||
					RegExp.$1 == "11")
		{
			if (RegExp.$2.valueOf() > 30)
				{ blnValidDate = false }
		}
		//Check the remaining 31-day months
		else
		{
			if (RegExp.$2.valueOf() > 31)
				{ blnValidDate = false }
		}
		//Make sure the month and date are not zero
		if (RegExp.$1.valueOf() < 1 || RegExp.$2.valueOf() < 1)
			{ blnValidDate = false }
	}
	else
	{
		blnValidDate = false
	}
	return blnValidDate
}

/******************************************************************************
* Name      : validateMarketOpp()
* Author    : TMC - Daenna Currie
* Purpose   : validate marketingOpportunities.asp 
* Parameters: 
* Returns   : Submits the form if all tests pass 
*           : notifies the user of missing data
* Description: Checks for required values and valid dates
*
* Maintenance Log
* -----------------------------------------------------------------------------
*    Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function validateMarketOpp()
{
	if(document.frmArticleSubmission.cmbCategory.selectedIndex == 0)
	{
		alert('The field "Category" is required in order to save.');
		document.frmArticleSubmission.cmbCategory.focus();
	}
	else if(document.frmArticleSubmission.txtTitle.value == 0)
	{
		alert("The field \"Article Title\" is required in order to save.");
		document.frmArticleSubmission.txtTitle.focus();
	}
	else if(document.frmArticleSubmission.txtText.value == 0 && 
			(document.frmArticleSubmission.txtAttachment.value == 0 && 
			document.frmArticleSubmission.txtArticle.value == 0) )
	{
		alert("The field \"Article Text\" OR \"Attachment\" is required in order to save.");
		document.frmArticleSubmission.txtText.focus()		
	}
	else if(document.frmArticleSubmission.txtStartDate.value == 0)
	{
		alert("The field \"Start Date\" is required in order to save.");
		document.frmArticleSubmission.txtStartDate.focus();		
	}
	else if(document.frmArticleSubmission.txtEndDate.value == 0)
	{
		alert("The field \"End Date\" is required in order to save.");
		document.frmArticleSubmission.txtEndDate.focus();		
	}
	else if(document.frmArticleSubmission.txtName.value == 0)
	{
		alert("The field \"Name\" is required in order to save.");
		document.frmArticleSubmission.txtName.focus();
	}
	else if(document.frmArticleSubmission.txtPhone.value == 0 & 
			document.frmArticleSubmission.txtEmail.value == 0)
	{
		alert("The field \"Phone\" OR \"Email\" is required in order to save.");
		document.frmArticleSubmission.txtPhone.focus();
	}
	else if(validDate(document.frmArticleSubmission.txtStartDate.value) == false)
	{
		alert("Please enter a valid date for the field \"Start Date\" before saving.");
		document.frmArticleSubmission.txtStartDate.focus();
	}
	else if(validDate(document.frmArticleSubmission.txtEndDate.value) == false)
	{
		alert("Please enter a valid date for the field \"End Date\" before saving.");
		document.frmArticleSubmission.txtEndDate.focus();
	}
	else if(bGetFileExtension(document.frmArticleSubmission.txtArticle.value.toLowerCase()) == "bat" || 
			bGetFileExtension(document.frmArticleSubmission.txtArticle.value.toLowerCase())== "exe" || 
			bGetFileExtension(document.frmArticleSubmission.txtArticle.value.toLowerCase())== "dll")
	{
		alert(bGetFileExtension(document.frmArticleSubmission.txtArticle.value.toLowerCase()));
		alert("This file extension is not permitted. Please choose another file.");
		document.frmArticleSubmission.txtArticle.focus();
		return;
	}
	else
	{
		document.frmArticleSubmission.txtSubmitted.value = true;
		document.frmArticleSubmission.submit();
	}
}

/******************************************************************************
 Name      : resetMarketOpp()
 Author    : TMC - Daenna Currie
 Purpose   : reset marketingOpportunities.asp 
 Parameters: 
 Returns   : 
 Description: Sets the values to what they were when the page loaded

 Maintenance Log
 -----------------------------------------------------------------------------
    Who          |   When            |  Why
 -----------------------------------------------------------------------------
  Daenna Currie  |  Aug 2002         | Initial Creation
*******************************************************************************/
function resetMarketOpp()
{
	document.frmArticleSubmission.reset();
}

/************************************************************************************
 Name      : validateContest()
 Author    : TMC - Darcy Wagner
 Purpose   : validate ContestDisplay.asp
 Parameters: none
 Returns   : Submits the form if all tests pass 
			: notifies the user of missing data
 Description: Checks for required values
 Maintenance Log
 ----------------------------------------------------------------------------------
         Who         |   When            |  Why
 ----------------------------------------------------------------------------------
  Darcy Wagner        |   Aug 2002        | Initial Code
***********************************************************************************/
function validateContest(intType)
{
    var intIndex = document.frmContest.Country.selectedIndex;       
    var strCountry = document.frmContest.Country.options[intIndex].value;

    if (intType == 1 && document.frmContest.txtEssay.value < '1') 
    {
	    alert("The Contest text is required.");
		document.frmContest.txtEssay.focus();
	}
    else if(document.frmContest.FName.value < '1')
	{
		alert("The field \"First name\" is required.");
		document.frmContest.FName.focus();
	}
    else if(document.frmContest.LName.value < '1')
	{
		alert("The field \"Last name\" is required.");
		document.frmContest.LName.focus();
	}	
    else if(document.frmContest.Add2.value < '1')
	{
		alert("The field \"Street Address\" is required.");
		document.frmContest.Add2.focus();
	}	
    else if(document.frmContest.City.value < '1')
	{
		alert("The field \"City\" is required.");
		document.frmContest.City.focus();
	}
    else if ((document.frmContest.prov_st.selectedIndex == 0) && (strCountry == "N/A" || strCountry == "CA" || strCountry == "US")) 
	{
   		alert("The field \"Prov/State\" is required.");
    	document.frmContest.prov_st.focus();
	}	
    else if(document.frmContest.post_zip.value < '1')
	{
		alert("The field \"Postal Code / Zip Code\" is required.");
		document.frmContest.post_zip.focus();
	}	
    else if(document.frmContest.Country.selectedIndex == 0)
	{
		alert("The field \"Country\" is required.");
		document.frmContest.Country.focus();
	}	
    else if ((document.frmContest.Other_State.value < '1') && (strCountry != "CA" && strCountry != "US")) 
	{
   		alert("The field \"Prov/State/Region\" is required.");
    	document.frmContest.Other_State.focus();
	}	
    else if(document.frmContest.email.value < '1')
	{
		alert("The field \"Email\" is required.");
		document.frmContest.email.focus();
	}	
	else
	{
		document.frmContest.txtSubmitted.value = true
		document.frmContest.submit();
	}
}


/************************************************************************************
* Name      : validateArticleSearch()
* Author    : TMC - Daenna Currie
* Purpose   : validate articleSearch.asp
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for valid dates entered on the form 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Daenna Currie       |   Aug 2002        | Initial Code
************************************************************************************/
function validateArticleSearch()
{
	if((document.frmArtSearch.txtStartDate.value != 0) & (validDate(document.frmArtSearch.txtStartDate.value) == false))
	{
		alert("Please enter a valid date for the field \"Start Date\" before searching.");
		document.frmArtSearch.txtStartDate.focus();

	}
	else if((document.frmArtSearch.txtEndDate.value != 0) & (validDate(document.frmArtSearch.txtEndDate.value) == false))
	{
		alert("Please enter a valid date for the field \"End Date\" before searching.");
		document.frmArtSearch.txtEndDate.focus();
	}
	else
	{
		document.frmArtSearch.submit();
	}
}


/************************************************************************************
* Name      : addMediaGroup()
* Author    : TMC - Daenna Currie
* Purpose   : add a group from the media group drop down to the 
			: cmbGroupSelected listbox
* Parameters: 
* Returns   : 
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Daenna Currie       |   Aug 2002        | Initial Code
************************************************************************************/
function addMediaGroup() 
{
	
	var Index = document.frmMedia.cmbGroup.selectedIndex;
	if (Index != 0) 
	{
		/* An Option object is created with the arguments "Three" and "3". The first 
		argument is the text that will appear in the list. The second argument is 
		the value for that Option. The length of the Select List is 
		retrieved, which is one more than the index of the last element in the list. So, 
		a new Object is added to the options array by using that number. 
		
		document.createElement("Option") does not work in NS 6
		*/
		var sText = document.getElementById("cmbGroup").options[Index].text;
		var sValue = document.getElementById("cmbGroup").options[Index].value;
		var newOpt  = new Option(sText, sValue);
		var selLength = document.getElementById("cmbGroupSelected").length;
		document.getElementById("cmbGroupSelected").options[selLength] = newOpt;
		document.getElementById("cmbGroup").options[0].selected = true;
	}
	
	
	/* the following works in IE only
	
	var Index = document.frmMedia.cmbGroup.selectedIndex;
	if (Index != 0) 
	{
		var oOption = document.createElement("OPTION");
		oOption.text = document.frmMedia.cmbGroup.options[Index].text;
		oOption.value = document.frmMedia.cmbGroup.options[Index].value;
		document.frmMedia.cmbGroupSelected.add(oOption);
		document.frmMedia.cmbGroup.options[0].selected = true;
	}
	
	*/
}

/************************************************************************************
* Name      : removeGroup()
* Author    : TMC - Daenna Currie
* Purpose   : removes a group from the listbox 
* Parameters: 
* Returns   : 
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Daenna Currie       |   Aug 2002        | Initial Code
************************************************************************************/
function removeGroup() 
{
	var List = document.frmMedia.cmbGroupSelected;
    for(var i=List.options.length;i>0;i--)
    {
		if (List.options[i-1].selected) 
		{
			List.remove(List.options[i-1].index);
		}
    }
}

/************************************************************************************
* Name      : makeCriteria()
* Author    : TMC - Daenna Currie
* Purpose   : sets all the values in the cmbGroupSelected as SELECTED
* Parameters: 
* Returns   : 
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Daenna Currie       |   Aug 2002        | Initial Code
************************************************************************************/
function makeCriteria() 
{
	var f = document.frmMedia;
	var sSelected = ''
	// THESE MUST DONE. It's mark them as selected which builds a list of ID's seperated by comma's.
	for(var i=f.cmbGroupSelected.options.length;i>0;i--) 
	{
		//f.cmbGroupSelected.options[i-1].selected = true;
		if(i!=1)
		{
			sSelected = sSelected + f.cmbGroupSelected.options[i-1].value + ","
		}
		else
		{
			sSelected = sSelected + f.cmbGroupSelected.options[i-1].value
		}
	}
	sSelected = sSelected + ''
	document.frmMedia.txtSelectedValues.value = sSelected
	
}

/******************************************************************************
* Name      : validateEmailMedia()
* Author    : TMC - Daenna Currie
* Purpose   : validate EmailMediaArticles.asp 
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for required values
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  TMC - Daenna Currie |   Aug 2002        | Initial Code
*******************************************************************************/
function validateEmailMedia()
{	
	makeCriteria();
	if(document.frmMedia.txtSubject.value == 0)
	{
		alert("The field \"Subject:\" is required in order to send.");
		document.frmMedia.txtSubject.focus();
		return;
	}
	else if(document.frmMedia.cmbGroupSelected.options.length == 0)
	{
		alert("The field \"Media Group:\" is required in order to send.");
		document.frmMedia.cmbGroup.focus();
		return;
	}
	else if(bGetFileExtension(document.frmMedia.txtFile.value.toLowerCase()) == "exe" ||
	        bGetFileExtension(document.frmMedia.txtFile.value.toLowerCase())== "dll" ||
	        bGetFileExtension(document.frmMedia.txtFile.value.toLowerCase())== "bat")
	{
		alert("This file extension is not permitted. Please choose another file.");
		document.frmMedia.txtFile.focus();
		return;
	}
	else
	{	
		document.frmMedia.submit();
	}
}


/******************************************************************************
* Name      : showPrint()
* Author    : TMC - Darcy Wagner
* Purpose   : open up the clients print dialog for their browser
* Parameters: none
* Returns   : none
* Description: open up the clients print dialog for their browser
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  Darcy Wagner |   Aug 2002        | Initial Code
*******************************************************************************/
function showPrint()
{
    window.print();
}

/************************************************************************************
* Name      : validateimagesolicitation()
* Author    : TMC - Paul Sitter
* Purpose   : validate imagesolicitation.asp
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for valid dates entered on the form 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Paul Sitter         |   Aug 2002        | Initial Code
************************************************************************************/
function validateimagesolicitation()
{
	var strTest = document.frmImage.txtPhoto.value
	
	if(!document.frmImage.optAgree[0].checked)
	{	
		alert("In order to submit your image you must agree to the terms and conditions")
		document.frmImage.optAgree[0].focus()
	}
	else if(document.frmImage.txtDate.value <='')
	{
		alert("Please enter a \"Season/Date Taken\"")
		document.frmImage.txtDate.focus()
	}
	else if(document.frmImage.txtDescription.value <='')
	{
		alert("Please enter a \"Description\"")
		document.frmImage.txtDescription.focus()
	}
	else if(document.frmImage.txtName.value <='')
	{
		alert("Please enter a \"Name\"")
		document.frmImage.txtName.focus()
	}
	else if(document.frmImage.txtEmail.value <='')
	{
		alert("Please enter an \"Email\"")
		document.frmImage.txtEmail.focus()
	}
	else if(document.frmImage.txtPhoto.value <='')
	{
		alert("Please select a photo to attach")
		document.frmImage.txtPhoto.focus()
	}
	
	
	/*
	else if(bGetFileExtension(strTest.toLowerCase()) == "exe" || 
	        
	        bGetFileExtension(strTest.toLowerCase())== "dll" || 
	        bGetFileExtension(strTest.toLowerCase())== "bat")
	{
		alert("This file extension is not permitted. Please choose another file");
		document.frmImage.txtPhoto.focus();
		return false
	}
	*/
	else
	{
		document.frmImage.submit();
	}
}


/************************************************************************************
* Name      : validateClassified()
* Author    : TMC - Daenna Currie
* Purpose   : validate classifiedAds.asp
* Parameters: 
* Returns   : Submits the form if all tests pass 
*			: notifies the user of missing data
* Description: Checks for valid dates entered on the form 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Daenna Currie       |   Aug 2002        | Initial Code
************************************************************************************/
function validateClassified()
{
	if(document.frmClassified.txtTitle.value == 0)
	{
		alert("Please enter a \"Title\" before saving.");
		document.frmClassified.txtTitle.focus();
	}
	else if(document.frmClassified.txtText.value == 0)
	{
		alert("Please enter \"Text\" before saving.");
		document.frmClassified.txtText.focus();
	}
	else if(!validDate(document.frmClassified.txtStartDate.value))
	{
		alert("Please enter a valid date for the field \"Start Date\" before saving.");
		document.frmClassified.txtStartDate.focus();
	}
	else if((document.frmClassified.txtPhone.value == 0) && (document.frmClassified.txtEmail.value == 0))
	{
		alert('Please enter either "Phone" or "Email" before saving.');
		document.frmClassified.txtPhone.focus();
	}
	else
	{
		var nDays
		if(document.frmClassified.cmbEndDate.value == '1')
		{
			nDays = 7
		}
		else if(document.frmClassified.cmbEndDate.value == '2')
		{
			nDays = 14
		}
		else if(document.frmClassified.cmbEndDate.value == '3')
		{
			nDays = 21
		}
		else if(document.frmClassified.cmbEndDate.value == '4')
		{
			nDays = 28
		}
		
		document.frmClassified.txtEndDate.value = dateAdd(document.frmClassified.txtStartDate.value, nDays)
		document.frmClassified.submit();
	}
}


/************************************************************************************
* Name      : dateAdd()
* Author    : TMC - Daenna Currie
* Purpose   : add months, days, years to a date
* Parameters: 
* Returns   : the new date
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Daenna Currie       |   Aug 2002        | Initial Code
************************************************************************************/
function dateAdd(sStartDate, nDays)
{
	var returnDate = new Date(sStartDate)
	returnDate.setTime(returnDate.getTime()+60000*60*24*nDays)
	return returnDate;
}

/************************************************************************************
* Name      : savecoupon()
* Author    : TMC - Darcy Wagner
* Purpose   : Validate and submit the coupon form
* Parameters: none
* Returns   : none
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Darcy Wagner        |   Sept 2002        | Initial Code
************************************************************************************/
function savecoupon()
{
	if(document.frmCoupon.txtBusinessName.value == 0)
	{
		alert("Please enter a \"Business Name\" before saving.");
		document.frmCoupon.txtBusinessName.focus();
	}
	else if(document.frmCoupon.txtHeading.value == 0)
	{
		alert("Please enter a \"Heading\" before saving.");
		document.frmCoupon.txtHeading.focus();
	}
	else if(document.frmCoupon.txtDescription.value == 0)
	{
		alert("Please enter a \"Description\" before saving.");
		document.frmCoupon.txtDescription.focus();
	}
	else if((document.frmCoupon.txtExpiryDate.value == 0) || (validDate(document.frmCoupon.txtExpiryDate.value) == false))
	{
		alert("Please enter a vaild date for the field \"Expiry Date\" before saving.");
		document.frmCoupon.txtExpiryDate.focus();
	}
	else
	{
        document.frmCoupon.submit();
    }
}

/************************************************************************************
* Name      : SayOKcoupon()
* Author    : TMC - Darcy Wagner
* Purpose   : Display message for a set amount of time
* Parameters: none
* Returns   : none
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Darcy Wagner        |   Sept 2002        | Initial Code
************************************************************************************/
function SayOKcoupon()
{
	objTimer = window.setTimeout('gotocouponmenu()',2000);
}

/************************************************************************************
* Name      : gotocouponmenu()
* Author    : TMC - Darcy Wagner
* Purpose   : Redirect to coupon Admin
* Parameters: none
* Returns   : none
* Description: 
*
* Maintenance Log
* ----------------------------------------------------------------------------------
*          Who         |   When            |  Why
* ----------------------------------------------------------------------------------
*  Darcy Wagner        |   Sept 2002        | Initial Code
************************************************************************************/
function gotocouponmenu()
{
	document.location.href = 'couponadmin.asp';
}

/******************************************************************************
* Name      : validateMembership()
* Author    : TMC - Daenna Currie
* Purpose   : Validates membership.asp before submitting
* Parameters: none
* Returns   : none
* Description: checks the capacity field to ensure the value entered is a number
*
* Maintenance Log
* -----------------------------------------------------------------------------
*          Who         |   When            |  Why
* -----------------------------------------------------------------------------
*  Daenna Currie       |   Sept 2002       | Initial Code
******************************************************************************/
function validateMembership()
{
	// check for empty select box
	if(document.frmMembership.cmbVoting.selectedIndex == -1)
	{
		alert('Please select a "Voting Member" before saving.');
		document.frmMembership.cmbVoters.focus();
	}
	if(document.frmMembership.cmbSector.selectedIndex == -1)
	{
		alert('Please select a "Sector" before saving.');
		document.frmMembership.cmbSector.focus();
	}
	if(document.frmMembership.txtCapacity.value != 0)
	{
		if(isNaN(parseInt(document.frmMembership.txtCapacity.value)))
		{
			alert("The capacity entered is not a number.");
			document.frmMembership.txtCapacity.focus();
		}
		else
		{
			document.frmMembership.submit();
		}
	}
	else
	{
		document.frmMembership.submit();
	}
}

function opencoupon(intCouponId) {
strFeatures = "top=40,left=40,width=450,height=360,toolbar=no," 
	+ "scrollbars=no,menubar=no,location=no,directories=no";
objNewWindow = window.open("../utils/coupondetails.asp?couponId=" + intCouponId, "CouponDetails", strFeatures);

}  


/* 
------------------------------------------------------------------
spawnWindow()
Parameters: url, window name, window height, window width)

- opens up a window at the top left with the 
  specified height and width
- shows the menu bar, tool bar, and status bar so the user can print
------------------------------------------------------------------
*/

function spawnWindow(URL,name,height, width){
	window.open(URL+"?winwidth="+width+"&winheight="+height,name,"menubar=1,location=0,toolbar=1,personalbar=0,status=1,scrollbars=1,height="+height+",width="+width+" ,left=80,top=20")
	
}


function ListNotes( orgID)
{

	wind=window.open("default.asp?page=213&plain=1&selOrg=" + orgID, "ListAllNotes", "status=yes,location=yes,toolbar=yes,width=600,height=450,resizable=yes,scrollbars=yes,left=600,top=100");
	wind.focus();

	return false;
}




 function AddATask(strDate, orgID)
 {
	var market_id = document.getElementById("market").value + "";
	market_id = parseInt( market_id );
	

	if( !isNaN(market_id))
	{
		if( !isNaN( parseInt( orgID))){ orgID="&org_id=" + orgID; }else{ orgID=""; }

		wind=window.open("CalendarTask.asp?market_id=" +market_id+ "&no_reload=1&plain=1&list=no_list&doWhat=add" + orgID + "&the_date="+ strDate, "AddATask", "status=yes,location=yes,toolbar=yes,width=600,height=450,resizable=yes,scrollbars=yes,left=600,top=100");
		wind.focus();
	}
	return false;
 }
 
 
 
  function EditATask(strDate, orgID)
  {
 	var market_id = document.getElementById("market").value + "";
 	market_id = parseInt( market_id );

 	var note_id = document.formMarketplaceNotes.note_id.value + "";
 	note_id = parseInt( note_id );
 	
 		
 	if( !isNaN(market_id))
 	{
 		if( !isNaN( parseInt( orgID))){ orgID="&org_id=" + orgID; }else{ orgID=""; }
 
 		wind=window.open("CalendarTask.asp?note_id="+note_id+"&market_id=" +market_id+ "&no_reload=1&plain=1&list=no_list&doWhat=edit" + orgID + "&the_date="+ strDate, "EditATask", "status=yes,location=yes,toolbar=yes,width=600,height=450,resizable=yes,scrollbars=yes,left=600,top=100");
 		wind.focus();
 	}
 	return false;
 }
 
 
 
 
 
  function AddATaskForOrg(strDate, orgID)
  { 

	if( !isNaN( parseInt( orgID))){ orgID="&org_id=" + orgID; }else{ orgID=""; }

	wind=window.open("CalendarTask.asp?no_reload=1&plain=1&list=no_list&doWhat=add" + orgID + "&the_date="+ strDate, "AddATask", "status=yes,location=yes,toolbar=yes,width=600,height=450,resizable=yes,scrollbars=yes,left=600,top=100");
	wind.focus();
 		
 	return false;
 }
 
 
 
  
function CreateOrgProfile( orgID, type )
{ 

	if( !isNaN( parseInt( orgID))){ orgID="&org_id=" + orgID; }else{ orgID=""; }
	
	wind=window.open("CreateOrgProfile.asp?&plain=1" + orgID, "OrgProfile", "status=yes,location=yes,toolbar=yes,width=600,height=450,resizable=yes,scrollbars=yes,left=600,top=100");
	wind.focus();

	return false;
}
 
 
 
 
 function queryString_old()
 {
 	var strURL = window.location + "";
 	arrURLPieces = strURL.split("\&");
 	if (arrURLPieces.length > 3 )
 	{
 		arrSmallerPieces = arrURLPieces[3].split("=");
 		if (( arrSmallerPieces.length = 2) && (!isNaN(arrSmallerPieces[1])))
 		{
 			return parseInt(arrSmallerPieces[1]);
 		}
 		else return 0;
 	}
 	else
 	{
 		return 0;	
 	}
 }



 
  function queryString(param_name)   // returns a named value from the querystring
  {
     //var tmp = ( location.search.substring(1) );
     var tmp = window.location + "";
     var i   = tmp.toUpperCase().indexOf( param_name.toUpperCase()+"=");
  
     if ( i >= 0 )
     {
        tmp = tmp.substring( param_name.length+i+1 );
        i = tmp.indexOf("&");
        var pr = unescape( tmp = tmp.substring( 0, (i>=0) ? i : tmp.length ));
        return pr;
     }
  
     return "";
  }
 
 
 
  function selectYourMatch()
  {
     var fish_id = queryString("fish");
 
     if (!isNaN( parseInt( fish_id+"")))
     {
        document.getElementById("fishSelect").options[fish_id].selected = true;
     }
  
     return;
 }


 
//  ************************************************
//  ITINERARY 
//  ************************************************

/*

- page loads
- script sets timer to call flash to see if ready




*/

 // get our flash movie object
 function itinerary_init() {
 	if (document.getElementById("itineraryflash")) {
	  window.setTimeout( mi_set_anchor_day, 100,true);
	  // window.setTimeout( mi_check_flash, 100,true);
	}
 }
 
 var itinerary_flash_ready = 0;
 var mi_shown_day = 0; 

 function mi_itinerary_flash_ready() {
 	itinerary_flash_ready = 1;
 }

function mi_check_flash() {

}

function mi_set_flash_day() {
 	var urlString = ""+document.location.href;
 	var lastCharPosition = urlString.length;
 	var anchorStartPosition = urlString.search("#");
 	
 	if (anchorStartPosition > 0) {
		var anchorValue = urlString.substring(anchorStartPosition+4, lastCharPosition );
		day_num = parseInt(anchorValue);
		if (day_num+"" == "NaN") {
			return 1;
		} else {
			return day_num;
		}
 	}
 	return 1;
}

 function mi_set_anchor_day() {
 	var urlString = ""+document.location.href;
 	var lastCharPosition = urlString.length;
 	var anchorStartPosition = urlString.search("#");
 	var anchorValue = urlString.substring(anchorStartPosition+1, lastCharPosition );
 	for (x = 1; x < 10; x++) {
 		obj = document.getElementById("day"+x+"tab");
 		if (obj) {
 			obj.onclick = function() {
 				mi_itinerary_day(this);
 			}
 		}
 		obj = document.getElementById("bookmark"+x);
 		if (obj) {
 			obj.onclick = function() {
 				mi_itinerary_day(this);
 			}
 		}
 	}
 	if (document.getElementById(anchorValue+"tab")) {
 		mi_itinerary_day(document.getElementById(anchorValue+"tab"));
 	} else {
 		mi_itinerary_day(document.getElementById("day1tab"));
 	}
 }
 
 
 
 
 function mi_addLoadEvent(func) {
 	var oldonload = window.onload;
 	if (typeof window.onload != 'function') {
 		window.onload = func;
 	}
 	else {
 		window.onload = function() {
 			oldonload();
 			func();
 		}
 	}
}
 
 
 function mi_itinerary_day(obj) {
 	var id = obj.id;
 	var x = 1;
 	var day = 1;
 	
 	// take the class off the other tabs...
 	for (x = 1; x < 10; x++) {
 		testobj = document.getElementById("day"+x+"tab");
 		if (testobj) {
 			testobj.className = "off";
 			if (testobj.id == obj.id) {
 				day = x;
 			}
 		}
 		testobj = document.getElementById("bookmark"+x);
 		if (testobj) {
 			testobj.className = "off";
 			if (testobj.id == obj.id) {
 				day = x;
 			}
 		}
 	}
 	if (day > 0) {
		document.getElementById("day"+day+"tab").className = "on";
		document.getElementById("bookmark"+day).className = "on";
 	}
 	
 	// show the day page
 	for (x = 1; x < 10; x++) {
 		testobj = document.getElementById("day"+x+"page");
 		if (testobj) {
 			if (testobj.id != id) {
 				testobj.style.display = "none";
 			}
 		}
 	}
 	document.getElementById("day"+day+"page").style.display = "block";
 
 	// now communicate with the flash
 	if (day > 0) {
 		// document.getElementById("itineraryflash").updateText(day);
 		if (mi_shown_day == 0) {
	 		mi_shown_day = 1;
 		} else {
	 		window.setTimeout( "mi_itinerary_day_flash("+day+")", 100);
 		}
 	} else {
 		alert("Error: day=" + day);
 	}
 }
 
 function mi_itinerary_day_flash(day) {
 	document.getElementById("itineraryflash").updateText(day);
 }
 
 

// wait for the page to fully load before initializing
 mi_addLoadEvent(itinerary_init);
 
 
// arrgh... ifr doesn't work 
//  mi_addLoadEvent(doIFR);
 
 
 function doIFR() {
// 	setTimeout(runIFR, 1000);
 }
 
 function runIFR() {
//  sIFR.replaceElement(named({sSelector:"h3", sFlashSrc:"/images_tr/flash_titles/sifr-themixplain.swf", sColor:"", sLinkColor:"", sBgColor:"", sHoverColor:"", nPaddingTop:0, nPaddingBottom:0,sFlashVars:""}));
 }
 
 
 function show_search_form23()
 {
 	$.get("/SearchFromMap.asp",
 	{quantity: 3},
 	function(my_options)
 	{
 		if(my_options !="")
 		{
 			$("#map_search").html(my_options);
 		}
 		else
 		{
 			document.getElementById("map_search").innerHTML="";
 		}
 	});
 
}
 
 
 
 

function OrgProfileReportFormSend( version )
{
	if(version=="web")
	{
		$.get("/SelectMarketplaceData.asp",
		{ org_id: document.getElementById("lstOrgs").value,
		  doWhat:"create_org_profile"
		  },
		  function(my_options)
		  {
			  $("#profile_spot").html(my_options);
		  });
	 }
	 else if(version=="print")
	 {
		var org_id= document.getElementById("lstOrgs").value;
		window.open("SelectMarketplaceData.asp?doWhat=create_org_profile&plain=1&org_id="+org_id, "OrgProfile", "menubar=1,width=800,height=600,resizable=yes,scrollbars=yes,left=100,top=50");
	 }
}

 
 
 
function ScrollToSpot( my_num )
{	
	// scroll to the spot with id indicated
	var scroll_to_spot_y = document.getElementById("product_"+my_num).offsetTop;
	scroll_to_spot_y = scroll_to_spot_y + 50;
	window.scrollTo(0, scroll_to_spot_y );
	    
	return false;
}
 
 
 
 
function SelectData2( my_marketi, my_form_name )
{
	eval( "document." + my_form_name + ".brand.value = '';" );
	eval( "document." + my_form_name + ".marketplace_name.value = '';" );
	
	$.get("SelectMarketplaceData.asp",
	{ doWhat:"select2",
	  marketi: my_marketi,
	  form_name: my_form_name
	},
	function(my_options)
	{
		$("#" + my_form_name + "_Options").html(my_options);
	});

}
 
 
 

function MarketplaceReportFormSend( do_this )
{

	var strSDate = "";
	var strEDate = "";
	var exl_file = "";

	if( document.getElementById("media_file").checked )
	{ exl_file = "1"; }


	var  my_market_id = "";
	var  my_event_brand_id = "";
	
	if( document.getElementById("marketi_all").checked )
	{ 
		my_market_id = "999999";
	
	}
	else
	{
		arr_checked_markets = document.frmTemp2.marketi;
		var comma = "";
		var comma1 = "";
		for(var i=0; i<arr_checked_markets.length; i++)
		{
			if( arr_checked_markets[i].checked)
			{
				
				my_market_id += comma + arr_checked_markets[i].value;
				comma = ",";
				
				var curr_marketi_id = arr_checked_markets[i].value;
				
			        if( document.getElementById("brand_all_of_market_"+curr_marketi_id).checked)
			        {
					for(var k=0; k<10; k++)
					{
						if( document.getElementById("brand_"+k+"_of_market_"+curr_marketi_id) )
						{
							my_event_brand_id += comma1 +  document.getElementById("brand_"+k+"_of_market_"+curr_marketi_id).value;
							comma1=",";
						}
					}
				}
				else
				{
					for(var k=0; k<10; k++)
					{
						if( document.getElementById("brand_"+k+"_of_market_"+curr_marketi_id) && document.getElementById("brand_"+k+"_of_market_"+curr_marketi_id).checked  )
						{
							my_event_brand_id += comma1 +  document.getElementById("brand_"+k+"_of_market_"+curr_marketi_id).value;
							comma1=",";
						}
					}				
				}
			}
		}
	}
	

	$("#marketplace_spot").html("");

	if( my_market_id+"" == "")
	{
		alert("Please select market(s) to run the report");
		return;
	}
	

	strSDate = document.frmTemp.start_month.value + "/"  + document.frmTemp.start_date.value + "/" +document.frmTemp.start_year.value ;
	strEDate = document.frmTemp.end_month.value + "/"  + document.frmTemp.end_date.value + "/" +document.frmTemp.end_year.value ;


	if( !isItDate( strSDate ) || !isItDate( strEDate ))
	{
		alert( strSDate );
		alert( strEDate );
		return;
	}

	
	
	if( do_this == "markets" )
	{

		$.get("SelectMarketplaceData.asp",
		{ marketi: my_market_id,
		  marketplace_brands:my_event_brand_id,
		  doWhat:"market_data_for_report",
		  start_date:strSDate,
		  end_date:strEDate,
		  media:exl_file
		  },
		  function(my_options)
		  {
			$("#marketplace_spot").html(my_options);
		  });
	 }
	 else if( do_this == "sales" )
	 {

		$.get("SelectMarketplaceData.asp",
		{ marketi: my_market_id,
		  marketplace_brands:my_event_brand_id,
		  doWhat:"market_counts_for_report",
		  start_date:strSDate,
		  end_date:strEDate,
		  media:exl_file
		  },
		  function(my_options)
		  {
			$("#sales_spot").html(my_options);
		  });
	 }
	  
	  
}




function MakeAList_1(markt_id)
{
	$.get("OrgsDropdown.asp",
	{ search_for: document.getElementById("search_for").value,
	  exclude_orgs_of:markt_id},
	function(my_options)
	{
		$("#list_orgproducts").html(my_options);

		document.getElementById("list_orgproducts_second_part").style.display="block";
	});
}








function MarketplaceCountReportFormSend(my_marketbrand_id)
{

	var strSDate = "";
	var strEDate = "";
	var exl_file = "";

	if( document.getElementById("media_file").checked )
	{ exl_file = "1"; }


	if( my_marketbrand_id+"" == "0")
	{
		$("#marketplace_spot").html("");
		return;
	}

	//if( my_marketbrand_id+"" == "999999")
	//{
		$("#sales_spot").html("");

		strSDate = document.frmTemp.start_month.value + "/"  + document.frmTemp.start_date.value + "/" +document.frmTemp.start_year.value ;
		strEDate = document.frmTemp.end_month.value + "/"  + document.frmTemp.end_date.value + "/" +document.frmTemp.end_year.value ;


		if( !isItDate( strSDate ) || !isItDate( strEDate ))
		{
			alert( strSDate );
			alert( strEDate );
			return;
		}
	//}


	$.get("SelectMarketplaceData.asp",
	{ marketplacebrand_id: my_marketbrand_id,
	  doWhat:"market_counts_for_report",
	  start_date:strSDate,
	  end_date:strEDate,
	  media:exl_file
	  },
	  function(my_options)
	  {
		  $("#sales_spot").html(my_options);
	  });
}



 
 
 
function SelectData1( my_obj, max_length )
{
	if(!my_obj)
	{ return;   }
	
	if( my_obj.id =="marketi_all")
	{
		for(var j=0; j<max_length; j++)
		{
			var table_id = document.getElementById('marketi_'+j).value;
			
			for(var i=0; i<10; i++)
			{
				if(document.getElementById("brand_"+i+"_of_market_" + table_id ) )
				{
					document.getElementById("brand_"+i+"_of_market_" + table_id ).checked = false;
				}
			}			
			
			document.getElementById("options_" + table_id ).style.display = "none";		
			document.getElementById('marketi_'+j).checked=false;
		}	
	}
	else
	{
		var table_id = my_obj.value;
		if(my_obj.checked)
		{ 
			document.getElementById('marketi_all').checked=false; 
			document.getElementById("options_" + table_id ).style.display = "block";
			document.getElementById("brand_all_of_market_" + table_id ).checked =true;	
		}
		else
		{	
			for(var i=0; i<10; i++)
			{
				if(document.getElementById("brand_"+i+"_of_market_" + table_id ) )
				{
					document.getElementById("brand_"+i+"_of_market_" + table_id ).checked = false;
				}
			}			
			
			document.getElementById("options_" + table_id ).style.display = "none";
		}		
	}
	
	return;
}



function openWin(url, w, h)
{
	var winprop = "width=" + w + ",height=" + h;
	openwin = window.open('maps/index.html','','width=800,height=600',winprop);
}





function ManageLogeRegion( pass )
{

	if( pass==140 && document.getElementById("lodge").checked )
	{
		document.getElementById("outfitter").checked=false;
	}


	if( pass==141 && document.getElementById("outfitter").checked )
	{
		document.getElementById("lodge").checked = false;
	}



	if( document.getElementById("outfitter").checked  )
	{

		document.getElementById("lstRegion").selectedIndex=0;
		document.getElementById("lstRegion").disabled=true;
	}
	else
	{
		document.getElementById("lstRegion").disabled=false;
	}

	return;

}



function SubmitContactForm ()
{

	var oForm = document.forms.ContactUs; 
	var sError = ""; 
	if (oForm.txtEmail.value=="" || !ValidateFormEmail("ContactUs.txtEmail") ) sError+= "Please enter a valid email address\n";
	if (oForm.txtTopic.value=="") sError+= "Please enter an inquiry topic\n";
	if (oForm.txtMessage.value=="") sError+= "Please include a message containing\nyour inquiry or comments\n";
	if(sError == "") 
	{ 
		oForm.submit(); 
	} else { 
		alert(sError+""); 
	}

	return;
}


	
	
function assignOrgIds()
{
	var strComma = "";
	var strResult = "";
	if(document.forOrgsOnly && document.forOrgsOnly.org_ids )
	{
		for(var j=0; j<document.forOrgsOnly.org_ids.length; j++ )
		{				if(document.forOrgsOnly.org_ids[j].checked)
			{
				strResult += strComma + document.forOrgsOnly.org_ids[j].value;
				strComma = ", ";
			}
		}
	}

	return strResult;
}




function themeChange( cur_value )
{
	if( !isNaN( parseInt( cur_value+"" ) ) )
	{
		document.frmListOffers.action='/OffersAndPackages/Theme' + cur_value +'/';
	}
	else
	{
		document.frmListOffers.action='/OffersAndPackages/';
	}

	return;
}




function ValidateBookingData()
{
	var error_message = "";

	if( isNaN( parseInt( document.frmBookOffer.nights.value+""))   && !document.frmBookOffer.nights_n_a.checked  )
	{ error_message += "\nEnter number of nights or mark as Not Applicable";}

	if(String((document.frmBookOffer.last_name.value+"").replace(/\ /gi,"")) == "")
	{ error_message += "\nLast name is required";}

	if(String((document.frmBookOffer.first_name.value+"").replace(/\ /gi,"")) == "")
	{ error_message += "\nFirst name is required";}

	if(String((document.frmBookOffer.phone.value+"").replace(/\ /gi,"")) == "")
	{ error_message += "\nPhone number is required";}

	if(isNaN(parseInt(document.frmBookOffer.adults.value+"") ) )
	{ error_message += "\nEnter a number of adults or 0 if none";}

	if(isNaN(parseInt(document.frmBookOffer.children.value+"") ) )
	{ error_message += "\nEnter a number of children or 0 if none";}

	if(  !ValidateFormDate( "frmBookOffer.date_start" ) )
	{ error_message += "\nWrong start date";}

	/*
	if(  !ValidateFormDate( "frmBookOffer.date_end" ) )
	{ error_message += "\nWrong end date";}
	*/

	if(  !ValidateFormEmail( "frmBookOffer.email" ) )
	{ error_message += "\nWrong email address";}


	if( error_message == "" )
	{
		document.frmBookOffer.submit();
	}
	else
	{
		alert(error_message + "\n\nPlease, enter all required data and submit the form again");
	}

	return false;
}


function ValidateEmails( Quantity_Of_Emails )
{
	var error_message = "";
	var no_addresses_flag = true;

	var sender_address = document.email_to_friend.sender.value + "";
	sender_address = sender_address.replace(/\ /gi, "");
	if( sender_address == "" )
	{
		error_message += "\nEnter your email address";
	}
	else
	{
		if(  !ValidateFormEmail2( "email_to_friend.sender" ) )
		{
			error_message += "\nInvalid sender email address ";
		}

	}


	for( var i=0; i< Quantity_Of_Emails; i++)
	{
		var email_address_value = "";
		eval( "email_address_value = ''+document.email_to_friend.email"+i+".value;");
		email_address_value = email_address_value.replace(/\ /gi, "");

		if( email_address_value != "" )
		{
			if(  !ValidateFormEmail2( "email_to_friend.email"+i ) )
			{
				var k = i+1;
				error_message += "\nInvalid email address in line " + k;
			}

			no_addresses_flag = false;
		}
	}


	if( no_addresses_flag)
	{
		error_message += "\nEnter email address to send the message to";
	}

	if( error_message == "" )
	{
		document.email_to_friend.submit();
	}
	else
	{
		alert(error_message + "\n\nPlease, enter valid data and submit the form again");
	}


	return false;
}



function validateFreeStuff( num )
{
	var bChecked = false;
	for (var i=0; i < num; i++)
	{
		if (document.getElementById("package_"+i).checked)
		{
			bChecked = true;
			break;
		}
	}


	if (!bChecked)
	{
		alert("Please select a free package.");
	}
	else
	{
		document.frmFreeStuff.submit();
	}

	return false;
}



function validateInfoRequest()
{
	if (document.frmInfoRequest.first_name.value == "")
	{
		alert("Please enter your first name.");
		document.frmInfoRequest.first_name.focus();
		return;
	}
	if (document.frmInfoRequest.last_name.value == "")
	{
		alert("Please enter your last name.");
		document.frmInfoRequest.last_name.focus();
		return;
	}

	if (document.frmInfoRequest.address1.value == "" && document.frmInfoRequest.address2.value == "")
	{
		alert("Please enter your address.");
		document.frmInfoRequest.address1.focus();
		return;
	}

	if (document.frmInfoRequest.city.value == "")
	{
		alert("Please enter your city.");
		document.frmInfoRequest.city.focus();
		return;
	}

	if (document.frmInfoRequest.country.value == "N/A")
	{
		alert("Please select your Country.");
		document.frmInfoRequest.country.focus();
		return;
	}


	if (document.frmInfoRequest.country.value == "US" || document.frmInfoRequest.country.value == "CA" )
	{
		if (document.frmInfoRequest.province.value == "N/A")
		{
			alert("Please select your Canadian Province or US State.");
			document.frmInfoRequest.province.focus();
			return;
		}
		if (document.frmInfoRequest.postal.value == "")
		{
			alert("Please enter your Postal Code/Zip Code.");
			document.frmInfoRequest.postal.focus();
			return;
		}
	}



	if (document.frmInfoRequest.email.value == "")
	{
		alert("Please enter your email.");
		document.frmInfoRequest.email.focus();
		return;
	}
	else if( true )
	{
		//echeck2(document.frmInfoRequest.email.value+"")
	}
	

	if (document.frmInfoRequest.how_found.value == "N/A")
	{
		alert("Please indicate how did you find our site.");
		document.frmInfoRequest.how_found.focus();
		return;
	}

	


	if (document.frmInfoRequest.purpose.value== "N/A")
	{

		alert("Please indicate a purpose of your trip");
		document.frmInfoRequest.purpose.focus();
		return;

	}

	

	if ( !document.frmInfoRequest.opt_in[0].checked && !document.frmInfoRequest.opt_in[1].checked && !document.frmInfoRequest.opt_in[2].checked )
	{
		alert("Please indicate if you would like to receive Travel Manitoba offers.");
		document.frmInfoRequest.opt_in[0].focus();
		return;
	}

	

	if ( (document.frmInfoRequest.comment.value +"").length>500 )
	{
		var extra = (document.frmInfoRequest.comment.value +"").length-500;

		alert("Please, limit your comment to 500 characters. You have " + extra + " extra characters.");
		document.frmInfoRequest.comment.focus();
		return;

	}

	
	
	document.frmInfoRequest.submit();
	return false
}




function goToLocation()
{
	location = "default.asp?page=200594";
}




function openSubscribeWindow()
{
	window.open('/RegisterForNewsletterNow/?page=253', 'Register_now', 'location=yes,width=600,height=700,resizable=yes,scrollbars=yes,left=100,top=100');
	return;
}
