// JavaScript Document
var buildsendtomehtml;
var mapbubblehtml;
var submitmediatype;

var pagemode;
var destarray=[];
var desteventarray = [];
var spinarray = [];
var updatedmarker;
var sectionlayouts;
//Added to make the searchfunction.js file compatible
var currentuser;

var globalscenepath;
var globalinputfield = 'blank';
var globalheaderitem;

//MAP GLOBALS
// GLOBAL SWITCHES FOR MAP FUNCTIONALTIY: 0 = Off; 1 = On;
var includemapcontrols = 1;
var includecreatecontrols = 0;
var includecustommarkers = 1;
var includedirections = 1;
var includepano = 1;

// GLOBAL TOGGLES FOR TRAFFIC AND STREETVIEW: 0 = OFF AT PAGELOAD; 1 = ON AT PAGELOAD.
var traffictoggleState = 0;
var panotoggleState = 0;
var searchfuncflag = false

var defaultmapoff;
var mapdiv;
var	mapcontrolsdiv;
var	mapcreatetoolsdiv;
var	mapdirectionsdiv;
var	mappanodiv;
var	mappanodetailsdiv;
var	highslidepanodiv;

//THE FOLLOWING FUNCTION NEEDS TO BE CALLED FROM THE "PAGE SPECIFIC" JAVASCRIPT FILE TO SET THE GLOBAL DIVS NEEDED FOR THE CORRESPONDING FUNCTIONS.
function setmapglobals(){
	
	mapdiv = document.getElementById("greetingmap");
	defaultmapoff = document.getElementById("HiddenMapOff").value;
	
	var mapsetupflag = loadmap();
	
	if(mapsetupflag == 'success'){
		
		if(includecustommarkers == 1){
			addcustommarkers();
		}
		
		if(includemapcontrols == 1){
			mapcontrolsdiv = document.getElementById("mapcontrols");
			setup_mapcontrols();
		}
		
		if(includecreatecontrols == 1){
			mapcreatetoolsdiv = document.getElementById("createcontrols");
			setup_createcontrols();
		}
		
		if(includedirections == 1){
			mapdirectionsdiv = document.getElementById("directionscontent");
			setup_intdirections();
		}
		
		if(includepano == 1){
			mappanodiv = document.getElementById("pano");
			mappanodetailsdiv = document.getElementById("panodetails");
			highslidepanodiv = document.getElementById("panopanel");
			if(panotoggleState == 1){
				init_streetview();
			}
		}
		
	}
	
}

function winattributes(){
	getbrowser();
	getwinsize();
	//alert(windowheight);
	document.getElementById("dynamback").style.minHeight = windowheight + 'px';
}


function parsedestinfo(destid){
	
	var alldestdetails = document.getElementById("HiddenFieldDestInfo").value;
	var destdetails = alldestdetails.split("|");
	
	//alert(destdetails.length);
	
	if(destdetails.length==22){
		destarray[0] = new popdestination(destid, destdetails[0], destdetails[1], destdetails[2], destdetails[3], destdetails[4], destdetails[5], destdetails[6], destdetails[7], destdetails[8], destdetails[9], destdetails[10], destdetails[11], destdetails[12], destdetails[13], destdetails[14], destdetails[15], destdetails[16], destdetails[17], destdetails[18], destdetails[19], destdetails[20], destdetails[21]);
	}
	
	buildgreetingpage();
	
}


function popdestination(destinationid, name, description, address1, address2, city, state, zip, country, phone, fax, email, weblink, datemanual, datecreated, datemodified, username, lat, lng, zoom, maptype, marker, desttype, coupon){
	
	this.destinationid=destinationid;
	
	this.name=name;
	this.description=description;
	this.address1=address1;
	this.address2=address2;
	this.city=city;
	this.state=state;
	this.zip=zip;
	this.country=country;
	this.phone=phone;
	this.fax=fax;
	this.email=email;
	this.weblink=weblink;
	
	this.datemanual=datemanual;
	this.datecreated=datecreated;
	this.datemodified=datemodified;
	this.username=username;
	this.lat = lat;
	this.lng = lng;
	this.zoom= zoom;
	this.maptype=maptype;
	this.marker=marker;
	this.desttype=desttype;
	this.coupon=coupon;
	
}

function setupeditmode(){
	makeHttpRequest('cpajax/cplayouts.xml', setcontrolpanel, true, 'destcontrolpanel');
	
	var editboxhtml = '<div style="margin-left:10px;"><table width="100%" align="center" class="editboxorange" style="padding:1px;"><tr>';
	editboxhtml += '<td align="right"><a href="javascript:openaddmediabutton()" style="text-decoration:none;">';
	editboxhtml += '<img src="http://www.cplanet.com/globalgraphics/general/icon_addmediahead.png" border="0" /></a></td>';
	editboxhtml += '<td align="left"><a id="addmbanchor" href="javascript:openaddmediabutton()" style="font-size:10px; font-weight:normal; text-decoration:none;" >Add media<br />button</a></td>';
	editboxhtml += '</tr></table></div>';
	
	document.getElementById("addmediatrigger").innerHTML = editboxhtml;
}

function openaddmediabutton(){
	highslideajax('cpajax/cpsnippets.html', 'newmediabutton', 'addmbanchor', 'Add a new Media Button', '650', '350', true)	
}

function openaddmediatype(){
	highslideajax('cpajax/cpsnippets.html', 'mediatypemenu', 'mediatypeanchor', 'Select the type of media', '650', '350', true)	
}

function openaddmediabutton(){
	highslideajax('cpajax/cpsnippets.html', 'newmediabutton', 'addmbanchor', 'Add a new Media Button', '650', '350', true)	
}

function selectnewmediatype(mtype){
	
	var mpageid = document.getElementById("HiddenFieldPageId").value;
	var mdestid = document.getElementById("HiddenDestinationID").value;
	var musername = document.getElementById("HiddenFieldDestUserName").value;
	
	var argstring = '?destid=' + mdestid + '&username=' + musername + '&pageid=' + mpageid;
	
	switch(mtype){
		
		case 'info':
			argstring += '&pageidentity=info';
			//alert(argstring);
			window.location = 'http://www.cplanet.com/Content_Forms/cpinfoeditor.aspx'+argstring;
		break;
		
		case 'guidegroup':
			argstring += '&pageidentity=guidegroup';
			//alert(argstring);
			window.location = 'http://www.cplanet.com/Content_Forms/cpinfoeditor.aspx'+argstring;
		break;
		
		case 'image': 
			window.location = 'http://www.cplanet.com/Content_Forms/cpimageeditor.aspx'+argstring;
		break;
		
		case 'spin': 
			window.location = 'http://www.cplanet.com/Content_Forms/cpspineditor.aspx'+argstring;
		break;
		
		case '3D': 
			window.location = 'http://www.cplanet.com/Content_Forms/cp3deditor.aspx'+argstring;
		break;
		
	}
}

