// JavaScript Flash Invite

function getFlashMovie(movieName) {
	if (document.embeds[movieName]) return document.embeds[movieName];
	if (window.document[movieName]) return window.document[movieName];
	if (window[mivoeName]) return window[movieName];
	if (document[movieName]) return document[movieName];
	return null;
//	var isIE = navigator.appName.indexOf("Microsoft") != -1;
//	return (isIE) ? window[movieName] : document[movieName];
}
 
function sendEventRecipient(){
 	var text = document.pageform.event_recipient_name.value;
  	getFlashMovie("swfTemplate").sendRecipient(text);
}

function sendEventName(){
 	var text = document.pageform.event_name.value;
  	getFlashMovie("swfTemplate").sendEventName(text);
}

function sendEventOrganizedby(){
 	var text = document.pageform.event_organizer_name.value;
	if (text != ''){text = 'You\'re invited to participate in a group gift!\n Organized by ' + text;}
	getFlashMovie("swfTemplate").sendOrganizedby(text);
}

function sendEventMessage(){
 	var text = document.pageform.event_desc.value;
 	getFlashMovie("swfTemplate").sendMessage(text);
}

function clearInfo(){
	document.pageform.eName_Coordinates.value = '';
	document.pageform.eRecipient_Coordinates.value = '';
	document.pageform.eOrganizedby_Coordinates.value = '';
	document.pageform.eMessage_Coordinates.value = '';
	getFlashMovie("swfTemplate").resetFlashForm();
}

function saveJPG(navURL){
	//Display Saving animated Gif
	showStatus_Loading(1, 1);
	try{
		document.pageform.navigation.value = navURL;
		getFlashMovie("swfTemplate").saveJPGFlash();
	}catch(err){
		//alert(err);
		showStatus_Loading(0, 1);
	}
}

function getTextFromFlash(nameVariable,nameValue){
	if ( nameVariable == 'eName') { document.pageform.eName_Coordinates.value = nameValue; }
	if ( nameVariable == 'eRecipient') { document.pageform.eRecipient_Coordinates.value = nameValue; }
	if ( nameVariable == 'eOrganizedby') { document.pageform.eOrganizedby_Coordinates.value = nameValue; }
	if ( nameVariable == 'eMessage') { document.pageform.eMessage_Coordinates.value = nameValue; }
	return "received.";
}

function getFilenameFromFlash(nameField){
	var tempFilename = nameField.replace(/%2F/gi,"/");
	tempFilename = tempFilename.replace(/%5F/gi, "_");
	tempFilename = tempFilename.replace(/%2E/gi, ".");
	tempFilename = tempFilename.replace(/=/gi, "");
	document.pageform.img_filename.value = tempFilename;
	
	var tempURL = document.pageform.navigation.value;
	//alert(tempURL);
	//Clear default text
	clearDefaultText(document.pageform.event_name);
	clearDefaultText(document.pageform.event_recipient_name);
	clearDefaultText(document.pageform.event_organizer_name);
	clearDefaultText(document.pageform.event_desc);
	if (tempURL.indexOf('savelater') > -1) {
		if (tempURL.indexOf('msavelater') > -1) {
			//alert('submitForm(document.pageform, ' + tempURL + ');');
			submitForm(document.pageform,tempURL);
		} else
			sendFormData(document.pageform, '/create/save/?nav=savelater&referer=' + location.href, '/create/save/savelater.asp', null, 600, 400);
	}
	else {
		//alert('submitForm(document.pageform, ' + tempURL + ');');
		submitForm(document.pageform, tempURL);
	};
	//alert(tempURL);
	
	//submitForm(document.pageform,'nav=preview');
	

	
	//
// return "received.";
}