// JavaScript Document
/* Google Analytics */
var mode = "test";
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6983844-1']); // production
_gaq.push(['_trackPageview' , branch]);
(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
function trace() {
  if (mode != "test") return false;
  if(typeof this.console == "undefined") return false;
  if(typeof console.log == "undefined") return false;
  
  for(var i = 0 ; i < arguments.length ; i++){
  	if(arguments[i]) console.log(arguments[i]);
  }
}
function trackPage(page,gCustomVar){
	if(typeof(_gaq) != "undefined") {
		if(typeof(gCustomVar) != "undefined"){
			_gaq.push(['_setCustomVar', gCustomVar.index, gCustomVar.category, gCustomVar.value, gCustomVar.scope]);
		}
		_gaq.push(['_trackPageview',page]);
		trace("Track Page " + page);
	}
}	
function trackEvent(gEvent,gCustomVar){
	if(typeof(_gaq) != "undefined"){
		if(typeof(gCustomVar) != "undefined"){
			_gaq.push(['_setCustomVar', gCustomVar.index, gCustomVar.category, gCustomVar.value, gCustomVar.scope]);
		}
		_gaq.push(['_trackEvent', gEvent.category, gEvent.action, gEvent.label]);
		trace("Track Event | " + "Category: " + gEvent.category + " Action: " + gEvent.action+ " Label: " + gEvent.label);
	}
}
function callPopup(imgURL,imgCaption){
	$("#popupContent").empty().append("<a class=\"singleImg\" href=\"" + imgURL + "\" title=\"asdf\"></a>");
	$("a.singleImg").fancybox({
		overlayOpacity : 0.9,
		imageScale : false,
		centerOnScroll : false,
		callbackOnShow : function(){ $("#fancy_title_main > div").html(imgCaption); }}).trigger('click');
}
$(window).load(function() {
	if (swfobject.hasFlashPlayerVersion("10.1")) {		
		var flashvars = {};
		if(typeof window.branch != "undefined") flashvars.branch = branch;
		var objOptions = {align: "middle", id: "Main_v2c", scale: "noscale", wmode: "opaque", allowScriptAccess:"sameDomain", bgcolor: "#E7E0CD"};
		swfobject.embedSWF("assets/main.swf?"+version, "content", "100%", "100%", "10.1", null, flashvars, objOptions, objOptions);
	} else {
		$("#missing-flash").css("display", "block");				
	}
});
