// START JAVA SCRIPT FOR DYNAMIC DROP DOWNS.
// Function myOptions
function myOptions (text,value) {
  this.text = text;
  this.value = value;
}
// End of function myOptions

// Add Canadian States.
// @author: Shilpi Modi
// @date modified: 07/24/2002.
// @desc: 50 US States and 1 Territory DC
states = new Array();
states[0] = new Array();
states[0][0] = new myOptions("AL", "AL");
states[0][1] = new myOptions("AK", "AK");
states[0][2] = new myOptions("AR", "AR");
states[0][3] = new myOptions("AZ", "AZ");
states[0][4] = new myOptions("CA", "CA");
states[0][5] = new myOptions("CO", "CO");
states[0][6] = new myOptions("CT", "CT");
states[0][7] = new myOptions("DC", "DC");
states[0][8] = new myOptions("DE", "DE");
states[0][9] = new myOptions("FL", "FL");
states[0][10] = new myOptions("GA", "GA");
states[0][11] = new myOptions("HI", "HI");
states[0][12] = new myOptions("IA", "IA");
states[0][13] = new myOptions("ID", "ID");
states[0][14] = new myOptions("IL", "IL");
states[0][15] = new myOptions("IN", "IN");
states[0][16] = new myOptions("KS", "KS");
states[0][17] = new myOptions("KY", "KY");
states[0][18] = new myOptions("LA", "LA");
states[0][19] = new myOptions("MA", "MA");
states[0][20] = new myOptions("MD", "MD");
states[0][21] = new myOptions("ME", "ME");
states[0][22] = new myOptions("MI", "MI");
states[0][23] = new myOptions("MN", "MN");
states[0][24] = new myOptions("MS", "MS");
states[0][25] = new myOptions("MO", "MO");
states[0][26] = new myOptions("MT", "MT");
states[0][27] = new myOptions("NE", "NE");
states[0][28] = new myOptions("NC", "NC");
states[0][29] = new myOptions("ND", "ND");
states[0][30] = new myOptions("NH", "NH");
states[0][31] = new myOptions("NJ", "NJ");
states[0][32] = new myOptions("NM", "NM");
states[0][33] = new myOptions("NV", "NV");
states[0][34] = new myOptions("NY", "NY");
states[0][35] = new myOptions("OH", "OH");
states[0][36] = new myOptions("OK", "OK");
states[0][37] = new myOptions("OR", "OR");
states[0][38] = new myOptions("PA", "PA");
states[0][39] = new myOptions("RI", "RI");
states[0][40] = new myOptions("SC", "SC");
states[0][41] = new myOptions("SD", "SD");
states[0][42] = new myOptions("TN", "TN");
states[0][43] = new myOptions("TX", "TX");
states[0][44] = new myOptions("UT", "UT");
states[0][45] = new myOptions("VT", "VT");
states[0][46] = new myOptions("VA", "VA");
states[0][47] = new myOptions("WA", "WA");
states[0][48] = new myOptions("WI", "WI");
states[0][49] = new myOptions("WV", "WV");
states[0][50] = new myOptions("WY", "WY");

// Add Canadian States.
// @author: Shilpi Modi
// @date modified: 07/24/2002.
// @desc: Canadian Provinces.
states[1] = new Array();
states[1][0] = new myOptions("AB", "AB");
states[1][1] = new myOptions("BC", "BC");
states[1][2] = new myOptions("MB", "MB");
states[1][3] = new myOptions("NB", "NB");
states[1][4] = new myOptions("NF", "NF");
states[1][5] = new myOptions("NT", "NT");
states[1][6] = new myOptions("NS", "NS");
states[1][7] = new myOptions("NU", "NU");
states[1][7] = new myOptions("ON", "ON");
states[1][8] = new myOptions("PE", "PE");
states[1][9] = new myOptions("QC", "QC");
states[1][10] = new myOptions("SK", "SK");
states[1][11] = new myOptions("YT", "YT");


// Add Other State
// @author: Shilpi Modi
// @date modified: 07/25/2002.
// @desc: Other Countries.
states[2] = new Array();
states[2][0] = new myOptions("--", "--");

// Function relateStates
function relateStates (selIndex) {
  // alert("Selected Index: " + selIndex);
    var len = document.frmCreate_Invitation.eventState.options.length;
  // alert("state LENGTH: " + len);
  for (var i = document.frmCreate_Invitation.eventState.options.length-1; i >= 0; i-- ) {
    document.frmCreate_Invitation.eventState.options[i] = null;
  }

  for (i=0; i < states[selIndex].length; i++ ) {
    document.frmCreate_Invitation.eventState.options[i] = new Option(states[selIndex][i].text, states[selIndex][i].value);
    // alert("Selected Index Text: " + states[selIndex][i].text);

    if (i == 0) {
      document.frmCreate_Invitation.eventState.options[i].selected = true;
    }
  }
}
// End of function relateStates