function oldcontrolpanel(){
		window.location = "destcontrolpanel.aspx?destid=" + destarray[0].destinationid	
}

function setcontrolpanel(rethtml){
	
	var mediaopthtml = "";
	
	document.getElementById("ctcontrolpanel").innerHTML = rethtml;
	
	if(document.getElementById("HiddenFieldHasMedia").value == 'True'){
		mediaopthtml += '<table><tr><td valign="middle" align="right">'
			+'<a href="javascript:opencontrol(\'destmatrix\')" style="text-decoration:none;">'
			+'<img src="globalgraphics/general/icon_matrix.png" border="0" /></a></td>'
			+'<td valign="middle" align="left">'
			+'<a href="javascript:opencontrol(\'destmatrix\')" style="text-decoration:none; font-size:12px;">Navigation & <br />Media Info</a></td>'
			
			//alert(destarray[0].desttype);
	}
	
	if((destarray[0].desttype == '3')||(destarray[0].desttype == '7')||(destarray[0].desttype == '8')){
		mediaopthtml += '<td valign="middle" align="right" style="padding-left:25px;">'
		+'<a href="javascript:opencontrol(\'storefrontmenu\')" style="text-decoration:none;">'
		+'<img src="globalgraphics/general/icon_upgrade.png" border="0" /></a></td>'
		+'<td valign="middle" align="left">'
		+'<a href="javascript:opencontrol(\'storefrontmenu\')" style="text-decoration:none; font-size:12px;">Storefront<br>Menu</a></td>';
	}else{
		//buildeditintro();
		
		mediaopthtml += '<td valign="middle" align="right" style="padding-left:25px;">'
		+'<a href="http://www.cplanet.com/controls/CthereUpgrade.aspx?destid='+destarray[0].destinationid+'&task=sfupgrade" style="text-decoration:none;">'
		+'<img src="globalgraphics/general/icon_upgrade.png" border="0" /></a></td>'
		+'<td valign="middle" align="left">'
		+'<a href="http://www.cplanet.com/controls/CthereUpgrade.aspx?destid='+destarray[0].destinationid+'&task=sfupgrade" style="text-decoration:none; font-size:16px;">Upgrade!</a></td>';
	}
			
	mediaopthtml += '</tr></table>';
	
	document.getElementById("ctheretrigger").innerHTML = mediaopthtml;
	
	
	if(document.getElementById("HiddenFieldHasMedia").value != 'True'){
		opencontrolpanel();
	}
	
	
}

function submitmedia(){
	//alert('This is collaborate');
	submitmediatype = 'contribute';
	var contributetitle = '<div align="center" class="cpfontheading18">Submit media to: <u>'+document.getElementById("HiddenDestinationName").value+'</u></div>';
	highslideajax('cpajax/cpsnippets.html', 'collaboratehtml', 'ajaxanchor', contributetitle, '700', '220', true, 'green');
}

function buildeditintro(){
	submitmediatype = 'hmedia';
	var introtitle = '<div align="center" class="cpfonttitle">Congratulations</div>'
					+'<div align="center" class="cpfontheading18">You have created the Cthere Cite: <u>'+document.getElementById("HiddenDestinationName").value+'</u></div>';
	
	highslideajax('cpajax/cpsnippets.html', 'cthereintrohtml', 'ajaxanchor', introtitle, '700', '480', true, 'green');
}

function opencontrolpanel(cptype){
	
	var GuideTitle;
	var GuideType;
	
	
	try{
		if(document.getElementById("HiddenFieldCommGuide").value != ''){
			var TempGuideInfo = document.getElementById("HiddenFieldCommGuide").value;
			var GuideInfo = TempGuideInfo.split("|");
			GuideTitle = GuideInfo[0];
			GuideType = GuideInfo[1];
			
			cptype = GuideType
		}
	}catch(err){
		//no action	
	}
	
	switch(cptype){
		case 'yearbook':
			submitmediatype = 'hmedia';
			var introtitle = '<div align="center" class="cpfontheading18">Yearbook Control Panel: <u>'+document.getElementById("HiddenDestinationName").value+'</u></div>';
			highslideajax('cpajax/cpsnippets.html', 'cthereintrohtml', 'ajaxanchor', introtitle, '700', '450', true, 'green');
		break;
		
		default:
			submitmediatype = 'hmedia';
			var introtitle = '<div align="center" class="cpfontheading18">Cthere Cite: <u>'+document.getElementById("HiddenDestinationName").value+'</u></div>';
			highslideajax('cpajax/cpsnippets.html', 'cthereintrohtml', 'ajaxanchor', introtitle, '700', '450', true, 'green');
		break;
	}
}

function addctheremedia(){
	changetabstrip('cthere');
	makeHttpRequest('cpajax/ctheretemplates.xml', setgreetingoptions, true, 'ctheregreetoptions');
}

function setgreetingoptions(rethtml){
	document.getElementById("sfmediaholder").innerHTML = rethtml;	
}

function ctheresettings(){
		var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value;
		window.location = 'http://www.cplanet.com/controls/connectmenu.aspx'+argstring;
}

function collaborate(){
		var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value + "&pfunc=admin";
		window.location = 'http://www.cplanet.com/controls/CPCollaborate.aspx'+argstring;
}

function shareinvite(){
		var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value + "&pfunc=invite";
		window.location = 'http://www.cplanet.com/controls/CPCollaborate.aspx'+argstring;
}

function ctherefeatures(){
		var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value + "&pfunc=invite";
		window.location = 'http://www.cplanet.com/controls/storefrontmenu.aspx'+argstring;
}

function addhomemedia(mediatype){
	submitmediatype = 'hmedia';
	ezmedia(mediatype);
}

