/*******************************
       Namespaced Functions
 *******************************/
 

$.extend(sbcu, {
	
	// handles chromeframe pop-up
	chromeFrameInstall: function() {
		var chromeOptions = { 
			node: 'banner',
			destination: 'index.html',
			// make this true to use onmissing to create custom install implementation
			preventPrompt: true,
			onmissing: function() {
				if(confirm('This website requires Google\'s Chrome Frame plugin to be compatible with IE6). Proceed to download site?')) {
					window.location = 'http://www.google.com/chromeframe';
				}
				else {
					window.location	= 'http://www.mozilla.org';
				}
			}
		};
		try {
			CFInstall.check(chromeOptions);	
		}
		catch(error) {
			// Chrome frame library not included on this page	
			console.log("Could not initiate chrome frame install:\n" + error);
		}
	},
	
	// standard embed code for this site
	youtubeEmbed: function(flvID, params) {
		var settings = {
			width: 853,
			height: 506,
			autoplay: 1,
			wmode: 'transparent',
			bgColor: '#FFFFFF'
		}
		$.extend(settings, params);
		
		return '\n' +
			'<object width="'+settings.width+'" height="'+settings.height+'" border="0">' + '\n' +
			'	<param value="http://www.youtube.com/v/'+flvID+'?rel=0&amp;fs=1&amp;disablekb=1&amp;autoplay='+settings.autoplay+'&amp;hd=1&amp;showsearch=0&amp;iv_load_policy=3&amp;showinfo=0" name="movie">' + '\n' +
			'	<param value="true" name="allowFullScreen">' + '\n' +
			'	<param value="'+settings.bgColor+'" name="bgcolor">' + '\n' +
			'	<param value="'+settings.wmode+'" name="wmode">' + '\n' +
			'	<param value="always" name="allowScriptAccess">' + '\n' +
			'	<embed width="'+settings.width+'" height="'+settings.height+'" border="0" bgcolor="'+settings.bgColor+'" wmode="'+settings.wmode+'" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash"src="http://www.youtube.com/v/'+flvID+'?rel=0&amp;fs=1&amp;disablekb=1&amp;autoplay='+settings.autoplay+'&amp;hd=1&amp;showsearch=0&amp;iv_load_policy=3&amp;showinfo=0">' + '\n' +
			'</object>'
		;
	},
	
	// finds current section by examing body tag
	findSection: function() {
		return $('body').attr('id');	
	},
	
	// handles user agent checking
	isiPad: function() {
		return navigator.userAgent.match(/iPad/i) != null;
	},
	
	isiPhone: function() {
		return navigator.userAgent.match(/iPhone/i) != null;
	},
	
	// Validates email
	isEmail: function(addy) {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(addy)){
			return true;
		} 
		else {
			return false;
		}	
	}
	
});

