//newWindow

var popupWindow;
function newWindow(url){
	//for Chrome	
	if(navigator.userAgent.indexOf("Chrome") >= 0){
		popupWindow=window.open(url,"pWindow","directions=1,location=1,menubar=1,scrollbars=yes,status=1,toolbar=1,resizable=1");
		popupWindow.focus();
	}else{
		window.blur();
		popupWindow=window.open(url,"pWindow","directions=1,location=1,menubar=1,scrollbars=yes,status=1,toolbar=1,resizable=1");
		popupWindow.focus();
	}
}

window.name = "popupWindow";

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

function focusFunc(e) { 
	log("focusFunc");
	swfTarget("orisma_swf").SetVariable("sound",1);
	// swfTarget("orisma_swf").setSound(1);
}

function blurFunc(e) { 
	log("blurFunc");
	swfTarget("orisma_swf").SetVariable("sound",0);
	// swfTarget("orisma_swf").setSound(0);
}

function flfocusFunc(e) { 
	log("flfocusFunc");
	swfTarget("orisma_swf").SetVariable("sound",1);
	// swfTarget("orisma_swf").setSound(1);
}

function flblurFunc(e) { 
	log("flblurFunc");
	swfTarget("orisma_swf").SetVariable("sound",0);
	// swfTarget("orisma_swf").setSound(0);
}


function setFunc() { 
	//alert(44);
	log("setFunc");
	Event.observe($("orisma_swf"), 'focus', flfocusFunc, false); 
	Event.observe($("orisma_swf"), 'blur', flblurFunc, false);
	if (Prototype.Browser.WebKit){
		Event.observe(window, 'focus', focusFunc, false);
		Event.observe(window, 'blur', blurFunc, false);
	}
	$("orisma_swf").focus();
}

function log(msg){
	return false;
	if(!$("log-console")){
		var logDiv = document.createElement("div");
		logDiv.id="log-console";
		logDiv.name="log-console";
		logDiv.style.position = "absolute";
		logDiv.style.border = "1px solid gray";
		logDiv.style.padding = "5px";
		logDiv.style.color = "white";
		logDiv.style.top = 0;
		logDiv.style.left = 0;
		logDiv.style.zIndex = 99999;
		document.body.appendChild(logDiv);
		initLog();
	}
	var logConsole = document.getElementById('log-console');
	
	var newP = document.createElement("p");
	var newT = document.createTextNode(msg);
	var firstP = document.getElementsByTagName('p')[0];
	newP.appendChild(newT);
	logConsole.insertBefore(newP,firstP);
}
function initLog(){
	var logDiv = document.getElementById('log-console');
	var myA = document.createElement("a");
	myA.href="javascript:clearLog()";
	var aTxt = document.createTextNode("clear");
	myA.appendChild(aTxt);
	logDiv.appendChild(myA); 
	var myP = document.createElement("p");
	myP.id="log-content";
	var myTxt = document.createTextNode("===log===");
	myP.appendChild(myTxt);
	logDiv.appendChild(myP);
}
function clearLog(){
	document.getElementById('log-console').innerHTML = "";
	initLog();
}