/*
Close/Open Boss coming panel on top of the page
*/
var isAvailable						= "";
var isNotAvailable					= "";
var currentAvailable				= "";

var globalImgArray					= new Array('jpg', 'JPG', 'jpeg', 'JPEG', 'png', 'PNG', 'gif', 'GIF');

function AddToFavourites() {
	var title					= document.title;
	var url						= this.location;
	if ( window.sidebar ) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} 
	else if ( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	}
	else if ( window.opera && window.print ) { // Opera Hotlist
		return true; 
	}
}

function redirect(url) {
	window.location.href					= url;
}

function ToggleBossPaneVisibility(sendIt) {
	if ( sendIt )
		$.post("/dynContent/doChecking.php", {action: 	"toggle-f12"});

	var o = document.getElementById('BossComingOpened');
	var c = document.getElementById('BossComingClosed');
	
	if (o!=null && c!=null) {
		if (o.style.display == 'none') {
			o.style.display = 'block';
			c.style.display = 'none';
		}
		else {
			o.style.display = 'none';
			c.style.display = 'block';
		}
	}
}

/*
Function open popup window with name
*/
function OpenNamePopUp(file, name, width, height)
{
	var maxY = screen.availHeight;
	var maxX = screen.availWidth;  
	var x = (maxX - width) / 2;
	var y = (maxY - height) / 2;
	var w = window.open(file, name, 'status=yes,scrollbars=no,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	if (w != null)
		w.focus();
}

function goto_forum_profile(user) {
	document.location.href				= "forum-profile.php?u=" + user;
}

function goto_forum_privmsg(user) {
	document.location.href				= "forum-privmsg.php?u=" + user;
}

function toggleAvailable() {
	$.post("/dynContent/doSavings.php", {
		action: 	"toggle-available"}, function(responseXML) {
				var returns			= $(responseXML).find("returns").text();
				if ( returns	== "success" ) {
					if ( currentAvailable == isAvailable )
						currentAvailable	= isNotAvailable;
					else
						currentAvailable	= isAvailable;

					$("#availabilty").html(currentAvailable);
				}
	});
}

function closeThickbox() {
	tb_remove();
}

function getFlashMovie(movieName) {
	var isIE 						= navigator.appName.indexOf("Microsoft") != -1;
  	return (isIE) ? window[movieName] : document[movieName];
}

function checkExt(extArray, filename) {
	allowSubmit 						= false;
	
	if (!filename) return;

	while (filename.indexOf("\\") != -1)
    		filename 					= filename.slice(filename.indexOf("\\") + 1);

	ext 						= filename.split(".");
	ext							= ext[(ext.length-1)];

    	for (var i = 0; i < extArray.length; i++) {
    		if (extArray[i] == ext) { 
			allowSubmit 				= true; 
			break; 
		}
    	}
	
    	if (allowSubmit) 
		return true;
    	else
    		alert("oops! we only accept the following filetypes: .jpg, .jpeg, .png, .gif. please select a new file to upload.");
    	return false;
}

function addBookmark(){
	if (document.all) {
		window.external.AddFavorite(location.href, document.title);
	}
	else if (window.sidebar) {
			window.sidebar.addPanel(document.title, location.href, "");
	}
}

function retryLogin() {
	$("#loginFailed").hide();
	$("#frm_login_hidden").show();
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function hideHeaderUserMessage() {
	$.post("/dynContent/doSavings.php", {
		action: 	"hide-usermessage"}, function(responseXML) {
				var returns			= $(responseXML).find("returns").text();
				if ( returns	== "success" ) {
					$("#theTotalTextBox").hide();
				}
	});
}