function clickSpamMoreInfo() {
	document.frmCreate_Invitation.clickValue.value = "spamMoreInfo";
	document.frmCreate_Invitation.submit();
} // clickImportContacts

function clickImportContacts() {
	document.frmCreate_Invitation.clickValue.value = "importContacts";
	document.frmCreate_Invitation.submit();
} // clickImportContacts

function clickSaveAndLogin() {
	document.frmCreate_Invitation.clickValue.value = "saveAndLogin";
	document.frmCreate_Invitation.submit();
} // clickImportContacts

function clickSaveForm() {
	document.frmCreate_Invitation.clickValue.value = "save";
	document.frmCreate_Invitation.submit();
} // clickSaveForm

function clickUpdateForm() {
	document.frmCreate_Invitation.clickValue.value = "update";
	document.frmCreate_Invitation.submit();
} // clickUpdateForm

function clickSendForm() {
	document.frmCreate_Invitation.clickValue.value = "send";
	//document.frmCreate_Invitation.submit();
} // clickSendForm

function clickPreviewForm() {
	document.frmCreate_Invitation.clickValue.value = "preview";
	document.frmCreate_Invitation.submit();
} // clickPreviewForm

function clickChooseAnotherDesignForm() {
	document.frmCreate_Invitation.clickValue.value = "chooseAnotherDesign";
	if (document.frmCreate_Invitation.searchGallery.value == "Search Invitations") {
		document.frmCreate_Invitation.searchGallery.value = "";
	}	
	document.frmCreate_Invitation.submit();
} 

function clickDesignYourOwnForm() {
	document.frmCreate_Invitation.clickValue.value = "designYourOwn";
	document.frmCreate_Invitation.submit();
} 

function clickPreviewTemplateForm() {
	document.frmCreate_Invitation.clickValue.value = "previewTemplate";
	document.frmCreate_Invitation.submit();
} 

function clickPreviewInvitationEmail() {
	popupWin('','650','730','yes','yes','no','no','InvitationPreview','no','no','center');
	document.frmCreate_Invitation.target = 'InvitationPreview';
	document.frmCreate_Invitation.clickValue.value = "previewInvitationEmail";
	document.frmCreate_Invitation.clickInsideForm.value = "false";
	document.frmCreate_Invitation.submit();
	document.frmCreate_Invitation.target = "";
} 

	function attitudeChoice(index) {
		document.frmCreate_Invitation.attitudeWill.value = askName[index];
		document.frmCreate_Invitation.attitudeAttend.value = yesName[index];
		document.frmCreate_Invitation.attitudeUndecided.value = undecidedName[index];
		document.frmCreate_Invitation.attitudeDecline.value = noName[index];
	}
	
	
   	var askName=
      [
		"Who's Coming?",
		"",
		"What's Your Major?",
		"Who's Shakin'?",
		"Who's Gonna Make It?",
		"Who's In?",
		"The Team",
		"Who's Rallying?",
		"Who's a Shredder?",
		"Who's Playing?",
		"What's the Verdict?",
		"Who's on Stage?",
		"Who's Attending?",
		"Who's In?",
		"Who's Connected?",
		"Are You Coming or What?",
	    "Up for Drinks?",
	    "Who's Toasting?",
	    "What's the Word, Ladies?",
	    "Are We Cookin'?",
	    "Who's Coming to Dinner?",
	    "Up for a Treasure Hunt, Matey?",
	    "Are You There?",
	    "Got Game?",
	    "Who's Rolling?",
	    "Ante Up",
	    "Come Strong or Not at All",
	    "Who's Campaigning?",
	    "The Credits",
	    "Joining the Cast?",
	    "To Be or Not to Be?"
	    
   ];	
	

  var yesName=
      [
		"Yes",
		"",
		"Declared",
		"Full Embrace",
		"Alive & Kicking",
		"On Board",
		"Starters",
		"Full Throttle",
		"Black Diamond",
		"Nothin' but Net",
		"Committed",
		"Cheer",
		"With Pleasure",
		"Absolutely",
		"Site Found",
		"Totally",
       	"Let it Flow",
       	"I'll Drink to That",
       	"I Have the Perfect Outfit",
       	"Hot to Trot",
       	"Bring a Chair to the Table",
       	"Aye, Aye Cap'n",
       	"Are You There?",
       	"Bring it On",
       	"I'm in, Collect $100 and Pass Go",
       	"All In",
       	"I'm Coming in Hot",
       	"Count on My Vote",
       	"Taking the Stage",
       	"Ready for My Close-Up",
       	"To Be"
      ];
  
  var noName=
      [
		"No",
		"",
		"Dropping Out",
		"Cold Shoulder",
		"Flat-liners",
		"On the way out",
		"Cut",
		"Out of Gas",
		"Green Circle",
		"Air ball",
		"Jumped Bail",
		"Boo",
		"Regrets",
		"Unthinkable",
		"Error 404",
		"Bummer",
        "On the Wagon",
        "My Glass is Empty",
        "Washing My Hair",
        "Cold Turkey",
        "I'll Take Leftovers",
        "Argh, I'm Walking the Plank",
        "MIA",
        "Sore Loser",
        "Stuck in Jail, Lose a Turn",
        "Bust",
        "I'm Weak",
        "Not Gonna Do It",
        "Call My Understudy",
        "I'll Never Work in this Town Again",
        "Not to Be"
	];
  
    var undecidedName=
      [
		"Maybe",
		"",
		"Undeclared",
		"Weak Handshake",
		"Barely there",
		"On the Fence",
		"On the Bench",
		"Stalled",
		"Blue Square",
		"Rim Shot",
		"Jury's Out",
		"Yawn",
		"Perhaps",
		"Hmmm",
		"Still Loading",
		"Whatever",
      	"Cutting Back",
      	"I Might Raise a Glass",
      	"Checking My Calendar",
      	"Lukewarm",
      	"Save a Plate for Me",
      	"Shiver Me Timbers, I Can't Decide",
      	"Didn't Copy, Please Repeat",
      	"Still Readin' the Rules",
      	"Not Sure How the Dice Will Fall",
      	"Split",
      	"I Can't Sort Myself Out",
      	"Flip Flop",
      	"Waiting in the Wings",
      	"Have Your People Call My People",
      	"That is the Question"
      ];
   
           