function ezmedia(type){
	//alert(submitmediatype);
	var pfuncarg = '';
	if(submitmediatype == 'hmedia'){
		pfuncarg = '&pfunc=hmedia';
	}
	
	if(submitmediatype == 'contribute'){
		pfuncarg = '&pfunc=contribute';
	}
	
	switch(type){
		case 'picture':
			var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value + "&pageidentity=picture";
			window.location = 'http://www.cplanet.com/Content_Forms/content_singlemedia.aspx'+argstring+pfuncarg;
		break;
		
		case 'video':
			var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value + "&pageidentity=video";
			window.location = 'http://www.cplanet.com/Content_Forms/content_singlemedia.aspx'+argstring+pfuncarg;
		break;
		
		case 'custom':
			var argstring =  "?destid=" + document.getElementById("HiddenDestinationID").value + "&pageidentity=homegroup";
			window.location = 'http://www.cplanet.com/Content_Forms/cpinfoeditor.aspx'+argstring+pfuncarg;
		break;
		
		case 'gallery':
			var argstring =  "?username=" + document.getElementById("HiddenFieldDestUserName").value + "&destid=" + document.getElementById("HiddenDestinationID").value;
			window.location = 'http://www.cplanet.com/Content_Forms/cpbuildgallery.aspx'+argstring+pfuncarg;
		break;
		
		case 'rmedia':
			var argstring =  "?username=" + document.getElementById("HiddenFieldDestUserName").value + "&destid=" + document.getElementById("HiddenDestinationID").value + "&pageidentity=greeting";
			window.location = 'http://www.cplanet.com/Content_Forms/cpinfoeditor.aspx'+argstring;
		break;
		
	}
	
}

function setmediamessage(rethtml){
	var argstring =  "?username=" + document.getElementById("HiddenFieldDestUserName").value + "&destid=" + document.getElementById("HiddenDestinationID").value + "&pageidentity=greeting";
	
	var editboxhtml = '<table width="100%" align="center" class="editboxgreen"><tr>';
	editboxhtml += '<td align="center" width="125" bgcolor="#00FF00">Home Page</td>';
	editboxhtml += '<td align="right"><img src="http://www.cplanet.com/globalgraphics/general/icon_edit.png" align="right" /></td>';
	editboxhtml += '<td align="left"><a id="mediatypeanchor" href="http://www.cplanet.com/Content_Forms/cpinfoeditor.aspx' + argstring + '">Edit Home Page</a></td>';
	editboxhtml += '</tr></table>';
	
	var rtemplate = '<table width="100%" height="350" border="0"><tr><td class="cpfonttitle">Customize your destination\'s greeting</td><td><img src="globalgraphics/general/videoback.jpg" border="0" /></td></tr></table>';
	var modhtml = rethtml.replace("**CTHEREMESSAGE**", rtemplate);
	document.getElementById("sfmediaholder").innerHTML = editboxhtml + modhtml;
	
}

function deleteactivepage(){
	highslideajax('cpajax/cpsnippets.html', 'deleteactivepage', 'deletepageanchor', 'Warning: Deleting Media Group', '600', '200', true);	
}

function deleteactivemedia(activemedia, mediatype){
	//alert(activemedia);
	document.getElementById("HiddenSelectedId").value = activemedia;
	document.getElementById("HiddenSelectedType").value = mediatype;

	highslideajax('cpajax/cpsnippets.html', 'deleteactivemedia', 'deletemediaanchor', 'Warning: Deleting Media', '600', '200', true)	
}

function tripbuildersetup(){
	highslideajax('cpajax/cpsnippets.html', 'createtrip', 'ajaxanchor', 'Start building your trip', '600', '450', true)	
}

function settextareareturn(){
	try{
		multilinetext = true;
	}catch(err){
		//NO ACTION
	}
}

//THE CHECH KEY FUNCTION SORTS OUT ALL KEY PRESSES EXCEPT THE ENTER KEY THEN TRIGGERS THE "processinput()" FUNCTION
//****NOTE: CHECK KEY FUNCTION REQUIRES THE JAVASCRIPT LINE "document.onkeypress = checkKey;" ON THE MASTER PAGE
//****NOTE: CHECK KEY FUNCTION REQUIRES A "processinput()" FUNCTION TO HANDLE THE ENTER KEY.
function checkKey(e)
{
	//alert(browsertype);
	var intKeyCode = 0;
	if (browsertype == "ie"){
		if (window.event.keyCode == 13){
			if(multilinetext==false){
				processinput();
				return false;
			}
		}
	}
	if (browsertype == "netscape"){
		//alert(e.which);
		intKeyCode = e.which;
		if (intKeyCode == 13){
			//alert('Enter key has been pressed');
			if(multilinetext==false){
				processinput();
				return false;
			}
		}
	}
	
}

function processinput(whichinput){
		
		if(globalinputfield == 'blank'){
			var activeinputfield = whichinput;
		}else{
			var activeinputfield = globalinputfield;	
		}
		
      	switch (activeinputfield){
			
			case 'txtUserDestSearch':
				var searchterm = document.getElementById("txtUserDestSearch").value;
				passportsearchtype = 'destsearch';
				userpassportsearch = document.getElementById("HiddenFieldCommGuideUsername").value;
				passportsearchterm = searchterm;
				
				getdestinations("", "", 'passportsearch');
			break;
			
			case 'txtTripName':
				var tripname = document.getElementById("txtTripName").value;
				var tripdesc = document.getElementById("txtTripDesc").value;
				//var builderemail = document.getElementById("txtUserEmail").value;
				var builderemail = "testuser@cplanet.com";
				
				var tripinfo = tripname +"|"+ tripdesc +"|"+ builderemail;
				
				sendcreatetrip(tripinfo);
			break;
			
			case 'password':
				loginButton_Click();
			break;
			
			case 'saddr':
				getdirections('to', globaldirectionpoint);
			break;
			
			case 'daddr':
				getdirections('from', globaldirectionpoint);
			break;
			
			default:
				return false;
			break;
		}
		
		globalinputfield = 'blank';
	  
}


