/*
History:
02/18/12 - Added preventDefault coding
10/29/11 - Created this page to support various CPL calls to display modal pages

This page is generally included in the site's settings file.

Fancy Box has some Catch-22 issues if you try to use common code to manually set width/height for mixed displays.  For iFrames it auto 
scrolls and listens to width/height unless autoDimensions=false.  For AJAX it doesn't auto scroll within the AJAX panel (but the parent
page auto scroll works) and it ignores width/height unless autoDimensions=false.  So, the width/height below are used by iFrames but not
AJAX.  AJAX uses our CSS.  This generally gives us the most compact display for small content while also handling large content.

*/

jQuery(document).ready(function() {

	$(".goModal").click(function (event) {			//Handle click on any of our modal items
		event.preventDefault(); 					//Prevent default action associated with the click; keeps the page from jumping around

		var fbTarget = '';							//Initialize the target
		var fbTargetType = 'ajax';					//Initialize the target type; assume (case-sensitive) ajax; we use ajax as default rather then iFrame because PayPal won't support Buy-Now calls from an iFrame.
		var theDbKey = '';							//Initialize the record id
		var thisID = $(this).attr("id");			//Get the ID of the link clicked

		if (thisID == 'termsOfUse'){				//Terms of Use for SMS-enabled sites; requires that the site use the explicit shell page in the next line
		  fbTarget='/page_iframe.asp?p=shell: Terms and Conditions of Use&showPrintOption=y'
		  fbTargetType='iframe'
		}
		if (thisID.slice(0,5) == "calID"){			//Calendar item
		  fbTarget = thisID.replace("calID","");											//Strip off the leading identifying text, leaving only the id number
		  fbTarget='/z_common/resources/calendar/calendar_display_modal.asp?cid=' +fbTarget	//Using z_common directly so no shell page is required
		}
		if (thisID.slice(0,9) == "jobbankID"){		//Job item
		  fbTarget = thisID.replace("jobbankID","");
		  fbTarget='/z_common/resources/jobbank_display_modal.asp?dbKey=' +fbTarget
		}
		if (thisID.slice(0,6) == "newsID"){			//News item
		  fbTarget = thisID.replace("newsID","");
		  fbTarget='/z_common/resources/news_display_modal.asp?cid=' +fbTarget
		}	
		if (thisID.slice(0,8) == "vendorID"){		//Vendor item
		  fbTarget = thisID.replace("vendorID","");
		  fbTarget='/z_common/resources/vendors_display_modal.asp?p=' +fbTarget
		}
//		alert(fbTarget);

		$.fancybox({
		//'transitionIn'	: 'elastic',			//Default is 'fade'; we use the default because the effects don't seem to be worth the overhead.
		//'easingIn'		: 'easeInSine',			//Used if transition(s) set to 'elastic'; Default is 'swing'
		//'centerOnScroll'	: true,					//Don't use - causes small screen mobile displays to jump around too much when user zooms in/out
		'width'				: 640,					//Default is 560 (px); applies to iframe and swf only unless autoDimensions = false
		'height'			: '100%',				//Default is 340 (px); applies to iframe and swf only unless autoDimensions = false
		'speedIn'			: 600,
		'href'				: fbTarget,
		'type'				: fbTargetType
		});		//End FancyBox
	});			//End goModal
});			//End doc ready function

