// Global Variables

function addToOutlook(noEventTime, eventId){
	if (noEventTime == 'true'){
		alert('Unable to add event to Outlook / Lotus 6.0 Calendar.\nA date and time was not entered for this event.');
	} else {
		location.href=("/respond/vcal/" + eventId + "/evite.vcs");
	}
}

function addToMyYahooCalendar (noEventTime, sYahooURL){
	if (noEventTime == 'true'){
		alert('Unable to add event to My Yahoo Calendar.\nA date and time was not entered for this event.');
	} else {
		location.href="javascript:uniPop('" + sYahooURL + "','yahoo','775','725')";
	}
}

function checkUpdateModuleClass() {
	var formEditArray = document.editForm.elements;
	var exists = false;
	for (var i = 0; i < formEditArray.length; i++) {
		if (formEditArray[i].name == "moduleJump") {
			exists = true;
		}
	}
	if(exists) {
		document.editForm.moduleJump.value='com.evite.create.guides.ExtraQuestions';
		document.editForm.submit();
	} else {
		document.editForm.module.value='com.evite.create.guides.ExtraQuestions';
		document.editForm.submit();
	}
}


function deleteEvent(eventID) {
 	if(confirm("Are you sure you want to delete this invite draft?")) {
		location.href=("/schedule/delDraft/noheaders/expireNow?eventID=" + eventID);
	}
}

function deleteInvite(inviteID) {
	if(confirm("Are you sure you want to delete this invite?")) {
		location.href=("/schedule/delInvite/noheaders/expireNow?iid=" + inviteID);
	}
}
	
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
  begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// Author: David Rowland
// Date  : 09-17-2002
// Desc  : Goes to URL

function goToURL(rurl){
	document.location=rurl;
}

// Checks for null
function isNull(val)
{
	val += "";
	if ((val == "null") || (val == "") || (val == "undefined"))
	{
		return true;
	}
	else
	{
		return false;
	}
}



function openEmail(id, suffix) {
    var win = window.open('/sendEmail?to=' + id + suffix, '_blank','scrollbars=yes,width=450,height=380,screenX=300,screenY=20,resizable=yes,status=yes,toolbar=yes');
    
    if(navigator.userAgent.indexOf("MSIE 3") == -1)	{
    	win.focus();
    }
}

// Creates a popup window based on specified arguments. A handle to the
// popup window is returned so the developer can programmatically manipulate the
// window after it has been launched.
function getPopupWinHandle(loc, width, height, resizable, scrollbars, toolbar, dependent, winName)
{
	// Evaluate the window arguments.
	var win = eval("window.open(loc, '"
		+ winName
		+ "','width=" + width
		+ ",height=" + height
		+ ",resizable=" + resizable
		+  ",scrollbars=" + scrollbars
		+  ",toolbar=" + toolbar
		+  ",dependent=" + dependent
		+  ",screenX=1,screenY=1,top=1,left=1"
		+  ",status=no,location=no')");
	// Return a handle to the newly created window.
	return win;
} // function getPopupWinHandle

// Creates a popup window based on specified arguments. 
function popupWin(loc, width, height, resizable, scrollbars, toolbar, dependent, winName)
{
	// Here we DO NOT return the handle to the window just created as it may
	// cause problems when embedding JavaScript statements in HTML anchor tags.
	var newWin = getPopupWinHandle(loc, width, height, resizable, scrollbars, toolbar, dependent, winName);
} // function popupWin

function previewEmail(eventID, inviteId)	{
	var previewWinURL = "inviteEmailPreview.jsp?eventId=" + eventID + "&inviteId=" + inviteId;
	var previewWin = window.open(previewWinURL, "Preview", "width=750,height=600,resizable=yes,scrollbars=yes", true);
 	if(navigator.userAgent.indexOf("MSIE 3") == -1)	{
		previewWin.focus();
	}
}

function Start(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,width=250,height=300");
}



function uniPop(href,winname,width,height,toolbar,scrollbars,resizable,status) {
	if (href == "") href = '/support';
	if (winname == 'spellChecker') href+=escape(document.eventForm.notes.value);
	if ((width < 100) || (width == null)) var width = '515';
	if ((height < 100) || (height == null)) var height = '475';
	if (toolbar == null) var toolbar = 'yes';
	if (scrollbars == null) var scrollbars = 'yes';
	if (resizable == null) var resizable = 'yes';
	if (status == null) var status = 'yes';
	var theParam = "width=" +width+ 
					",height=" +height+  
					",toolbar=" +toolbar+ 
					",scrollbars=" +scrollbars+ 
					",resizable=" +resizable+ 
					",status=" +status+
					",screenX=1,screenY=1,top=1,left=1";
	var thePopup = window.open(href,winname,theParam);
}