function buildgreetingpage(){
		
	//alert('Name: '+destarray[0].name+'\nDescription: '+destarray[0].description+'\nLat: '+destarray[0].lat);
	
	var classify = destarray[0].desttype;
//	if(classify != '3'){
//		//document.getElementById("ctherebanner").innerHTML = '<img id="ctherebanner2" src="globalgraphics/bannerads/cthere_lite_ad_banner4.jpg" alt="Cthere" width="850" />';
//	}else{
//		document.getElementById("ctherebanner").style.visibility = 'hidden';
//		document.getElementById("ctherebanner").style.height = '0px';
//	}
	
	var destdetailshtml='<div id="greetingtextholder" class="sfmediaholder" style="width:90%;">';
	mapbubblehtml='<div align="left" class="cpfont" style="width:300px; font-size:13px; color:#000000;">';
	var footerhtml='';
	var exploretext='';
	buildsendtomehtml='';
	
	if(destarray[0].name!=''){
		destdetailshtml += '<span class="cpfontheading18">'+destarray[0].name+'</span>';
		mapbubblehtml += '<span class="cpfontheading"><i>'+destarray[0].name+'</i></span>';
		buildsendtomehtml += destarray[0].name;
		footerhtml += destarray[0].name;
	}
	
	if(destarray[0].description!=''){
		destdetailshtml += '<br /><span class="cpfontbold">'+destarray[0].description+'</span>';
	}
	
	if(destarray[0].address1!=''){
		destdetailshtml += '<hr />'+destarray[0].address1;
		mapbubblehtml += '<br />'+destarray[0].address1;
		buildsendtomehtml += '\n'+destarray[0].address1;
		footerhtml += ' | '+destarray[0].address1;
		exploretext += destarray[0].address1;
	}
	
	if(destarray[0].address2!=''){
		destdetailshtml += '<br />'+destarray[0].address2;
		mapbubblehtml += '<br />'+destarray[0].address2;
		buildsendtomehtml += '\n'+destarray[0].address2;
		footerhtml += ' | '+destarray[0].address2;
	}
	
	if(destarray[0].city!=''){
		destdetailshtml += '<br />'+destarray[0].city+', ';
		mapbubblehtml += '<br />'+destarray[0].city+', ';
		buildsendtomehtml += '\n'+destarray[0].city+', ';
		footerhtml += ' | '+destarray[0].city;
		exploretext += destarray[0].city+' ';
	}
	
	if(destarray[0].state!=''){
		destdetailshtml += destarray[0].state+', ';
		mapbubblehtml += destarray[0].state+', ';
		buildsendtomehtml += destarray[0].state+', ';
		footerhtml += ' | '+destarray[0].state;
		exploretext += destarray[0].state+' ';
	}
	
	if(destarray[0].zip!=''){
		destdetailshtml += destarray[0].zip+', ';
		mapbubblehtml += destarray[0].zip+', ';
		buildsendtomehtml += destarray[0].zip+', ';
		footerhtml += ' | '+destarray[0].zip;
		exploretext += destarray[0].zip+' ';
	}
	
	if(destarray[0].country!=''){
		destdetailshtml += destarray[0].country;
		mapbubblehtml += destarray[0].country;
		exploretext += destarray[0].country+' ';
	}
	
	if(destarray[0].phone!=''){
		destdetailshtml += '<br />Phone: '+destarray[0].phone;
		mapbubblehtml += '<br />Phone: '+destarray[0].phone;
		buildsendtomehtml += '\n'+destarray[0].phone;
		footerhtml += ' | '+destarray[0].phone;
	}
	
	if(destarray[0].fax!=''){
		destdetailshtml += '<br />Fax: '+destarray[0].fax;
		mapbubblehtml += '<br />Fax: '+destarray[0].fax;
	}
	
	if(destarray[0].email!=''){
		destdetailshtml += '<br />Contact Email: '+destarray[0].email;
	}
	
	if(destarray[0].weblink!=''){
		destdetailshtml += '<br />Weblink: '+destarray[0].weblink;
		buildsendtomehtml += '\n'+destarray[0].weblink;
	}
	
	destdetailshtml+='</div>';
	mapbubblehtml += '</div>';
	buildsendtomehtmlpreview = mapbubblehtml;
	
	buildbubblemenu(exploretext);
	
	var dynbannerhtml = destarray[0].name;
	var dyngreetingmedia = '';
	//var dyngreetingmedia = '<img src="globalgraphics/storefront/storefront_sample.jpg" alt="Storefront Sample" border="0" />';	
	
	var dyngreetinghtml = '<table width="100%" border="0"><tr>'
						+'<td align="center" valign="middle">'+destdetailshtml+'</td>'
						+'</tr></table>';
						
	document.getElementById("sffooter").innerHTML=footerhtml;
	plotdestination();
	
}

function plotdestination(){
	
	var lat = parseFloat(destarray[0].lat);
	var lng = parseFloat(destarray[0].lng);
	var zoom = parseFloat(destarray[0].zoom);
	var point = new GLatLng(lat,lng);
	
	panoClient.getNearestPanorama(point, ispanoavailable);
	
	var label1 = 'Info';
	var label2 = 'Directions';
	
	configmap(point, zoom, destarray[0].maptype);
    var newmarker = new GMarker(point, {icon:location_marker});
    map.addOverlay(newmarker);
	activemarker=newmarker;

	var dmarker = markerpath + destarray[0].marker;
	newmarker.setImage(dmarker);
		
	GEvent.addListener(newmarker, "click", function(marker, point) {
		newmarker.openInfoWindow(mapbubblehtml);
	});
	
	newmarker.openInfoWindow(mapbubblehtml);
	
}

function ctherepanocheck(){
	var lat = parseFloat(destarray[0].lat);
	var lng = parseFloat(destarray[0].lng);
	var point = new GLatLng(lat,lng);
	panoClient.getNearestPanorama(point, ispanoavailable);	
}


function buildbubblemenu(exploretext){
	
	var directionpoints = parseFloat(destarray[0].lat)+','+parseFloat(destarray[0].lng);
	
		mapbubblehtml += '<div align="left" style="font-size:11px; margin-top:5px;"><table cellpadding="2">';
		
		mapbubblehtml += '<tr><td><img src="http://www.cplanet.com/globalgraphics/general/directionsicon.png" /></td>';
		mapbubblehtml += '<td><b>Directions:</b></td>';
		mapbubblehtml += '<td align="left"><a href="javascript:setdirectionbubble(\'to\', \''+directionpoints+'\' )">To Here  </a></td>';
		mapbubblehtml += '<td align="center">Or</td>';
		mapbubblehtml += '<td align="right"><a href="javascript:setdirectionbubble(\'from\', \''+directionpoints+'\' )">From Here  </a></td></tr>';
		
		if(document.getElementById("HiddenFieldHasMedia").value == 'True'){
			mapbubblehtml += '<tr><td><img src="http://www.cplanet.com/globalgraphics/general/infoicon.png" /></td><td colspan="4"><a href="javascript:changetabstrip(\'cthere\')">Cthere Info</a></td></tr>'
		}
		
		mapbubblehtml += '<tr><td><img src="http://www.cplanet.com/globalgraphics/general/connecticon.png" /></td><td colspan="4"><img src="http://www.cplanet.com/globalgraphics/general/facebookicon.png" /><a href="javascript:changetabstrip(\'connect\')">Get Connected</a></td></tr>'

// COMMENTING OUT EXPLORE FUNCTIONS FOR NOW...7/1/2010
//		mapbubblehtml += '<tr><td><img src="http://www.cplanet.com/globalgraphics/general/directionsicon.png" /></td><td colspan="4"><a href="http://www.cplanet.com/cpexplore.aspx?explorelatlng='+directionpoints+'">EXPLORE</a></td></tr>'
		
		mapbubblehtml += '<tr><td align="center" colspan="5" height="30"><div id="panobutton"><img src="globalgraphics/general/streetview_off.jpg" border="0" /><script type=""text/javascript"">ctherepanocheck()</script></div></td></tr>'
		
		mapbubblehtml += '</table></div>';
	
}


