function TT_flashDispatch(obj){
	/* Funktion för att från HTML-wrappern anropa Flash med ett eventobjekt */
	var f = TT_getFlash();
	
	/* ex: obj={type:"value", param1:"value1"} */
	/* Varje ny regel måste parsas av Flash */
	f.dispatch(obj);
	
	return true;
}

function TT_getFlash(){
	/* Funktion som returnerar FlashPlayer-objektet */
	return document.getElementById("main");
}

function TT_trace(text){
	/* Registrerad av Flash - byt inte namn! */
	/* Funktion som under utveckling kan vara bra att ha, och som Flash kan anropa */
	alert(text);
}

function TT_flashAlert(headline, message){
	/* Funktion som under utveckling kan vara bra att ha, HTML-wrappern anropar flash */
	var f = TT_getFlash();
	f.alert(headline, message);
}


function TT_Save(vectorProductid){
	var newLoc=location.href+"/save/"+vectorProductid;
	newLoc=newLoc.replace("?setup_s=JAKO","");
	newLoc=newLoc.replace("/index","");
	//alert(newLoc);
	window.location=newLoc;

}

function TT_addCartContentFromFlash(cart_id){
	window.location="/shop/addCartContentFromFlash?cart_id="+cart_id;

}



function TT_flashEvent(e){
	/* Registrerad av Flash - byt inte namn! */
	/* Funktion som anropas från Flash med generella eventobjekt som parsas av HTML-wrappern */
	var type = e.type;
	var version = e.version;
	var id = e.id;
	var shop = e.shop;
	var article = e.article;
	var product = e.product;
	var message = e.message;
	var stackTrace = e.stackTrace;
	
	if(type=='cart'){	
		//switchToCart(id);
		TT_addCartContentFromFlash(id);
	}else if(type=='help'){	
		displayCommonHelp();
	}else if(type=='close'){	
			closeDesigner();
	}else if(type=='save'){	
		//var debug = "TT_flashEvent" + "\ntype: " + type + "\nversion: " + version + "\nid: " + id + "\nshop: " + shop + "\narticle: " + article + "\nproduct: " + product + "\nmessage: " + message + "\nstackTrace: " + stackTrace;
		//alert(debug);
		TT_Save(product);
	}else if(type=='about'){	
	  showArticleInfo(article);
	}else{
		var debug = "TT_flashEvent" + "\ntype: " + type + "\nversion: " + version + "\nid: " + id + "\nshop: " + shop + "\narticle: " + article + "\nproduct: " + product + "\nmessage: " + message + "\nstackTrace: " + stackTrace;
		alert(debug);
	
	}
	
	/* Nu kan du hantera event med data i HTML-wrappern */
	return;
}

