
// General routines
function showloading(where) {
	container = document.getElementById(where);
	positioning = 'top: '+container.offsetTop+'px; width: '+container.offsetWidth+'px; height: '+container.offsetHeight+'px; ';
	$('div#' + where).append('<div id="requestwaiting" style="position: absolute; ' + positioning + '"/>');
	
}
function postform(whatform,destination,callerobj) {
	if (callerobj) {
		destination= $('#' + callerobj.id).parent('div').attr("id");	
	}
	showloading(destination);
	$.ajax({
	  url: "/cfpages/functions/ajaxcontroller.cfc?method=execute",
	  cache: false,
	  data: $('#' + whatform).serialize(),
	  success: function(data) {
		$('div#' + destination).hide();
		$('div#' + destination).html(data);
		$('div#' + destination).fadeIn();				  
		}
	});		
	return false;
}	
function loadSection(panel,what,extra) {
	
	if (!extra) {
		extra='';	
	}	
	
	if (panel == 'new') {
		window.open("/cfpages/functions/ajaxcontroller.cfc?method=execute&actionmethod=" + what + "&extraparams=" + extra,what);
		$('#requestwaiting').hide();
	} else {
		showloading(panel);
		$.ajax({
		  url: "/cfpages/functions/ajaxcontroller.cfc",
		  dataType: "html",
		  data: {actionmethod:what, method:"execute", extraparams:extra },
		  success: function(data) {		
				$('div#' + panel).hide();
				$('div#' + panel).html(data);
				$('div#' + panel).fadeIn();
			},
			error:function(xhr,err){
				alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
				alert("responseText: "+xhr.responseText);
				$('#requestwaiting').hide();
			}
		});	
	}
}		

function setOffers() {
$('a.offerlink').each(function()
   {
	  $(this).qtip(
	  {
		 content: {
			// Set the text to an image HTML string with the correct src URL to the loading image you want to use
			text: '<img src="/images/extras/ajax-loader.gif" alt="Loading..." />',
			url: '/cfpages/xml/iglusummary.cfm?id=' + $(this).attr('rel'), // Use the rel attribute of each element for the url to load
			title: {
			   text: 'IGLU Offer - ' + $(this).text(), // Give the tooltip a title using each elements text
			   button: 'Close' // Show a close link in the title
			}
		 },
		 position: {
			corner: {
			   target: 'bottomMiddle', // Position the tooltip above the link
			   tooltip: 'topMiddle'
			},
			adjust: {
			   screen: true // Keep the tooltip on-screen at all times
			}
		 },
		 show: { 
			when: 'click', 
			solo: true // Only show one tooltip at a time
		 },
		 hide: 'unfocus',
		 style: {
			tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
			border: {
			   width: 0,
			   radius: 4
			},
			name: 'light', // Use the default light style
			width: 415 // Set the tooltip width
		 }
	  })
   });	
	$('a.resortname').each(function()
	   {
		  $(this).qtip(
		  {
			 content: {
				// Set the text to an image HTML string with the correct src URL to the loading image you want to use
				text: '<img src="/images/extras/ajax-loader.gif" alt="Loading..." />',
				url: '/cfpages/xml/resortsummary.cfm?id=' + $(this).attr('rel'), // Use the rel attribute of each element for the url to load
				title: {
				   text: 'WSG Review - ' + $(this).text(), // Give the tooltip a title using each elements text
				   button: 'Close' // Show a close link in the title
				}
			 },
			 position: {
				corner: {
				   target: 'bottomMiddle', // Position the tooltip above the link
				   tooltip: 'topMiddle'
				},
				adjust: {
				   screen: true // Keep the tooltip on-screen at all times
				}
			 },
			 show: { 
				when: 'click', 
				solo: true // Only show one tooltip at a time
			 },
			 hide: 'unfocus',
			 style: {
				tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
				border: {
				   width: 0,
				   radius: 4
				},
				name: 'light', // Use the default light style
				width: 350 // Set the tooltip width
			 }
		  })
	   });
}











function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 
function setText(thefield){
if (thefield.value=="")
thefield.value = thefield.defaultValue
} 


function popItUp(newURL) {
	newWindow=window.open(newURL,"sendMail","statusbar=false, titlebar=false, resizable=false, menubar=false,HEIGHT=480, WIDTH=500")
	newWindow.focus()
}		


function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}