// END JAVA SCRIPT FOR DYNAMIC DROP DOWNS.

function checkPaidYes() {
	if(document.frmCreate_Invitation.paid[0].value == 'yes') {
		document.frmCreate_Invitation.paid[0].checked=true;
	}
}

// CHANGE RECUR MODULE
	function selectRecurWeekly() {
		var weeklyCheck = false;
			if(document.frmCreate_Invitation.sunday.checked == true) {
				weeklyCheck = true;
			} else if(document.frmCreate_Invitation.monday.checked == true) {
				weeklyCheck = true;
			} else if(document.frmCreate_Invitation.tuesday.checked == true) {
				weeklyCheck = true;
			} else if(document.frmCreate_Invitation.wednesday.checked == true) {
				weeklyCheck = true;
			} else if(document.frmCreate_Invitation.thursday.checked == true) {
				weeklyCheck = true;
			} else if(document.frmCreate_Invitation.friday.checked == true) {
				weeklyCheck = true;	
			} else if(document.frmCreate_Invitation.saturday.checked == true) {
				weeklyCheck = true;		
			}
			if(weeklyCheck == true) {
				document.frmCreate_Invitation.recurEventType[0].checked = true;
			}
	}
	
	function selectEndDateWeekly(){
		document.frmCreate_Invitation.recurEndPeriodType[0].checked = true;
	}
	
	function selectEndDateMonthly(){
		document.frmCreate_Invitation.recurEndPeriodType[1].checked = true;
	}
	function selectRecurMonthly() {
		document.frmCreate_Invitation.recurEventType[1].checked = true;
	}


	// CHANGE RECUR MODULE
	function changeRecurModule(fieldID, sDate) {
		sDate = formatDDate(fieldID);
		sPattern = "MM/d/yy";
		
		if(sDate.length == 10){
			sPattern = "MM/d/yyyy";
		}
		var eviteDate = new EviteDate(sDate, sPattern);
		// Proicess only if valid
		if(eviteDate.isValid()) {
			var nameDayOfWeek = eviteDate.get(eviteDate.NAME_DAY_OF_WEEK);
			var eviteWeekOfMonth = eviteDate.get(eviteDate.EVITE_WEEK_OF_MONTH);
			var monthlyDisplay = "";
			var weekOfMonthText = "";
			var monthWeek = "";
			// alert("eviteDate.getFormattedDate()="+eviteDate.getFormattedDate());	
			// alert("eviteDate.EVITE_WEEK_OF_MONTH="+eviteDate.get(eviteDate.EVITE_WEEK_OF_MONTH));
			// alert("eviteDate.NAME_DAY_OF_WEEK="+eviteDate.get(eviteDate.NAME_DAY_OF_WEEK));
			
			switch(eviteWeekOfMonth) {
				case 1:
				{
					weekOfMonthText = "First ";
					monthWeek = "1";
					break;
				} 
				case 2:
				{
					weekOfMonthText = "Second ";
					monthWeek = "2";
					break;
				}
				case 3:
				{
					weekOfMonthText = "Third ";
					monthWeek = "3";
					break;
				}
				case 4:
				{
					weekOfMonthText = "Fourth ";
					monthWeek = "4";
					break;
				}
				case 5:
				{
					weekOfMonthText = "Last ";
					monthWeek = "L";
					break;
				}
			}
			
			// uncheckDayOfWeek(nameDayOfWeek);
			if(nameDayOfWeek=="Sunday") {
				document.frmCreate_Invitation.sunday.checked=true;
				monthlyDisplay = weekOfMonthText + "Sunday";
		    } else if(nameDayOfWeek=="Monday") {
				document.frmCreate_Invitation.monday.checked=true;
				monthlyDisplay = weekOfMonthText + "Monday";
			} else if(nameDayOfWeek=="Tuesday") {
				document.frmCreate_Invitation.tuesday.checked=true;
				monthlyDisplay = weekOfMonthText + "Tuesday"; 
			} else if(nameDayOfWeek=="Wednesday") {
				document.frmCreate_Invitation.wednesday.checked=true;
				monthlyDisplay = weekOfMonthText + "Wednesday";
			} else if(nameDayOfWeek=="Thursday") {
				document.frmCreate_Invitation.thursday.checked=true;
				monthlyDisplay = weekOfMonthText + "Thursday";
			} else if(nameDayOfWeek=="Friday") {
				document.frmCreate_Invitation.friday.checked=true;
				monthlyDisplay = weekOfMonthText + "Friday";
			} else if(nameDayOfWeek=="Saturday") {
				document.frmCreate_Invitation.saturday.checked=true;
				monthlyDisplay = weekOfMonthText + "Saturday";
			}
			
			// alert("eviteDate.getFormattedDate('MM d, yyyy')="+eviteDate.getFormattedDate('MM d, yyyy'));
			// alert("eviteDate.getFormattedDate('MMM d, yy')="+eviteDate.getFormattedDate('MMM d, yy'));
			// alert("eviteDate.getFormattedDate('NNN d, y')="+eviteDate.getFormattedDate('NNN d, y'));
			// alert("eviteDate.get(eviteDate.EVITE_WEEK_OF_MONTH)="+eviteDate.get(eviteDate.EVITE_WEEK_OF_MONTH));
			// alert("eviteDate.get(eviteDate.YEAR)="+eviteDate.get(eviteDate.YEAR));
			// alert("eviteDate.get(eviteDate.WEEK_OF_MONTH)="+eviteDate.get(eviteDate.WEEK_OF_MONTH));
		} else {
			monthlyDisplay = "----------------";
			document.frmCreate_Invitation.sunday.checked=false;
			document.frmCreate_Invitation.monday.checked=false;
			document.frmCreate_Invitation.tuesday.checked=false;
			document.frmCreate_Invitation.wednesday.checked=false;
			document.frmCreate_Invitation.thursday.checked=false;
			document.frmCreate_Invitation.friday.checked=false;
			document.frmCreate_Invitation.saturday.checked=false;
			// alert("Date is invalid");
		}
		var monthlyText = document.getElementById("monthlyTextValue");
		monthlyText.innerHTML=monthlyDisplay;
		document.frmCreate_Invitation.monthlyDisplay.value=monthlyDisplay;
		document.frmCreate_Invitation.monthWeek.value=monthWeek;
	}

	
	function uncheckDayOfWeek(nameDayOfWeek) {
		if(nameDayOfWeek != "Sunday") {
			document.frmCreate_Invitation.sunday.checked=false;
		} 
		if(nameDayOfWeek != "Monday") {
			document.frmCreate_Invitation.monday.checked=false;
		}
		if(nameDayOfWeek != "Tuesday") {
			document.frmCreate_Invitation.tuesday.checked=false;
		}
		if(nameDayOfWeek != "Wednesday") {
			document.frmCreate_Invitation.wednesday.checked=false;
		}
		if(nameDayOfWeek != "Thursday") {
			document.frmCreate_Invitation.thursday.checked=false;
		}
		if(nameDayOfWeek != "Friday") {
			document.frmCreate_Invitation.friday.checked=false;
		}
		if(nameDayOfWeek != "Saturday") {
			document.frmCreate_Invitation.saturday.checked=false;
		}
	}
	