function exploredestpoint(){
	var explorepoint = parseFloat(destarray[0].lat)+','+parseFloat(destarray[0].lng);
	window.location = "cpexplore.aspx?explorelatlng=" + explorepoint;
}


function placemarker(){
	
	//changetabstrip('map');
	
	clearmap();
	
	var updatelat = parseFloat(destarray[0].lat);
	var updatelng = parseFloat(destarray[0].lng);
	var updatezoom = parseFloat(destarray[0].zoom);
	var updatemaptype = destarray[0].maptype;
	updatedmarker = destarray[0].marker;
	
	var point = new GLatLng(updatelat, updatelng);
	
	var label1 = 'Instructions';
	var label2 = 'Map Markers';
	
	var mapbubblehtml = '<div id="bubbleform3" style="width:300px; margin:3px;">'
						+'<table width="100%" border="0" cellspacing="2" cellpadding="5">'
						+'<tr><td class="cpfontreg">1. To adjust the location of the marker: Close this bubble and drag the map marker to its new position.</td></tr>'
						+'<tr><td class="cpfontreg">2. Use the map controls to set the zoom, maptype (i.e. Hybrid, Satellite, Map)</td></tr>'
						+'<tr><td class="cpfontreg" >3. Click the Map Markers tab and select a marker to change your map marker.</td></tr>'
						+'<tr><td class="cpfontreg">4. Click Save Map Settings to complete.</td></tr>'
						+'<tr><td class="cpfontreg"><hr><input type="button" name="upmapsettings" value="Save Map Settings" id="upmapsettings" runat="server" onclick="prepmapsettings()" />'
						+'</td></tr></table></div>';
	
	var localmarkerpath  = "../globalgraphics/markers/";
	var localmarker = localmarkerpath+updatedmarker;
	
	configmap(point, updatezoom, updatemaptype);
    editmarker = new GMarker(point, {icon:dynamicmarker, draggable: true});
    map.addOverlay(editmarker);
	
	editmarker.enableDragging();
	editmarker.setImage(localmarker);
	
	var markertab = '<div id="bubbleform3" style="width:300px; height:250px; overflow: auto;">'+
					'<iframe width="250" height="650" scrolling="auto" src="/globalgraphics/markers/marker_list_update.htm" name="markerlist">'+
					'</iframe></div>';
		
	GEvent.addListener(editmarker, "click", function(marker, point) {
		editmarker.openInfoWindowTabsHtml([new GInfoWindowTab(label1,mapbubblehtml), new GInfoWindowTab(label2,markertab)]);
	});
	
	editmarker.openInfoWindowTabsHtml([new GInfoWindowTab(label1,mapbubblehtml), new GInfoWindowTab(label2,markertab)]);
}


function prepmapsettings(){
	var updatelat = editmarker.getPoint().y;
	var updatelng = editmarker.getPoint().x;
	var updatezoom = map.getZoom();
	var updatemaptype = map.getCurrentMapType().getName();
	
	//alert('Lat: '+updatelat+'\nLng: '+updatelng+'\nZoom: '+updatezoom+'\nMap Type: '+updatemaptype+'\nMarker: '+updatedmarker);
	var argstrg = destinationid+'|'+updatelat+'|'+updatelng+'|'+updatezoom+'|'+updatemaptype+'|'+updatedmarker;
	//alert(argstrg);
	var mapstatus = updatemapsettings(argstrg);
	
	location.reload(true);
	//alert(mapstatus);
	
}

function updatemarker(image){

	var localmarkerpath  = "../globalgraphics/markers/";
	updatedmarker = image;
	var newmarkerimage = localmarkerpath + updatedmarker;
	editmarker.setImage(newmarkerimage);
	
}


function updatemapsettings(mapinfo){
	//alert(mapinfo);
	xmlRequest = DoCallback("/controls/ServerToJavascript.aspx",  mapinfo +',updatemap');
	return (xmlRequest.responseText);
}




//*************************************************************************************************


function displayeditbars(state){
		
	switch (state){
			case 'all': 
				document.getElementById("editbanner").style.visibility = 'visible';
				document.getElementById("editbanner").style.height = '15px';
				document.getElementById("editbanner").innerHTML='<a href="javascript:parent.dynamicedit(\'banner\')"><b>EDIT BANNER</b></a>';
				document.getElementById("editgreeting").style.visibility = 'visible';
				document.getElementById("editgreeting").style.height = '15px';
				document.getElementById("editgreeting").innerHTML = '<a href="javascript:parent.dynamicedit(\'greeting\')"><b>EDIT GREETING</b></a>';
			break;
			
			case 'banneronly': 
				document.getElementById("editbanner").style.visibility = 'visible';
				document.getElementById("editbanner").style.height = '15px';
				document.getElementById("editbanner").innerHTML='<a href="javascript:parent.dynamicedit(\'banner\')"><b>EDIT BANNER</b></a>';
				document.getElementById("editgreeting").style.visibility = 'hidden';
				document.getElementById("editgreeting").style.height = '0px';
				document.getElementById("editgreeting").innerHTML = '';
			break;
		}
}




function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return yWithScroll;
}

function buildheadereditbox(){
	
	var editboxhtml = '<table align="center" class="editboxorange"><tr>';
	editboxhtml += '<td align="center" ><img src="http://www.cplanet.com/globalgraphics/general/icon_mediamini.png" style="margin:1px;" /></td>';
	editboxhtml += '<td align="center" width="130" bgcolor="#FF9900" >Media Header</td>';
	editboxhtml += '<td align="left" style="padding-left:15px; font-size:13px; color:#FF9900;">' + document.getElementById("HiddenPageTitle").value + '</td>';
	editboxhtml += '<td align="right" style="padding-left:15px;"><img src="http://www.cplanet.com/globalgraphics/general/icon_add.png" /></td>';
	editboxhtml += '<td align="left"><a id="mediatypeanchor" href="javascript:openaddmediatype()">Add More Media</a></td>';
	editboxhtml += '<td align="right" style="padding-left:15px;"><img src="http://www.cplanet.com/globalgraphics/general/icon_delete.png" /></td>';
	editboxhtml += '<td align="left"><a  id="deletepageanchor" href="javascript:deleteactivepage()">Delete</a></td>';
	editboxhtml += '</tr></table>';
	
	return editboxhtml;
	
}

