/************************************************************************************************************************************Author: Philip KinlowOwner: World Vision US**************REQUIREMENTS:**************The autolightbox_config is used only when World Vision Version of the Shadowbox script includes are on the page. This feature will not work or produce an error if the following includes are not present on the page:<script type="text/javascript" src="http://media.worldvision.org/js-includes/prod/shadowbox-2.0/src/excanvas-compressed.js"></script><script type="text/javascript" src="http://media.worldvision.org/js-includes/prod/shadowbox-2.0/src/shadow-box-round-corners-addon-compress.js"></script><script type="text/javascript" src="http://media.worldvision.org/js-includes/prod/shadowbox-2.0/src/adapter/shadowbox-base.js"></script><script type="text/javascript" src="http://media.worldvision.org/js-includes/prod/shadowbox-2.0/src/shadowbox_wv_ver_compressed.js"></script><script type="text/javascript" src="http://media.worldvision.org/js-includes/prod/shadowbox-2.0/src/wv_shadowbox_config.js"></script>Then Include this Script After the above scripts:<script type="text/javascript" src="http://www.worldvision.org/resources.nsf/autoplaylightbox.js"></script>****************WHAT IT DOES ****************Autolightbox script provides an easy to configure method to making a the lightbox launch on page load with a provided querystring. ********************ABOUT THE FUNCTION ********************autolightbox_configParameter:inputval	( String or Object ){inputval as a String - The String URL or HTML for the lightbox content }{inputval as a object - using the Shadows configuration properties }inputval as a object Properties:player		//player [string] property can be iframe, img, swf, flv, gt, wmp, htmltitle		//title [string] property any text string for the titlecontent		//content [string] property url for iframe sourcewidth		//width [number] width of lightbox in pixelsheight		//height [number] width of lightbox in pixelsquery		//query	[string] the querystring used for triggering the lightbox. A value of 'playlightbox' will launch the lightbox without a querystring.*********************Examples*********************----------------------------------------------------------------------------------- EX 1). Configure the Lightbox with URL String for the location of the content-----------------------------------------------------------------------------------autolightbox_config("http://www.worldvision.org/content.nsf/pages/five-days-of-hunger")-------------------------------------------------------------------- Ex 2). Configure Lightbox with object configuration properties--------------------------------------------------------------------autolightbox_config({	player: 'iframe',	title:	'iStore Sponsorship Page',	content: 'http://donate.worldvision.org/OA_HTML/xxwvibeCZzpEntry.jsp?go=sponsor&CL=0000&CST=ALL',	width: 520,	height: 340,	query: 'playlightbox'})*************************************************Attach Lightbox Configuration to a Link on the *************************************************The autolightbox_config function returns an object with a function for attaching the same lightbox configurations to an HTML Element on the Page. Return Object attachLightbox function ( As the shadowboxAttachEvent function )Parameters:		ref (required)	( string or object )	Accepts ref as an HTML Element Object or HTML Id Reference as Stringev  (optional)	( string )		Accepts ev Name as a String - Will use the onclick event the defaultobj (optional)	( object )		Accepts Shadowbox Options Object - Will use the configuration specified by the autolightbox_config functionrto (optional)	( String ) 		Accepts lpos value to be used when the ligbhtbox is launched - No default.*********************Example*********************----------------------------------------------------------------------------------- EX 3). Configure the Lightbox with URL String for the location of the content-----------------------------------------------------------------------------------If a link exist on the page with id of 'lightboxlink' then the lightbox can be triggered with the hyperlink<a href="http://donate.worldvision.org/OA_HTML/xxwvibeCZzpEntry.jsp?go=sponsor&CL=0000&CST=ALL" id="lightboxlink">iStore Sponsorship Page</a><script>autolightbox_config({	player: 'iframe',	title:	'iStore Sponsorship Page',	content: 'http://donate.worldvision.org/OA_HTML/xxwvibeCZzpEntry.jsp?go=sponsor&CL=0000&CST=ALL',	width: 520,	height: 340,	query: 'playlightbox'}).attachLightbox('lightboxlink')</script>**********************************************************************************************************/var autolightbox_config = function(inputval){		/* Default Object Properties Values */ 	var obj_default = {			player: 'iframe',		title: '',		content: '',		width: 520,		height: 340,		query: 'playlightbox=true',	// Include a value of 'playlightbox' to play lightbox without querystring requirement		playon: ''	}		/* The Object Properties Used For The Window Onload Event and the Returned Object */	var obj_ret = {};	/* Define The Object Property Values Based On The Included Parameter */	if(typeof inputval == "object"){		try{obj_ret = compareAndAssign(inputval,obj_default)}catch(e){obj_ret = null;}	}else if(typeof inputval == "string" && inputval != ""){ 		obj_ret = obj_default;		obj_default.content = inputval;	}else{		obj_ret = null;	}		/* Attach Shadowbox Callback Function To Window.Onload Event */	if(typeof window.onload == "function" && obj_ret != null){		autolightbox_obj = { 			player: obj_ret.player,			title: obj_ret.title,			content: obj_ret.content,			width: obj_ret.width,			height: obj_ret.height		}		autolightbox_opts = {			query: obj_ret.query		}		var loadWindowOnload = window.onload;		if(autolightbox_config.isConfigured != true){			window.onload = function(){				loadWindowOnload();				var isQSValue = function(sv){return(new RegExp("[?&]"+ sv +"([&#]|$)").test(location.search) || sv == 'playlightbox')}				var isQS = false;									/* Checking Query Trigger */				if(typeof autolightbox_opts.query === "string"){					var reTestQS = new RegExp("[?&]"+ autolightbox_opts.query +"[&#]*$");					isQS = reTestQS.test(location.search) || (autolightbox_opts.query == 'playlightbox');				}else if(typeof autolightbox_opts.query === "function"){					isQS = (autolightbox_opts.query(autolightbox_opts,isQSValue) === true);				}							if(isQS === true){					if(Shadowbox.open){						Shadowbox.open(autolightbox_obj);							}				}			}		}		autolightbox_config.isConfigured = true;			}	/* Return Object For Extending the Shadowbox Configuration To Other HTML Elements On The Page */	return {		attachLightbox: function(ref,ev,obj,rto){			if(typeof ref != "undefined"){				if(typeof obj=="undefined"){obj = obj_ret}					if(typeof ev=="undefined"){ev = "onclick"}				shadowboxAttachEvent(ref,ev,obj,rto);			}			return this;			},		lightbox_opts: obj_ret	}}/* The original autolightbox_config does not properly support multiple configurations on the same page. This new function will allow the same functionality with the support of multiple configuration on the same page. Use the following object parameters:playertitle		: See Notes Abovecontent		: See Notes Abovewidth		: See Notes Aboveheight		: See Notes Abovequery		: See Notes Aboveid 		: Please include the id paramter to provide an unique key to identify seperate configurations. If not provide, then the query value if it is a string will be used. */var autolaunchlightbox = function(obj){		if(!autolaunchlightbox.config){autolaunchlightbox.config = [];}			obj.id = typeof obj.id == "string" ? obj.id : (typeof obj.query == 'string' ? obj.query : null );			if(obj.id == null){return null};		autolaunchlightbox.config[obj.id] = {		player: obj.player ? obj.player: 'iframe',		title: obj.title ? obj.title : '',		content: obj.content ? obj.content : '',		width: obj.width ? obj.width : 520,		height: obj.height ? obj.height : 340,		query: obj.query ? obj.query : playlightbox=true	}		autolightbox_config({		query: function(opts,isQS){			var selectedKey = null;			for(var i in autolaunchlightbox.config){				var o = autolaunchlightbox.config;				if(typeof o[i].query != "undefined"){					var q = o[i].query;					var runLightbox = false;					if(typeof q == 'function'){						runLightbox = q(opts,isQS);					}else if(typeof q == 'string'){							runLightbox = isQS(q);					}					if(runLightbox === true){						selectedKey = i;						break;					}				}								}			if(selectedKey != null){				autolightbox_obj = {					player: autolaunchlightbox.config[selectedKey].player,					title: autolaunchlightbox.config[selectedKey].title,					content: autolaunchlightbox.config[selectedKey].content,					width: autolaunchlightbox.config[selectedKey].width,					height: autolaunchlightbox.config[selectedKey].height				}				autolightbox_opts.query = autolaunchlightbox.config[selectedKey].query;				return true;				}else{return false}			}	});	var obj_ret = autolaunchlightbox.config[obj.id];		return {		attachLightbox: function(ref,ev,ob,rto){			if(typeof ref != "undefined"){				if(typeof ob=="undefined" || ob==""){ob = autolaunchlightbox.config[obj.id]}					if(typeof ev=="undefined" || ev==""){ev = "onclick"}				shadowboxAttachEvent(ref,ev,ob,rto);			}			return this;			},		lightbox_opts: obj_ret	}}