// this function is created to turn off Include Map Module for country other then "US"
function switchIncludeMapModule(sCountry) {
	var includeMapDiv = document.getElementById("includeMapDiv");
	
	if("US" == sCountry) {
		includeMapDiv.style.display = "block";
	} else {
		includeMapDiv.style.display = "none";
		document.frmCreate_Invitation.mapLink.checked = false;
	}	
}


function toggleDiv(e, link) {
  var imageTitle;
  var div = document.getElementById(e);
  var linkDiv = document.getElementById(link);
  var display = div.style.display;

  if (display == "none") {
    div.style.display = "block";
    imageTitle = "grn_dn.gif";
  }
  else if (display == "block") {
    div.style.display = "none";
    imageTitle = "grn_rt.gif";
  }
  if(linkDiv != null) {
  	linkDiv.innerHTML = "<a href=\"\" onClick=\"toggleDiv('" + e + "','" + link + "'); return false;\"><img src=\"/images/06/arrows/"+ imageTitle +"\" width=\"11\" height=\"11\" border=\"0\"></a>";
  }
}
	
function toggleDivForRegistry(e, link) {
	  var imageTitle;
	  var div = document.getElementById(e);
	  var linkDiv = document.getElementById(link);
	  var display = div.style.display;

	  if (display == "none") {
	    div.style.display = "block";
	    imageTitle = "grn_dn.gif";
	  }
	  else if (display == "block") {
	    div.style.display = "none";
	    imageTitle = "grn_rt.gif";
	  }
	  if(linkDiv != null) {
	  	linkDiv.innerHTML = "<a href=\"\" onClick=\"toggleRegistryDiv(); return false;\"><img src=\"/images/06/arrows/"+ imageTitle +"\" width=\"11\" height=\"11\" border=\"0\"></a>" +
	  					   "<img src='/images/t.gif' width='5' height='1'><a href=\"\" onClick=\"toggleRegistryDiv(); return false;\" class=\"crGreen\">Add a Target Registry</a>";
	  }
	}