function callcpgroup(tourid){
	
	if(searchfuncflag == false){
		addjspage('cpsearchfunctions');
		searchfuncflag = true;
		//alert(destarray[0].name);
		setTimeout("sendgroupid('"+tourid+"')", 700);
	}else{
		sendgroupid(tourid);	
	}
	//changetabstrip('map', 'tour');

}

function sendgroupid(tourid){
	
	if(document.getElementById("HiddenDestinationName").value == "Nicoya Peninsula"){
		//alert('WTF');
		gcouponimage = "http://www.cplanet.com/Users/2009112774838427/images/zoomcoupon.jpg";
	}
	
	getdestinations(tourid, '', 'ctherepage');	
}

function checkpage(sender, args){
	
	//RESET THE MULTI-LINE TEXT FLAG
	multilinetext = false;
	
	//GET AND PARSE THE PAGE PAGE ARGUMENTS
	var activepagename=args.get_item().get_text();//eventArgs.Item.Text;
	var activepagevalue=args.get_item().get_value();//Args.Item.Value;
	var mapoffsetting;
	var multiplesubs = false;
	
	//alert('Page Name: '+activepagename+'Argument String: '+activepagevalue);
	var checkvaluestring = activepagevalue.search(/\?/);
		
	if(checkvaluestring != -1){
		var valuestring = activepagevalue.split("?");
		if(valuestring.length == 7){
			var activemediatype = valuestring[0];
			var activemediaid = valuestring[1];
			var activepageid = valuestring[2];
			var menuitemtype = valuestring[3];
			var menuordernumber = valuestring[4];
			mapoffsetting = valuestring[5];
			var mediapath = valuestring[6];
						
			//THIS SEARCH AND IF STATEMENT HANDLE A VARIABLE GLITCH IN THE DATABASE.
			try{
				var trimmapflag = mapoffsetting.search("True");
				
				if(trimmapflag != -1){
					mapoffsetting = 'True';
				}
			}catch(err){
				mapoffsetting = 'True';
			}
			
			if(menuitemtype!='main'){
				globalheaderitem = 'sub';
				document.getElementById("sfmediaholder").innerHTML='';
			}else{
				//alert(activepageid);
				globalheaderitem = 'main';
				document.getElementById("HiddenFieldPageId").value = activepageid;
				document.getElementById("HiddenPageTitle").value = activepagename;
				
				if(activemediaid=='blank'){
					if(document.getElementById("HiddenEditMode").value == 'True'){
						var editboxhtml = buildheadereditbox();
						document.getElementById("sfmediaholder").innerHTML = editboxhtml;
					}
				}
			}
			
			//alert(activemediatype);
			
			switch (activemediatype){
				case 'Home':
					var reservedpage=true;
					if(defaultmapoff == 'False'){
						mapoffsetting = 'False';
					}else{
						mapoffsetting = 'True';
					}
					
					try{
						changetabstrip('cthere');
					}catch(err){
						//No Action	
					}
				break;
				
				case 'Info':
					try{
						changetabstrip('cthere');
					}catch(err){
						//No Action	
					}
				break;
				
				case 'Community':
					var reservedpage=true;
					mapoffsetting = 'True';
				break;
				
				case 'Calendar':
					var reservedpage=true;
					displaycalendar();
					mapoffsetting = 'True';
				break;
				
				case 'Spin':
					args.set_cancel(true); 
					displayspin(mediapath, activepageid, activemediaid);
					mapoffsetting = 'True';
					//alert(activemediaid);
					document.getElementById("HiddenSelectedId").value = activemediaid;
					document.getElementById("HiddenSelectedType").value = "Spin";
					try{
						changetabstrip('cthere');
					}catch(err){
						//No Action	
					}
				break;
				
				case 'SpinPack':
					//alert("Hello World");
					getspins();
					mapoffsetting = 'True';
				break;
				
				case 'Tag':
					//args.set_cancel(true); 
					callcpgroup(mediapath);
					//mapoffsetting = 'True';
					//alert(activemediaid);
					document.getElementById("HiddenSelectedId").value = activemediaid;
					document.getElementById("HiddenSelectedType").value = "Tag";
					try{
						changetabstrip('map');
					}catch(err){
						//No Action	
					}
				break;
				
				case '3d':
					args.set_cancel(true); 
					display3d(mediapath, activepageid, activemediaid);
					mapoffsetting = 'True';
				break;
				
				case 'order':
					//THIS CASE HANDLE THE SITUATION OF A MAIN MENU HEADER WITH MULTIPLE SUB ITEMS. THE CLICK HAS NO MEDIA TO EDIT.
					//alert('setting multiple subs to true.\nPageid = '+activepageid);
					multiplesubs = true;
					mapoffsetting = 'True';
				break;
				
				case 'ImageShare':
					mapoffsetting = 'False';
				break;
				
			}
			
			//alert(mapoffsetting);
			if(mapoffsetting == 'True'){
				togglemapdisplay('off');
			}else{
				togglemapdisplay('full');
			}
			
		}else{
			alert('Error in Nav Menu String Arguments.');	
		}	
	}else{
		alert('No argument delimiter found.');	
	}
}


function getspins(){
	var spinpackall = document.getElementById("HiddenSpinInfo").value;
	var destname = document.getElementById("HiddenDestinationName").value;
	var spinsets = spinpackall.split('~');
	var spinlist = '<table cellpadding="8" style="background-color:#FFFFFF; border:solid 1px #999999;">';
	spinlist += '<tr><td style="font-size:16pt;"><b>Panorama Spins of '+destname+'</b></td></tr>';
	for (var x = 0; x < spinsets.length; x++) {
		var currset = spinsets[x].split('||');
		var spinthumb = getspinthumb(currset[0])
		spinarray[x] = new popspinarray(currset[0], currset[1], currset[2], currset[3], currset[4], spinthumb);
		var fullspin = spinarray[x].spinpath + spinarray[x].spinimage
		var fullspinthumb = spinarray[x].spinpath + spinarray[x].spinthumb
		spinlist += '<tr><td><a href="javascript:displayhsspin(\'http://www.cplanet.com/'+fullspin+'\', \''+spinarray[x].spinname+'\')"><img src="http://www.cplanet.com/'+fullspinthumb+'" width="250" height="100" /></a><br/><br/><b>'+spinarray[x].spinname+'</b><br/>'+spinarray[x].spindesc+'</td></tr>';
		spinlist += '<tr><td><hr /></td></tr>';
	}
	
	document.getElementById("sfmediaholder").innerHTML = spinlist;
}

