var APPBoard = "viewforum.php?f=10";
var sStoreURL = "http://zukavstore.serverlogic.com";

function t_init(){
	updatePNGGfx();
	updateMACGFX();
}

function needHack(){
	var index = navigator.userAgent.indexOf("MSIE ");
	if (index == -1) return false;
	
	var version = navigator.userAgent.substring(index + 5);
	return (((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)) && (navigator.platform == ("Win32")));
}

function updatePNGGfx(){
	var image, src;
	
	if(needHack()){
		for(i = 0; i < document.images.length; i++){
			image = document.images[i];
			src = image.src;
			if(src.indexOf(".png.gif") > -1){
				src = src.substring(0, src.length - 4);
				image.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			}
		}
	}else{
		for(i = 0; i < document.images.length; i++){
			image = document.images[i];
			src = image.src;
			if(src.indexOf(".png.gif") > -1){
				src = src.substring(0, src.length - 4);
				image.src = src;
			}
		}
	}
}

function updateMACGFX(){
	var userAgent = navigator.userAgent.toLowerCase();
	//alert(userAgent);
	if((userAgent.indexOf("safari") > -1 || userAgent.indexOf("msie") > -1) && userAgent.indexOf("mac") > -1){
		var div;
		
		div = document.getElementById("pagehead");
		if(div){
			div.id = "macpagehead";
		}
		div = document.getElementById("headmenutable");
		if(div){
			div.id = "macheadmenutable";
		}
		div = document.getElementById("footerbar");
		if(div){
			div.id = "macfooterbar";
		}
	}
}


function openMessageBoard(initialPage){
	var win2;
	if(initialPage){
		win2 = window.open("MessageWindow.aspx?initialPage=" + escape(initialPage), "messageboard", "width=780,height=550,scrollbars=yes,resizable=yes,toolbar=yes");
	}else{
		win2 = window.open("MessageWindow.aspx", "messageboard", "width=780,height=550,scrollbars=yes,resizable=yes,toolbar=yes");
	}
	win2.focus();
}

function openChat(chatID){
	var xWid = 800;
	var yHei = 570;
	
	var win2 = window.open("ChatFrameset.aspx?chatID=" + chatID, "chat", 'width='+xWid+',height='+yHei+',resizable=no,scrollbars=no,left=0,top=0,screenx=0,screeny=0');
	win2.focus();
}

function openAPPChat(chatID){
	openChat(chatID);
	/*
	var xWid = 800;
	var yHei = 600;
	if (window.screen){
		xWid=screen.availWidth - 5;
		yHei=screen.availHeight - 30;
	}
	var win2 = window.open("ChatFrameset.aspx?APP=y&chatID=" + chatID, "chat", 'width='+xWid+',height='+yHei+',resizable=yes,scrollbars=no,left=0,top=0,screenx=0,screeny=0');
	win2.focus();
	*/
}


function showChatLog(roomname){
	var win2;
	win2 = window.open("ChatWindow_MessageLog.aspx?roomname=" + escape(roomname), "chatmessagelog", "width=450,height=550,scrollbars=yes");
	win2.focus();
}

function showChatUsers(roomname){
	var win2;
	win2 = window.open("ChatWindow_UserLog.aspx?roomname=" + escape(roomname), "chatuserlog", "width=350,height=350,scrollbars=yes");
	win2.focus();
}

function openAPPUserChatLog(){
	showChatUsers("APP");
}

function openAPPChatLog(){
	showChatLog("APP");
}

function t_requestLogin(loginURL, requestText, loginAction){
	var goURL, currentURL;
	
	if(confirm(requestText)){
		goURL		= loginURL;
		currentURL	= window.location + "";
		
		if(loginAction){
			if(currentURL.indexOf("?") > -1){
				currentURL += "&loginAction=" + loginAction;
			}else{
				currentURL += "?loginAction=" + loginAction;
			}
		}
		if(goURL.indexOf("?") > -1){
			goURL += "&";
		}else{
			goURL += "?";
		}
		
		goURL += "redirectURL=" + escape(currentURL);
		window.location = goURL;
	}
}

function OpenStore(){
	var win2;
	
	//open a handle to a new window
	win2 = window.open(sStoreURL, "zukavstore", "width=730,height=650,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,top=0")
	
	//verify window exists
	if(win2 != null){
	
		//bring to front
		win2.focus();
	}
	
}