function toggleRegistryDiv(){
	var eventType = document.frmCreate_Invitation.eventType.value;
	var registryCouple = document.frmCreate_Invitation.registryCouple.value;
	var registryType = document.frmCreate_Invitation.registryType.value;
	if(isNull(registryCouple) == true && (eventType == 'Wedding_Themes_top' || eventType == 'Baby_Shower_top')){
		if(eventType == 'Wedding_Themes_top'){
			toggleDivForRegistry('regWedding','addRegistryDiv');
		} else if(eventType == 'Baby_Shower_top'){
			toggleDivForRegistry('regBaby','addRegistryDiv');
		}
	} else if(isNull(registryType) == false){
		if(registryType == 'wedding'){
			changeDivTag('regWedding','none');
			toggleDivForRegistry('regWeddingConfirm','addRegistryDiv');
		} else if(registryType == 'babyreg'){
			changeDivTag('regBaby','none')
			toggleDivForRegistry('regBabyConfirm','addRegistryDiv');
		}			
	}
}

function displayRegistryDiv(){
	var eventType = document.frmCreate_Invitation.eventType.value;
	var registryCouple = document.frmCreate_Invitation.registryCouple.value;

      if(show_registry == true){
 	    if(eventType == 'Wedding_Themes_top'){
 		   if(isNull(registryCouple)){
 		   	 toggleRegistryDiv();
 		   	 changeDivTag('regBaby', 'none');
    			// changeDivTag('regWedding','block');
    			// changeDivTag('regBaby','none');
    		   }
 		   changeDivTag('addRegistryDiv','block');
 	    } else if(eventType == 'Baby_Shower_top'){
 		   if(isNull(registryCouple)){
 		     toggleRegistryDiv();
 		     changeDivTag('regWedding', 'none');
    			 // changeDivTag('regBaby','block');
    			 // changeDivTag('regWedding','none');
 		   }
    		   changeDivTag('addRegistryDiv','block');
    	    } else {
    		   changeDivTag('regWedding','none');
    		   changeDivTag('regBaby','none');
    		   if(isNull(registryCouple)){
    		   	  changeDivTag('addRegistryDiv','none');
    		   } else {
    		      changeDivTag('addRegistryDiv','block');
    		   }
        }	     	
   
      }
}

function displayGiftExchangeDiv(){
	var eventType = document.frmCreate_Invitation.eventType.value;
	if(eventType == 'gift_exchange'){
		changeDivTag('gift','block');
	} else {
		if(document.frmCreate_Invitation.includeGiftExchange.checked == false){
			changeDivTag('gift','none');
		}
	}
}

function submitTargetRegistryBabyForm(){
	var firstName = document.frmCreate_Invitation.targetFirstnameBaby.value;
	var lastName = document.frmCreate_Invitation.targetLastnameBaby.value;
	var targetRoleValue = getRadioValue(document.frmCreate_Invitation.targetRoleBaby);
	var url = "/app/invitations/create/target/getTargetRegistryInfo.do";
	url += "?firstname=" + firstName + "&lastname=" + lastName;
	url += "&location="+ document.frmCreate_Invitation.targetLocationBaby.value;
	url += "&eventMonth="+ document.frmCreate_Invitation.targetEventMonthBaby.value;
	url += "&role=" + targetRoleValue;
	url += "&type=babyreg";
	url += "&newSearch=true";
	if(isNull(firstName) == true || isNull(lastName) == true){
		alert('The first & last names are required.');
	} else {
		popupWin(url,'613', '580','yes','yes','no','no','DependentWindow','no','no','center');
	}
}

