function getQueryVidValue(){
	var q = document.location.search || document.location.hash;
	if(q){
		var startIndex =  q.indexOf("#");
		var endIndex = q.length;
		var story_id =  q.substring(q.indexOf("#", startIndex)+1, endIndex);
 		return story_id;
	}
	return "";
}

function getSWF (movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
   
}

function pushDeeplink (id) {  
	//alert("pushDeeplink = "+id);
  	getSWF("sfugSwf").pushDeeplink(id);
    
}

function setExternalLink() {  
	
	// some application vars
	var stateVar = "nothin'", displayDiv = document.getElementById("HistoryState");
	//NEW LUIS
	this.applyNew = function(linkMessage) {
		
		if(linkMessage != ""){
			unFocus.History.addHistory(linkMessage); 
		}else{
		//	alert("linkMessage = "+linkMessage);
			document.title = "GARDEN PARTY ";
			displayDiv.innerHTML = "Current History: ";
			unFocus.History.addHistory("");
		}
	}
	//LUI
	// the sole public method to manipulate this application
	this.promtForNew = function() {
		// do the stuff that changes the state
		var newVal = window.prompt("Please enter some value to store in the history and url");
		// Set the new history hash. This value must be a string, so serializtion is up to you.
		// JSON works nicely, if you need something quick: http://www.json.org
		// When a new entry is made, unFocus.History will notify the historyListener 
		// method of the change, even on the first call. For this demo app we can 
		// rely on the historyListener method to update the state, and view.
		unFocus.History.addHistory(newVal);
	};
	
	// This is the method that will recieve notifications from the History Keeper,
	// which will then update the state of the app.
	// :NOTE: This will be called when a new entry is added.
	// :NOTE: This will be called if another app on the page sets a history,
	//        so you will need to watch out for this, if you have more than
	//        one script using the history keeper, by doing some kind of 
	//        check to make sure that the new hash belongs to this app.
	//        I wouldn't expect this to be a problem all that frequently.
	this.historyListener = function(historyHash) {
		// update the stateVar
		stateVar = historyHash;
 		//alert(stateVar);
		// update display content
		displayDiv.innerHTML = "Current History: " + historyHash; 
		
		// update document title
		document.title = "GARDEN PARTY :: OFFICIAL SITE :: Now on DVD";
		//document.title = "GARDEN PARTY: " + historyHash;
		pushDeeplink(historyHash);

	};
	this.getLink = function(){
	     //alert("stateVar= "+stateVar);
		pushDeeplink(stateVar);
	}
	// subscribe to unFocus.History
	unFocus.History.addEventListener('historyChange', this.historyListener);
	
	// Check for an initial value (deep link).
	// In this demo app, the historyListener can handle the task.
	this.historyListener(unFocus.History.getCurrent());
	
};
// instantiate and inialize the app. DOM has to be ready so we can get a ref to
// the HistoryState DOM element (aka the view), so we use QuickLoader to make
// sure it's ready.
//		<body onLoad="demoApp = new setExternalLink();">

var demoApp;