var  seccion_activa;
var  section_hash;
var  sub_section_hash;
var sub_sub_section_hash;
var  old_s;
var demoApp;
seccion_activa = null;
section_hash = null;
sub_section_hash = null;


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) {
		// alert(linkMessage);
		if(linkMessage != ""){
			//alert("linkMessage = "+linkMessage);
			//unFocus.History.addHistory(linkMessage); 
			 if (navigator.appName.indexOf("Microsoft") != -1) {
				window.location.hash	=	linkMessage;
			 }
			 else
			 {
				 document.location.hash	=	linkMessage;
			 }
		}else{
			document.title = "| chikara "+linkMessage + " |";
		  	displayDiv.innerHTML = "Current History: ";
			//unFocus.History.addHistory("");
			document.location.hash	=	"";
		}
	}

	// 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) {
	
		if(!historyHash)	historyHash	=	"";
		if(historyHash == seccion_activa){
			return;
		}
		//
		seccion_activa = historyHash;
		// update the stateVar
		stateVar = historyHash;
		// update display content

		var historyHash_t = historyHash.split("/");
		section_hash = historyHash_t[1];
		sub_section_hash = historyHash_t[2];
		sub_sub_section_hash = historyHash_t[3];
		
		historyHash_t = historyHash_t.join(" | ");
		
		document.title = "| CHIKARA DESIGN | mastectomy swimwear | mastectomy bras | breast cancer clothing " + historyHash_t + " |";
		
		
		displayDiv.innerHTML = "Current History: " + historyHash;
		
		pushDeeplink(historyHash);

		this.getLink = function(){
			pushDeeplink(stateVar);
		}
	
	};
	unFocus.History.addEventListener('historyChange', this.historyListener);
	
 	this.historyListener(unFocus.History.getCurrent());
	
};
 