function submitTargetRegistryWeddingForm(){
	var targetRoleValue = getRadioValue(document.frmCreate_Invitation.targetRoleWedding);
	var firstName =  document.frmCreate_Invitation.targetFirstnameWedding.value;
	var lastName =  document.frmCreate_Invitation.targetLastnameWedding.value
	var url = "/app/invitations/create/target/getTargetRegistryInfo.do";
	url += "?firstname=" +firstName + "&lastname=" + lastName;
	url += "&location="+ document.frmCreate_Invitation.targetLocationWedding.value;
	url += "&eventMonth="+ document.frmCreate_Invitation.targetEventMonthWedding.value;
	url += "&role=" + targetRoleValue;
	url += "&type=wedding";
	url += "&newSearch=true";
	if(isNull(firstName) == true || isNull(lastName) == true){
		alert('The first & last names are required.');
	} else {
		popupWin(url,'613', '580','yes','yes','no','no','DependentWindow','no','no','center');
	}
}

function removeRegistration(){
	document.frmCreate_Invitation.registryCouple.value = "";
	document.frmCreate_Invitation.registryURL.value = "";
	document.frmCreate_Invitation.registryType.value = "";
	document.frmCreate_Invitation.clickInsideForm.value= "";
	
	document.frmCreate_Invitation.submit();
}
function popDesignGallery(Invite_ID, themeName) {
	eventTypeParam = escape(document.frmCreate_Invitation.eventType.options[document.frmCreate_Invitation.eventType.selectedIndex].value);
	uniPop('/pages/invitations/gallery/index.jsp?Invite_ID='+Invite_ID+'&type=' + eventTypeParam +'&theme='+themeName+'&pg=1&src=create','designGallery','650','632','toolbar=no','scrollbars=no','resizable=no','status=no');
}

function selectMyLocation1() {
	document.frmCreate_Invitation.selectMyLocation.value = 'true';
	document.frmCreate_Invitation.clickInsideForm.value = 'true';
	document.frmCreate_Invitation.selectVenueFromPopup.value = 'no';
	document.frmCreate_Invitation.submit();
} // selectMyLocation1


function selectWhatToBring80() {
	document.frmCreate_Invitation.whatToBringAdd80.value = 'true';
	document.frmCreate_Invitation.clickInsideForm.value = 'true';
	document.frmCreate_Invitation.submit();
} // selectWhatToBring

function deSelectWhatToBring80() {
	document.frmCreate_Invitation.whatToBringAdd80.value = 'false';
	document.frmCreate_Invitation.clickInsideForm.value = 'true';
	document.frmCreate_Invitation.submit();
} // deSelectWhatToBring


function generateCustomDesignURL() {
	var createForm = document.frmCreate_Invitation;
	var params = "/pages/invitations/create/popupCustomDesign.jsp?";
	params += "mainImgID="+createForm.iconID.value+"&";
	params += "backgroundImgID="+createForm.backgroundImgID.value+"&";
	params += "mainImgName="+createForm.iconName.value+"&";
	params += "backgroundImgName="+createForm.backgroundImgName.value+"&";
	params += "customColor="+createForm.customColor.value+"&";
	params += "pageTextColor="+createForm.pageTextColor.value+"&";
	params += "eventTitleTextColor="+createForm.eventTitleTextColor.value+"&";
	params += "headerBarColor="+createForm.headerBarColor.value+"&";
	params += "headerBarTextColor="+createForm.headerBarTextColor.value+"&";
	params += "linkTextColor="+createForm.linkTextColor.value+"&";
	params += "pageBackgroundColor="+createForm.pageBackgroundColor.value +"&";
	params += "eventType="+createForm.eventType.options[createForm.eventType.selectedIndex].value;
	return params;
}

function delectRecurOptions() {
	// document.frmCreate_Invitation.sunday.checked=false;
	// document.frmCreate_Invitation.monday.checked=false;
	// document.frmCreate_Invitation.tuesday.checked=false;
	// document.frmCreate_Invitation.wednesday.checked=false;
	// document.frmCreate_Invitation.thursday.checked=false;
	// document.frmCreate_Invitation.friday.checked=false;
	// document.frmCreate_Invitation.friday.checked=false;
	document.frmCreate_Invitation.recurEndPeriodType[0].checked=false;
	document.frmCreate_Invitation.recurEndPeriodType[1].checked=false;
	document.frmCreate_Invitation.recurEndPeriodType[2].checked=false;
}

// Logic for display
function toggleSuggestDivTags(div, state)  {
	/// alert("IN TOGGLE SUGGEST DIV TAG");
	var div1 = 'suggestCannotDisplayText';
	var state1 = state;
	if(document.frmCreate_Invitation.recurEventType[0].checked == true || document.frmCreate_Invitation.recurEventType[1].checked == true) {
		// alert('cannot select date time');
		state = 0;
		state1 = 1;
		document.frmCreate_Invitation.letGuestSuggestDate[0].checked = true;
	} else {
		state = 1;
		state1 = 0;
	}
    if(document.layers){
       document.layers[div].visibility = state ? "block" : "none";
    }
  	if(document.getElementById){
        var obj = document.getElementById(div);
        obj.style.display = state ? "block" : "none";
    }
    else if(document.all)	// IE 4
    {
        document.all[div].style.display = state ? "block" : "none";
    }
    
    // DIV 1
  	 if(document.layers){
        document.layers[div1].visibility = state1 ? "block" : "none";
     }
   	if(document.getElementById){
         var obj = document.getElementById(div1);
         obj.style.display = state1 ? "block" : "none";
     }
     else if(document.all)	// IE 4
     {
         document.all[div1].style.display = state1 ? "block" : "none";
     }
}