function getspinthumb(fullimage){
	var thumbstring = fullimage.split('.');
	var spinthumb = thumbstring[0] + '_thumb.' + thumbstring[1];
	//alert(spinthumb);
	return spinthumb;
}

function popspinarray(spinimage, spinpath, spinname, spindesc, spinid, spinthumb){
	this.spinimage=spinimage
	this.spinpath=spinpath;
	this.spinname=spinname;
	this.spindesc=spindesc;
	this.spinid=spinid;
	this.spinthumb=spinthumb
}


function displayspin(spininfo, mpageid, mmediaid){
	
		//var spininfo = document.getElementById("HiddenSpinInfo").value
		
		var spindetails = spininfo.split("||");
		var spin = "http://www.cplanet.com/" + spindetails[0];
		var spintext = spindetails[1];
		var spindesc = spindetails[2];
	
		//alert(spininfo + " , " + mpageid + " , " + mmediaid);
		
		panostring = '<div align="left" style="padding:10px;"><span style="font-size:18px;"><i><b>'+spintext+'</b></i></span><br /><br />'
					+'<span style="font-size:11px;">'+spindesc+'</span></div>'
					+'<div class="spinarea" style="background-image:url(\''+spin+'\')"><APPLET archive=http://www.cplanet.com/ptviewer.jar  code=ptviewer.class width=800 height=450 name="ptviewer" mayscript=trues>'
					+'<PARAM name=file 			value="'+spin+'">'
					+'<PARAM name=showToolbar 	value="true">'
					+'<PARAM name=auto			value="0.15">'
					+'<PARAM name=fov			value="95">'
					+'<PARAM name=wait			value="globalgraphics/general/wait.jpg">'
					+'</APPLET></div>';
					
		//panostring = '<img src="'+spin+'" width="800" />';
		
		if(document.getElementById("HiddenEditMode").value == "True"){
			var musername = document.getElementById("HiddenFieldDestUserName").value
			var mdestid = document.getElementById("HiddenDestinationID").value
			
			var argstring = '?username='+musername;
				argstring += '&destid='+mdestid;
				argstring += '&pageid='+mpageid;
				argstring += '&mediaid='+mmediaid;
				
			var editboxhtml = '<table width="100%" align="center" class="editboxgreen"><tr>';
			editboxhtml += '<td align="center" width="150" bgcolor="#00FF00">Panorama Spin Media</td>';
			editboxhtml += '<td align="right"><img src="http://www.cplanet.com/globalgraphics/general/icon_edit.png" align="right" /></td>';
			editboxhtml += '<td align="left"><a id="mediatypeanchor" href="http://www.cplanet.com/Content_Forms/cpspineditor.aspx' + argstring + '">Edit</a></td>';
			editboxhtml += '<td align="right" style="padding-left:15px;"><img src="http://www.cplanet.com/globalgraphics/general/icon_delete.png"></td>';
			editboxhtml += '<td align="left"><a id="deletemediaanchor" href="javascript:deleteactivemedia(\''+mmediaid+'\', \'Spin\')">Delete</a></td>';
			editboxhtml += '</tr></table>';
			
			if(globalheaderitem == 'main'){
				var naveditbox = buildheadereditbox();
				document.getElementById("sfmediaholder").innerHTML = naveditbox + editboxhtml + panostring;
			}else{
				document.getElementById("sfmediaholder").innerHTML = editboxhtml + panostring;
			}
			
		}else{
			document.getElementById("sfmediaholder").innerHTML = panostring;
			//document.getElementById("sfmediaholder").innerHTML = spin;
		}
							
		

//		//spin = "panofiles/CplanetPano.xml";
//		
//		var spinfile = 'controls/spinsxml.aspx?path='+spin;
//		
//		var spinstring = '<div id="spinholder" style="margin-top:40px;"></div>';
//		
//		document.getElementById("sfmediaholder").innerHTML = spinstring;
//
//		so = new SWFObject("panofiles/ModuleLoader.swf?xml="+spinfile, "pano", "600", "400", "9", "#000000"); 	
//		so.addParam("allowFullScreen","true");
//		so.addParam("allowScriptAccess","sameDomain");
//		so.write("spinholder");
	
	
}

function displayhsspin(spin, title){
	
		var newtitle = "Panorama Spin";
		
		if(title){
			newtitle = title;
		}
	
		if(spin){
		
			panostring = '<div align="center"><div style="z-index: 1;"><APPLET archive=http://www.cplanet.com/ptviewer.jar  code=ptviewer.class width=625 height=400 name="ptviewer" mayscript=trues>'
						+'<PARAM name=file 			value="'+spin+'">'
						+'<PARAM name=showToolbar 	value="true">'
						+'<PARAM name=auto			value="0.15">'
						+'<PARAM name=fov			value="95">'
						+'<PARAM name=wait			value="globalgraphics/general/wait.jpg">'
						+'</APPLET></div></div>';
			
			
			displayMessage(panostring, newtitle, '700', '475');
		
		}
					
}


function displaycalendar(){
	
	var calendarhtml='<div align="center"><iframe src="Calendar.aspx?destid='+destinationid+'" id="calendarframe" width="800" height="700" frameborder="0" allowtransparency="true" name="calendarframe"></iframe></div>';
	
	document.getElementById("sfmediaholder").innerHTML = calendarhtml;
	
}

