// This is a method to dynamically load javascript after the page is loaded.

	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = ((agent.indexOf('iphone')!=-1));
	if (is_iphone) {
		//load jQuery and then load the iPhone flick plugin
		addLoadEvent(loadJQuery(onJQueryLoad));
		// loadJQuery(onJQueryLoad);
		// jQuery(onJQueryLoad);
	}
	
	function addLoadEvent(func) { 
		var oldonload = window.onload; 
		if (typeof window.onload != 'function') { 
			window.onload = func; 
		} else { 
			window.onload = function() { 
				oldonload(); 
				func(); 
			} 
		} 
	} 
	
	// This function loads jquery
	function loadJQuery(callback) {
		var script = document.createElement('script'); 
		script.type = 'text/javascript'; 
		script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js";
		var head = document.getElementsByTagName("head")[0]; 
		head.appendChild(script);
		// alert('hello');
		var callbackTimer = setInterval(function() {
		  var isLoaded = false;
		  try {
		    isLoaded = (jQuery != undefined);
		  } catch (e) {}
		  // alert("tried");
		  if (isLoaded) {
		    clearInterval(callbackTimer);
		    callback.call();
		  }
		}, 100);
	}
	
	
	function onJQueryLoad() {
		// alert("jQuery loaded: "+populateIFrames);
		$.getScript("jquery.flick.compact.js", populateIFrames);
	}
	
	function populateIFrame(iframeSelector, url) {
		// alert('populating '+iframeSelector);
		$.get(url, function(data) {
		  data.replace(/^.*<body>/i, '');
		  data.replace(/<\/body>.*$/i, '');
		  $(iframeSelector).html(data);
		  $(iframeSelector).prepend('<p><strong><em>Flick to Scroll</em></strong></p>');
		  $(iframeSelector).flick();
		});
	}
	