function toggleRemindersDivs() {
	divBorderName = 'reminders';
	divGoodName   = 'note';
	divBadName    = 'noteCannotDisplayText';
	divLinkName   = 'guestnote';
	var divGood = document.getElementById(divGoodName);
	var divBad  = document.getElementById(divBadName);
	var divBorder = document.getElementById(divBorderName);
	var divGoodVisible = false;
	var divBadVisible  = false;
	var divBorderVisible = false;
	var isRecurringEvent = document.frmCreate_Invitation.isRecurringEvent.value == 'true';
	if(divGood) {
		divGoodVisible = divGood.style.visibility == 'block' || divGood.style.display == 'block';
	}
	if(divBad) {
		divBadVisible  = divBad.style.visibility == 'block' || divBad.style.display == 'block';
	}
	if(divBorder) {
		divBorderVisible = divBorder.style.visibility == 'block' || divBorder.style.display == 'block';
	}
	var showDivBad = isRecurringEvent;
	if(document.frmCreate_Invitation.recurEventType) {
		recurEventType0 = document.frmCreate_Invitation.recurEventType[0];
		recurEventType1 = document.frmCreate_Invitation.recurEventType[1];
		showDivBad = recurEventType0.checked == true || recurEventType1.checked == true;
	}
	/*
	alert("divGood == null: " + (divGood == null) + "\ndivBad == null: " + (divBad == null) + 
		"\ndivGoodVisible: " + divGoodVisible + "\ndivBadVisible: " + divBadVisible + 
		"\nshowDivBad: " + showDivBad);
	*/
	if(!divBorderVisible) {
		if(showDivBad) {
			if(divGoodVisible) {
				toggleDiv(divGoodName, divLinkName, '');
			}
			if(!divBadVisible) {
				toggleDiv(divBadName, divLinkName, '');
			}
		} else {
			if(!divGoodVisible) {
				toggleDiv(divGoodName, divLinkName, '');
			}
			if(divBadVisible) {
				toggleDiv(divBadName, divLinkName, '');
			}
		}
	}
	toggleDiv('reminders', 'guestnote', '');
}

function toggleRecurringOptionDivs(divGoodName, divBadName, divLinkName) {
	var divGood = document.getElementById(divGoodName);
	var divBad  = document.getElementById(divBadName);
	var divGoodVisible = false;
	var divBadVisible  = false;
	var isRecurringEvent = document.frmCreate_Invitation.isRecurringEvent.value == 'true';
	if(divGood) {
		divGoodVisible = divGood.style.visibility == 'block' || divGood.style.display == 'block';
	}
	if(divBad) {
		divBadVisible  = divBad.style.visibility == 'block' || divBad.style.display == 'block';
	}
	var showDivBad = isRecurringEvent;
	if(document.frmCreate_Invitation.recurEventType) {
		recurEventType0 = document.frmCreate_Invitation.recurEventType[0];
		recurEventType1 = document.frmCreate_Invitation.recurEventType[1];
		showDivBad = recurEventType0.checked == true || recurEventType1.checked == true;
	}
	/*
	alert("divGood == null: " + (divGood == null) + "\ndivBad == null: " + (divBad == null) + 
		"\ndivGoodVisible: " + divGoodVisible + "\ndivBadVisible: " + divBadVisible + 
		"\nshowDivBad: " + showDivBad);
	*/
	if(divGoodVisible) {
		toggleDiv(divGoodName, divLinkName, '');
	} else if(divBadVisible) {
		toggleDiv(divBadName, divLinkName, '');
	} else {
		if(showDivBad) {
			toggleDiv(divBadName, divLinkName, '');
		} else {
			toggleDiv(divGoodName, divLinkName, '');
		}
	}
}

function toggleSuggestTimeDiv() {
	toggleDiv('suggest','guest', '');
	var eventDateCheckBoxDisplay = document.getElementById("eventDateCheckBox");
	var suggestDateCheckBoxDisplay = document.getElementById("suggestDateTimeCheckBox");
	
	if(eventDateCheckBoxDisplay.style.display == "none") {
		eventDateCheckBoxDisplay.style.display = "block";
		suggestDateCheckBoxDisplay.style.display = "block";
	} else {
		eventDateCheckBoxDisplay.style.display = "none";
		suggestDateCheckBoxDisplay.style.display = "none";
	}
}