function display3d(scenefile, mpageid, mmediaid){
	//alert(scenefile);
	var scenetitle = '3D Scene Title';
	globalscenepath = scenefile;
	//loadscenehtml='<a id="scenelink" href="javascript:highslidepanel(\'3dscene\')">Open 3d Scene</a>';
	loadscenehtml='<div align="center"><div id="launchmessgae" style="width:550px; border:solid thin #0066CC; padding:15px; background-color:#FFFFFF;">'
    			  	+'<table width="100%" border="0">'
      				+'<tr><td colspan="2" align="center"><span style="font-size:18px; color:#0066CC; font-weight:bold;">'
					+'Clicking the image below will launch a three dimensional, interactive simulation.</span><br />'
					+'To experience the 3D effects you must have the <b>Viewpoint Media Player Plugin</b> installed on your computer. '
					+'If you do not, you will be prompted to do so.<br /><br />'
					+'<span style="font-size:20px">Enjoy the Cplanet 3D Experience</span>.</td></tr>'
      				+'<tr><td colspan="2" align="center">'
					+'<div id="scenetitle"><a id="scenelink" href="javascript:highslidecontrol(\'3dscene\')">'
					+'<img src="/globalgraphics/instructions/launch3dimage.gif" alt="Launch 3D Scene" /><br />'+scenetitle+'</a></div><hr/></td></tr>'
      				+'<tr><td align="center"><img src="/globalgraphics/instructions/viewpoint_logo.gif" alt="Viewpoint" /></td>'
        			+'<td align="center"><i><strong>Known issues:</strong> Safari browser has installation issues on select operating systems.</i> </td>'
      				+'</tr></table></div></div>';
	
	
	if(document.getElementById("HiddenEditMode").value == "True"){
		var musername = document.getElementById("HiddenFieldDestUserName").value
		var mdestid = document.getElementById("HiddenDestinationID").value
		
		var argstring = '?username='+musername;
			argstring += '&destid='+mdestid;
			argstring += '&pageid='+mpageid;
			argstring += '&mediaid='+mmediaid;
			
		var editboxhtml = '<table width="100%" align="center" class="editboxgreen"><tr>';
			editboxhtml += '<td align="center" width="150" bgcolor="#00FF00">3D Scene Media</td>';
			editboxhtml += '<td align="right"><img src="http://www.cplanet.com/globalgraphics/general/icon_edit.png" align="right" /></td>';
			editboxhtml += '<td align="left"><a id="mediatypeanchor" href="http://www.cplanet.com/Content_Forms/cp3deditor.aspx' + argstring + '">Edit</a></td>';
			editboxhtml += '<td align="right" style="padding-left:15px;"><img src="http://www.cplanet.com/globalgraphics/general/icon_delete.png"></td>';
			editboxhtml += '<td align="left"><a id="deletemediaanchor" href="javascript:deleteactivemedia(\''+mmediaid+'\', \'3d\')">Delete</a></td>';
			editboxhtml += '</tr></table>';
			
			
		if(globalheaderitem == 'main'){
			var naveditbox = buildheadereditbox();
			document.getElementById("sfmediaholder").innerHTML = naveditbox + editboxhtml + loadscenehtml;
		}else{
			document.getElementById("sfmediaholder").innerHTML = editboxhtml + loadscenehtml;
		}
		
	}else{
		document.getElementById("sfmediaholder").innerHTML=loadscenehtml;	
	}
	
}

function turnpanooff(){
	//var appletinfo = document.ptviewer.getAppletInfo();
	var newpano = '{file=patio.jpg}';
	document.ptviewer.newPano(newpano);
	//alert(appletinfo);
}

function expandmappane(){
	togglemapdisplay('full')
}

function collapsemappane(){
	togglemapdisplay('off')
}


function togglemapdisplay(state){
	
//	var viewingbuffer = 25;
//	var viewingwidth=(document.getElementById('sfbanner').offsetWidth - viewingbuffer);
//	
//	//alert(pagesize.offsetWidth );
//	
//	if(state=='full'){
//		document.getElementById("greetingmap").style.visibility = "visible";
//		document.getElementById('greetingmap').style.height = '375px';
//		var maptriggerhtml = '<a href="javascript:togglemapdisplay(\'off\')">Turn Map Off</a>';
//		document.getElementById("editmap").innerHTML = maptriggerhtml;
//	}
//	
//	if(state=='off'){
//		document.getElementById("greetingmap").style.visibility = "hidden";
//		document.getElementById('greetingmap').style.height = '0px';
//		var maptriggerhtml = '<a href="javascript:togglemapdisplay(\'full\')">Turn Map On</a>';
//		document.getElementById("editmap").innerHTML = maptriggerhtml;
//	}
//	
//	if(state=='split'){
//		document.getElementById("greetingmap").style.visibility = "visible";
//		document.getElementById('greetingmap').style.height = '375px';
//		document.getElementById('greetingmap').style.width = (viewingwidth/2) + 'px';
//		
//		document.getElementById("greetingmedia").style.visibility = "visible";
//		document.getElementById('greetingmedia').style.height = '375px';
//		document.getElementById('greetingmedia').style.width = (viewingwidth/2) + 'px';
//	}
	
	map.checkResize();
	
}


function addblogentry(){
	parent.dynamicedit('blog');
}


function cleanstring(searchstring){
	var newstring=searchstring.replace(/'/g, "\\'");
	newstring=newstring.replace(/|/g, '');
	
	//alert(newstring);
	return newstring;
}

//SEND TO ME FUNCTION
function prepforsend(){
	
	sendtomehtml = buildsendtomehtml;
	
	buildsendbubble();
	
	setTimeout("highslidecontrol('sendtome')",500);
}

function sendtexttoowner(textsubject, sendtext){
	try{
		closeactiveexpander();
	}catch(err){
		//NO ACTION
	}
	
	//alert(textsubject);
	
	var owneruser = destarray[0].username;
	//alert(owneruser);
	
	var owneremail = getuseremail(owneruser);
	//var owneremail = 'mmedalia@virtualeyes.net'
	//alert(owneremail);
	
	sendemail(owneremail, textsubject, sendtext);
	alert("Your message as been sent.");
}



function loadtag(content, name, description){
	
	document.getElementById("sfmediaholder").innerHTML = "Loading content";
		
	document.getElementById("sfmediaholder").innerHTML = '<div>'+ content + '</div>';
	//document.getElementById("sfmediadescription").innerHTML = description;
	
}


function loadvideo(video){

		var videoplayer = '<object type="application/x-shockwave-flash" data="FlowPlayerWhite.swf"';
       videoplayer +='width="320" height="240">';
       videoplayer +='<param name="allowScriptAccess" value="sameDomain" />';
       videoplayer +='<param name="movie" value="FlowPlayerWhite.swf" />';
       videoplayer +='<param name="quality" value="high" />';
       videoplayer +='<param name="scale" value="Scale" />';
       videoplayer +='<param name="wmode" value="transparent" />';
       videoplayer +='<param name="flashvars" value="config={videoFile: \'' + video + '\' , showMenu: false , loop: false , showLoopButton: false}" />';
       videoplayer +='</object>';
          //document.getElementById("sfmediadescription").innerHTML = videoplayer
}
//END OF LOAD CONTENT FUNCTION