function searchVenue() {
	if(document.frmCreate_Invitation.venueZipcode.value.length == 0 ||
	   document.frmCreate_Invitation.venueKeywords.value.length == 0) {
	   alert("To search for venues, keywords and zipcode information is required.");
	} else {
		var citysearchPopupURI = "/pages/gt/create/venueSearch.jsp?zip="+document.frmCreate_Invitation.venueZipcode.value+"&keywords="+document.frmCreate_Invitation.venueKeywords.value;		
		uniPop(citysearchPopupURI,'VenueSearch','550','550','yes','yes','no','yes');	
	}
}

//DO NOT remove this variable because it is used by Time Suggestions View Calendar
var timeSuggestionCurrentFocus = 'timeSuggestion1';
function timeSuggestionFieldFocus(fieldName) {
	timeSuggestionCurrentFocus = fieldName;
	document.frmCreate_Invitation.letGuestSuggestDate[1].checked = true;
}

function eventDateFieldFocus(formValue) {
	if(formValue.length > 0){
		formValue[0].checked = true;
	} else {
		formValue.checked = true;
	}
//	document.frmCreate_Invitation.letGuestSuggestDate[0].checked = true;
}

function validateMapQuestRequiredFields() {
	var createForm = document.frmCreate_Invitation;
	
	if(createForm.eventStreetAddress.value == null || 
	   createForm.eventCity.value == null ||
	   createForm.eventState.value == null) {
	   alert("Missing Street Address or City or State to generate the Map");
		return false;		   	  	   
	}
	
	if(createForm.eventStreetAddress.value.length == 0 || 
	   createForm.eventCity.value.length == 0 ||
	   createForm.eventState.value.length == 0) {
	   alert("Missing Street Address or City or State to generate the Map");
	   	return false;
	}
	
	var valueWithComma = "";

	if(createForm.eventStreetAddress.value.indexOf(',') != -1) {
		valueWithComma += "Street Address: "+ createForm.eventStreetAddress.value;
	}
	if(createForm.eventCity.value.indexOf(',') != -1) {
		valueWithComma += "\n";
		valueWithComma += "City: "+ createForm.eventCity.value;
	}

	if(valueWithComma.length > 0) {
		alert(" Commas cannot be used in the following fields:\n"+valueWithComma);
		return false;
	}
	
	return true;
}

function generateMapQuestPopup() {
	var createForm = document.frmCreate_Invitation;	
	
	var url="/app/mapping/mapAddress.do?originAddress=";
	url += escape(createForm.eventPlace.value);
	url += "@$@";
	url += escape(createForm.eventStreetAddress.value)+",";
	url += escape(createForm.eventCity.value)+",";
	url += escape(createForm.eventState.value);
	return url;		
}

// for photo reminders
var wantsPhotoCenter;
function checkWantsPhotoCenter() {
	wantsPhotoCenter = document.frmCreate_Invitation.wantsPhotoCenter.checked;
	document.frmCreate_Invitation.sendPhotoReminders.checked = wantsPhotoCenter;
}

function checkSendPhotoReminders() {
	wantsPhotoCenter = document.frmCreate_Invitation.wantsPhotoCenter.checked;
	if(wantsPhotoCenter == false) {
		document.frmCreate_Invitation.wantsPhotoCenter.checked = true;
	}
}
function checkEvery() {
	if(document.frmCreate_Invitation.recurType != null) {
		for(var i=0; i<document.frmCreate_Invitation.recurType.length; i++) {
			if(document.frmCreate_Invitation.recurType[i].value == "<%=RecurringEventControl.RECURRING_EVENT_TYPE_EVERY%>") {
				document.frmCreate_Invitation.recurType[i].checked = true;
			}
		}	
	}
}

function checkMonthly() {
	if(document.frmCreate_Invitation.recurType != null) {
		for(var i=0; i<document.frmCreate_Invitation.recurType.length; i++) {
			if(document.frmCreate_Invitation.recurType[i].value == "<%=RecurringEventControl.RECURRING_EVENT_TYPE_MONTHLY%>") {
				document.frmCreate_Invitation.recurType[i].checked = true;
			}
		}
	}
	
}
function toggleDivTagsRecur(div, state)  {

    if(document.layers){

       document.layers[div].visibility = state ? "block" : "none";
    }
  	if(document.getElementById){
        var obj = document.getElementById(div);
        obj.style.display = state ? "block" : "none";
    }
    else if(document.all)	// IE 4
    {
        document.all[div].style.display = state ? "block" : "none";
    }

	if(document.frmCreate_Invitation.letGuestSuggestDate.length > 0) {
	    document.frmCreate_Invitation.letGuestSuggestDate[0].checked  = true;
	} else {
	  	document.frmCreate_Invitation.letGuestSuggestDate.checked  = true;
	}
}


//-->
