
if (typeof _URL == undefined) {
	var _URL;
}

	var oxbase_onload = new Array();
	var oxbase_unload = new Array();

	window.onload = function()
	{
		for (i = 0; i <= oxbase_onload.length; i++)
		{
			eval(oxbase_onload[i]);
		}
	}

	window.onunload = function()
	{
		for (i = 0; i <= oxbase_unload.length; i++)
		{
			eval(oxbase_unload[i]);
		}
	}

var bites = document.cookie.split("; ");

function getCookie(name) { 
for (var i=0; i < bites.length; i++) {
  nextbite = bites[i].split("=");
  if (nextbite[0] == name)
	return unescape(nextbite[1]);
}
return null;
}

var today = new Date();
var expiry = new Date(today.getTime() + 60 * 60 * 24 * 1000); // plus 1000 days
var expiry_past = new Date(today.getTime() - 60 * 60 * 24 * 1000); // plus 1000 days

function setCookie(name, value) {
	if (value != null && value != "")
		document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
	bites = document.cookie.split("; ");
}
	
function delCookie(name) {
	document.cookie=name + "=_; expires=" + expiry_past.toGMTString();
	bites = document.cookie.split("; ");
}
	




function SubmitNewsletter() {
	

	url = _URL + "private/newsletter"

	var val = "";
	var errors = new Array();
	var count = 1;

	if ((document.forms["subscribe"].email.value.indexOf("@") == -1) || (document.forms["subscribe"].email.value.length < 5)) {
		ShowMessageBox( 
			"Error!", 
			"Please enter your email in order to subscribe.",
			{ "Close" : "__close__" }
		);
	} else {

		var response = HTTPPostRequest(
				false,
				url , 
				{
					"email" : document.forms["subscribe"].email.value,
					"act" : GetRadioValue(document.forms["subscribe"].act)
				}
			);

		
		switch (response) {
			case "registered":
				UserBox("newsletterRegistered");
			break;

			case "unregistered":
				UserBox("newsletterUnregistered");
			break;

			case "error":
				UserBox("newsletterError");
			break;

			case "exists":
				UserBox("newsletterExists");
			break;

			case "notexists":
				UserBox("newsletterNotexists");
			break;
		}
	}
}
function ShowRating(parent , type) {

	var html= "<form name='subrate' method='post' action='javascript:void(SubmitRate())'><input type='hidden' name='parent' value='" + parent +"'/><input type='hidden' name='tp' value='" + type + "'/>";
		html +="<table align=center>";
		html += "<tr><td>Bad:</td><td><input type=radio name=rate value=1></td><td style='font: 5px;'><img src='/img/star_1.gif'/> <img src='/img/star_3.gif'/> <img src='/img/star_3.gif'/> <img src='/img/star_3.gif'/> <img src='/img/star_3.gif'/></td></tr>";
		html += "<tr><td>Poor:</td><td><input type=radio name=rate value=2></td><td style='font: 5px;'><img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_3.gif'/> <img src='/img/star_3.gif'/> <img src='/img/star_3.gif'/></td></tr>";
		html += "<tr><td>Average:</td><td><input checked type=radio name=rate value=3></td><td style='font: 5px;'><img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_3.gif'/> <img src='/img/star_3.gif'/></td></tr>";
		html += "<tr><td>Good:</td><td><input type=radio name=rate value=4></td><td style='font: 5px;'><img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_3.gif'/></td></tr>";
		html += "<tr><td>Excellent:</td><td><input type=radio name=rate value=5></td><td style='font: 5px;'><img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/> <img src='/img/star_1.gif'/></td></tr>";
		html +="</table></form>";

		ShowMessageBox( 
			"Select Rating", 
			html,
			{ 
				"Close" : "__close__" ,
				"Submit" : "javascript:document.forms['subrate'].submit();" 
			}
		);
	
}


function SubmitRate(form) {

	url = _URL + "private/rate";

	var response = HTTPPostRequest(
			false,
			url , 
			{
				"type" : document.forms["subrate"].tp.value,
				"parent" : document.forms["subrate"].parent.value,
				"rate" : GetRadioValue(document.forms["subrate"].rate)
			}
		);

	
	switch (response) {
		case "ok":
			UserBox("rateOk");
		break;

		case "error":
			UserBox("rateError");
		break;

		case "exists":
			UserBox("rateExists");
		break;

		case "login":
			UserBox("rateLogin");
		break;
	}
}

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
//comment

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

function HTTPGetRequest(onsuccess , url ) {

	wait = onsuccess == false ? false : true;

	xmlhttp.open("GET", url,wait);

	if (!wait){
		xmlhttp.send(null)
		return xmlhttp.responseText;
	} else {
		xmlhttp.onreadystatechange = function() {
			//temporaty fix, i font know why it isnw working when i pass directlu the xmlhttp.readyState to the function
			switch (xmlhttp.readyState)	{
				case 4:
					onsuccess(xmlhttp.responseText , xmlhttp.readyState)
				break;

				default:
					onsuccess("" , xmlhttp.readyState)
				break;			
			}
		}
		xmlhttp.send(null)
	}	
}


function HTTPPostRequest(onsuccess , url , vars)  {

	var wait = onsuccess == false ? false : true;
	var request = "";

	for ( i in vars ){
		request += i + "=" + escape(vars[i]) + "&";
	}

	xmlhttp.open("POST", url, wait);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

	if (!wait){
		xmlhttp.send(request)
		return xmlhttp.responseText;
	} else {
		xmlhttp.onreadystatechange = function() {

			switch (xmlhttp.readyState)	{
				case 4:
					onsuccess(xmlhttp.responseText , xmlhttp.readyState)
				break;

				default:
					onsuccess("" , xmlhttp.readyState)
				break;			
			}
						
			//alert(xmlhttp.readyState);
		}
		xmlhttp.send(request)
	}
}

function is_Ajax() {
	if (xmlhttp ==false)
		return false;
	else 
		return true;
}

function getWindowSize() {
/*
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		iWidth = document.clientWidth;
		iHeight =document.clientHeight;
	} else {
		iWidth = window.innerWidth;
		iHeight = window.innerHeight;

	}
*/
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}

	return { "width" : parseInt(myWidth) , "height" : parseInt(myHeight) };
/*
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	} else 	{
			winW = window.innerWidth;
			winH = window.innerHeight;		
	}
*/
	return { "width" : parseInt(winW) , "height" : parseInt(winH) };
}

function isIe() {
	return (navigator.appName.indexOf("Microsoft")!=-1) ? true : false;
}


function SelectElement(select,which) {
	for (var i = 0; i < select.options.length; i++) {          
		if ( select.options[i].value == which )                    
			select.options[i].selected=true;
	}
}


function str_replace( r, w , s){
     return s.split(r).join(w);
}


	function GetSelectText(select) {
		for (var i = 0; i < select.options.length; i++) {          
			if ( select.options[i].selected == true )                    
				return select.options[i].text;
		}
	}


function browserVersion(){
	var browser=navigator.appName
	var b_version=navigator.appVersion
	var version=parseFloat(b_version)

	var ie=false;

	if (browser = "Microsoft Internet Explorer") {
		var arr = navigator.appVersion.split(";");
		for (i =0 ; i< arr.length ; i++ ) {
			if (arr[i].indexOf("MSIE") != "-1") {
				//found it 
				var tmp2 = arr[i].split(" ");
				
				version = parseFloat(tmp2[2]);
			}
		}
		
		ie = true;

	}

	return version;
}


function getAbsolutePos (el) {
	var r = { x: el.offsetLeft, y: el.offsetTop , width: el.offsetWidth, height: el.offsetHeight};
	if (el.offsetParent) {
		var tmp = getAbsolutePos (el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}

	return r;
};


function GetRadioValue(select) {
	for (var i = 0; i < select.length; i++) {          
		if ( select[i].checked == true )                    
			return select[i].value;
	}
}

	function GetSelectValue(select) {
		for (var i = 0; i < select.options.length; i++) {          
			if ( select.options[i].selected == true )                    
				return select.options[i].value;
		}
	}

/*
	OXYLUS Developement web framework
	copyright (c) 2002-2007 OXYLUS Developement

	$Id: message.js,v 0.0.2 9/12/2007 20:38:15 Exp $

	Note: tested in IE 6.0 / 7.0 , MOZILLA FIREFOX, OPERA, SAFARI 3.0

	contact:
		www.oxylus.ro
		devel@oxylus.ro

		office@oxyls.ro

	ALL THIS CODE IS THE PROPERTY OF OXYLUS DEVELOPEMENT. YOU CAN'T USE ANY OF THIS CODE WITHOUT
	A WRITTEN ACCORD BETWEEN YOU AND OXYLUS DEVELOPEMENT. ALL ILLEGAL USES OF CODE WILL BE TREATED
	ACCORDING THE LAWS FROM YOUR COUNTRY.

	THANKS FOR YOUR UNDERSTANDING.
	FOR MORE INFORMATION PLEASE CONTACT US AT: office@oxylus.ro
*/


var __box_overlay = false;
var __box_html = false;
var __box_images = false;
var __box_settings = {
		"hide_body_scrooling" : false
	};

var __box_cache = {};
function ShowMessageBox(title , message , buttons) {
	__messageHtml();
	__messageOverlay();
	__messageBackground();

	var _div_main = document.getElementById("msgbox");
	var _div_title = document.getElementById("msgboxtitle");
	var _div_msg = document.getElementById("msgboxbody");
	var _div_buttons = document.getElementById("msgboxbuttons");
	var _div_overlay = document.getElementById("overlay");

	if (isIe() && (browserVersion() <= 7)) {
		_div_overlay.style.position = "absolute";
		_div_main.style.position = "absolute";

		_div_overlay.style.height = document.body.offsetHeight + "px";
		_div_overlay.style.width = document.body.offsetWidth + "px";
	}

	//window.location = window.location.href + "#";
	window.scroll(0,0);

	//try to hide the scrolling

	if (__box_settings["hide_body_scrooling"])
		try {		
			//cache the existing settings
			__box_cache["body_overflow"] = document.body.style.overflow ;
			document.body.style.overflow = "hidden";
		} catch (e) {
		}	

	_div_overlay.style.display="inline";

	//set the title
	_div_title.innerHTML = title;
	_div_msg.innerHTML = message;


	var _win = getWindowSize();
	//center the box right on the middle.
	var left = (_win["width"] / 2) - (330 / 2);
	var top = _win["height"] / 2 - 204 ;

	_div_main.style.left = parseInt(left) + "px";
	_div_main.style.top = parseInt(top)  + "px";

	//clear the existing list of buttons
	_div_buttons.innerHTML = "";

	//generate the buttons
	for (i in buttons ) {
		if (buttons[i] == "__close__") 
			buttons[i] = "javascript:HideMessageBox();";

		_div_buttons.innerHTML +=
				'<a class="btn" href="' + buttons[i] + '">' + i + '</a>';
	}

	//make the box visible
	_div_main.style.display = "block";	
}

function UserBox(id) {

	if (typeof id == "object") {
		ShowMessageBox(
				id["title"],
				id["msg"],
				id["buttons"]
			);
	}
	ShowMessageBox(
			__messagesBox[id]["title"],
			__messagesBox[id]["msg"],
			__messagesBox[id]["buttons"]
		);
} 

function HideMessageBox() {
	document.getElementById("msgbox").style.display = "none";
	var _div_overlay = document.getElementById("overlay");
	_div_overlay.style.display="none";


	if (__box_settings["hide_body_scrooling"])
		try {		
			document.body.style.overflow = __box_cache["body_overflow"];
		} catch (e) {
		}	

}


function __messageOverlay() {
	if (__box_overlay == false) {
		__box_overlay = true;

		div_element = document.createElement("div");
		div_element.setAttribute("id" , "overlay");
		div_element.setAttribute("class" , "overlay");
		document.body.appendChild(div_element);
	}
}

function __messageHtml() {
	if (__box_html == false) {
		__box_html = true;

		div_element = document.createElement("div");
		div_element.setAttribute("id" , "msgbox");
		div_element.setAttribute("class" , "alert-box");

		document.body.appendChild(div_element);
 
		document.getElementById("msgbox").innerHTML =
		'<table cellspacing="0" cellpadding="0" class="msgbox"> ' +
		'	<tr><td id="msgboxtitle">.</td></tr>' +
		'	<tr><td id="msgboxbody"></td></tr>' +
		'	<tr><td id="msgboxbuttons"></td></tr>' +
		'	<tr><td id="msgboxfooter"></td></tr>'+
		'</table>'
	}
}


function __messageBackground() {

}


/* History 

0.0.2 
	Added support for custom messages to UserBox( {title: "" , message : "" , buttons : { ...}  } )

0.0.1
	Basic functions


*/
/*
	OXYLUS Development web framework
	copyright (c) 2002-2007 OXYLUS Development
		web:  www.oxylus.ro
		mail: support@oxylus.ro		

	$Id: messaging.js,v 0.0.1 7/8/2007 7:30 PM emanuel Exp $
	
	javascript backend for the messaging module.
	
	requires message.js ( js box )
*/


var __messageNewFolder = "";
var __messageAction = "";
var __messageDelete = "";

var __messageDeleteSingle = {"msg" : "" , "folder" : ""} ;

function MessagingPost() {
	var post= document.forms["compose"];
	//check for all the fields;
	if (post.msg_to.value == "") {
		UserBox("messagingErrorToEmpty");
		post.msg_to.focus();
	} else 
		if (post.msg_subject.value == "") {
			UserBox("messagingErrorSubjectEmpty");
			post.msg_subject.focus();
		} else 
			if (post.msg_body.value == "") {
				UserBox("messagingErrorBodyEmpty");
				post.msg_body.focus();
			} else {
				//check if the username is available
				var response = HTTPPostRequest( 
									false , 
									_URL + "account/messages/private?action=checkUser",
									{ "user" : post.msg_to.value }
								) ;
				
				switch (response) {
					case "ok":
						//the users exists, okay send the message

						response = HTTPPostRequest( 
											false , 
											_URL + "account/messages/private?action=sendMessage",
											{ 
												"msg_action" : post.msg_act.value,
												"msg_parent" : post.msg.value,
												"msg_thread" : post.msg_thread.value ,
												"msg_to" : post.msg_to.value ,
												"msg_subject" : post.msg_subject.value ,
												"msg_body" : post.msg_body.value
											}
										);
						
						//check the response to see if i return any error
						if (response == "ok") {

							//reply duirectly from the message details
							if (typeof document.forms["compose"].orig_msg_to != "undefined") {
								UserBox("messagingSentOkDetails");
							} else
							UserBox("messagingSentOk");
						} else 
							//else, there was an error, i cant imagine the problem...
							UserBox("messagingSentError");
					break;
				
					case "self":
						UserBox("messagingErrorToSelf");
						post.msg_to.focus();
					break;

					default:
						UserBox("messagingErrorToInvalid");
					break;
				}
					
			}
}

function MessageJump( act ) {

	//reset the form
	var val = act.value;
	SelectElement(act , "");

	//detect the operation
	switch (val) {
		case "folder_new":
			__messageAction = "jump";
			MessageNewFolder();
		break;

		default:
			//check if i need to jump
			if (val.indexOf("folder_") != "-1") {
				var tmp = val.split("_");
				window.location = _URL + "account/messages/folder.html?id=" + tmp[1];			
			}
		break;
	}
}

function DeleteMessages(){ 
	UserBox("messagingDeleteMsg");
}


function MessageAction( act ) {

	if (typeof act == "string") {
		var val = act;
	} else {
		var val = act.value;
		SelectElement(act , "");
	}
	var action = false;
	var count = 0;
	var query = {};

	//check to see if there is at least one message selected
	form = document.forms["messages"];

	//doenst work on safari for windows??	
	var elements = form.getElementsByTagName("input");

	for (var i=0;i<elements.length;i++) {
		if (elements[i].type == "checkbox") {
			if (elements[i].checked == true) {
				action = true;
				count ++;
				query["msg[" + count + "]"] = elements[i].value;
			}			
		}
	}

	if (action == true) {
		//detect the operation
		switch (val) {

			case "markRead":
			case "markUnread":
			case "addStar":
			case "remStar":
			case "delMsg":
				var response = HTTPPostRequest( 
									false , 
									_URL + "account/messages/private?action=" + val,
									query
								);

				if (response == "ok")
					window.location.reload();
				else
					UserBox("messagingSelectError");
			break;

			case "folder_new":
				__messageAction = "move";
				MessageNewFolder();				
			break;

			default: 
				if (val.indexOf("folder_") != "-1") {
					var tmp = val.split("_");
					var folder = tmp[1];
					
					//add the folder to the query
					query["folder"] = folder;

					var response = HTTPPostRequest( 
										false , 
										_URL + "account/messages/private?action=moveFolder",
										query
									);

					if (response == "ok")
						window.location.reload();
					else
						UserBox("messagingSelectError");

				}
			break;
		}
	} else {
		//show an error
		UserBox("messagingSelect");
	}
}


function MessageNewFolder() {
	//show a box with an input so i can create the folder
	UserBox("messagingNewFolder");
	document.forms["newFolder"].folder.focus();
}


function MessageCreateFolder() {
	var folder = document.forms["newFolder"].folder.value;

	if (folder != "") {
		//hide the message
		HideMessageBox();

		//query the server to create the folder

		response = HTTPPostRequest( 
							false , 
							_URL + "account/messages/private?action=newFolder",
							{ 
								"folder" : folder 
							}
						);
		if (response.indexOf("ok") != "-1") {
			//get the folder id so i can transmit to the parent function
			var tmp = response.split(";");

			switch (__messageAction) {
				case "jump":
					__messageAction = "";
					window.location = _URL + "account/messages/folder.html?id=" + tmp[1];			
				break;
				
				case "move":
					__messageNewFolder = tmp[1];
				break;			
			}

		}

		switch (response) {
			case "exists":
				//the folder already exists, show an error
				UserBox("messagingNewFolderExists");
				//show the box again
			break;

			case "ok":
				return true;
			break;
		}
	}
}

function MessagesChangeStar(id) {

	response = HTTPPostRequest( 
						false , 
						_URL + "account/messages/private?action=changeStar",
						{ 
							"msg" : id
						}
					);


	switch (response) {
		case "added":
		case "removed":
			//new image
			var image = "img/messages/star_" + (response == "added" ? "on" : "off" ) + ".gif";
			//change the image
			document.getElementById("msg_star_" + id).src = image;
		break;

		default:
			UserBox("messagingSelectError");
		break;
	}
}

function MessagesSelect( what ){
	//parse the entire list and get the ids of the messages


	//check to see if there is at least one message selected
	form = document.forms["messages"];

	var elements = form.getElementsByTagName("input");

	for (var i=0;i<elements.length;i++) {
		if (elements[i].type == "checkbox") {

			switch (what) {
				case "all":
					elements[i].checked = true;
				break;

				case "none":
					elements[i].checked = false;
				break;

				case "starred":
					if (document.getElementById("msg_star_" + elements[i].value).src.indexOf("_on") != "-1")
						elements[i].checked = true;
					else
						elements[i].checked = false;
				break;

				case "unstarred":
					if (document.getElementById("msg_star_" + elements[i].value).src.indexOf("_off") != "-1")
						elements[i].checked = true;
					else
						elements[i].checked = false;
				break;

				case "read":
					if (document.getElementById("msg_read_" + elements[i].value).value == 1)
						elements[i].checked = false;
					else
						elements[i].checked = true;
				break;

				case "unread":
					if (document.getElementById("msg_read_" + elements[i].value).value != 1)
						elements[i].checked = false;
					else
						elements[i].checked = true;
				break;

			}

/*
			if (elements[i].checked == true) {
				action = true;
				count ++;
				query["msg[" + count + "]"] = elements[i].value;
			}			
*/
		}
	}
}

function MessageDeleteFolder(fold){
	var folder = fold.value;

	//alter the message box
	
	//change the folder name
	__messagesBox["messagingDeleteFolder"]["msg"] = str_replace(
			"{FOLDER}",
			GetSelectText(fold),
			__messagesBox["messagingDeleteFolder"]["msg"]
		);

	__messagesBox["messagingDeleteFolder"]["buttons"]["Yes"]="javascript:__messageDeleteFolder('" + folder + "');";
	UserBox("messagingDeleteFolder");

}

function __messageDeleteFolder(folder) {
	var tmp = folder.split("_");
	var folder_id = tmp[1];

	//call the server

	response = HTTPPostRequest( 
						false , 
						_URL + "account/messages/private?action=remFolder",
						{ 
							"folder" : folder_id 
						}
					);

	if (response == "ok") {
		window.location.reload();
	} else
		UserBox("messagingSelectError");
}

function MessagingShowCompose(wh){

	var subject = document.forms["compose"].msg_subject;
	var subject2 = document.forms["compose"].orig_msg_subject;
	
	switch (wh) {
		case "re":
			try {
				document.getElementById("MessagingBtnReply").style.display = "none";
				document.getElementById("MessagingBtnForward").style.display = "inline";
				document.getElementById("MessagingBtnReplyOff").style.display = "inline";
				document.getElementById("MessagingBtnForwardOff").style.display = "none";
				
			} catch (e) {
			}

			document.forms["compose"].msg_to.value = document.forms["compose"].orig_msg_to.value;

			//check if it has the re of fw in front of the text
			if (subject2.value.indexOf("RE:") != 0)
				subject.value = "RE:" + document.forms["compose"].orig_msg_subject.value;
			else
				subject.value = document.forms["compose"].orig_msg_subject.value;
		break;

		case "fw":
			try {
				document.getElementById("MessagingBtnReply").style.display = "inline";
				document.getElementById("MessagingBtnForward").style.display = "none";
				document.getElementById("MessagingBtnReplyOff").style.display = "none";
				document.getElementById("MessagingBtnForwardOff").style.display = "inline";
				
			} catch (e) {
			}

			document.forms["compose"].msg_to.value = "";

			if (subject2.value.indexOf("FW:") != 0)
				subject.value = "FW:" + document.forms["compose"].orig_msg_subject.value;
			else
				subject.value = document.forms["compose"].orig_msg_subject.value;
		break;

	}

	//show thte box
	document.getElementById("RFMessage").style.display = "inline";

	window.location = window.location.href + "#compose";
}


function MessagingHideCompose(){
	

	//show thte box
	document.getElementById("RFMessage").style.display = "none";

	try {
		document.getElementById("MessagingBtnReply").style.display = "inline";
		document.getElementById("MessagingBtnForward").style.display = "inline";

		document.getElementById("MessagingBtnReplyOff").style.display = "none";
		document.getElementById("MessagingBtnForwardOff").style.display = "none";
		
	} catch (e) {
	}
}


function DeleteSingleMessage(){

	var response = HTTPPostRequest( 
						false , 
						_URL + "account/messages/private?action=delMsg",
						{"msg[1]" : __messageDeleteSingle["msg"]}
					);

	if (response == "ok")
		window.location = _URL + "account/messages/folder.html?id=" + __messageDeleteSingle["folder"];
	else
		UserBox("messagingSelectError");

}


function DeleteSingleMsg(msg , folder){
	__messageDeleteSingle["msg"] = msg;
	__messageDeleteSingle["folder"] = folder;
	
	
	UserBox("messagingDeleteSingleMsg");
}



function MessagesPerPage(val) {
	setCookie("messaging_messages_per_page", val);
	window.location.reload();
}
var __fac_cache = {};

function ProcessFaq() {
	
	__faq__processTabs();
	__faq__processQuestions();
}

function __faq__processTabs() {
	
	var elements = document.getElementById("faqTabs").getElementsByTagName("a");
	var tmp;
	
	for (var i=0;i<elements.length;i++) {
		if (elements[i].href.indexOf(_URL) == 0) {
			elements[i].href = "javascript:void(0);";			
		}
	}

}

function faqClickTab(tab) {
	var elements = document.getElementById("faqTabs").getElementsByTagName("dd");

	for (var i=0;i<elements.length;i++) {
		if (elements[i].id == "faq_tab_" + tab)
			elements[i].className = "active";
		else
			elements[i].className = "";
	}
}

function faqClickTabContent(link){
	//get the content link
	div = document.getElementById("faqContent")
	div2 = document.getElementById("faqContentLoader")

	//add the loading image
	//div.innerHTML = "<center><img class='loading' src='/images/loading.gif'/></center>";
	div2.style.display = "block";
	div.style.display = "none";

	
	setTimeout("__clickTab('" + link + "');" , 100);
}

function __clickTab(link){
	div = document.getElementById("faqContent")
	div2 = document.getElementById("faqContentLoader")

	if (!__fac_cache[link]) {
		response = HTTPPostRequest(false , link, {
				"ajax" : "true"
		});

		//store this in the cache
		__fac_cache[link] = response;
	} else
		response = __fac_cache[link] ;

	if (response != "error") {
		div.innerHTML = response;
	} else {
		alert("error, put a nice box hre");
	}

	__faq__processQuestions();

	div2.style.display = "none";
	div.style.display = "block";

}

function __faq__processQuestions(){
	var elements = document.getElementById("faqQuestions").getElementsByTagName("a");

	var loc = window.location.href.split("#");

	for (var i=0;i<elements.length;i++) {
		if (typeof elements[i].id == "string") {
			
			if (elements[i].id.indexOf("faq_topic_") != "-1") {
				//add the jump to certain position
				elements[i].href= loc[0] + "#" + str_replace("faq_topic_" , "" , elements[i].id );
			} else {

				if (elements[i].href.indexOf("#top") != "-1") {					
					elements[i].href= loc[0] + "#";
				}
			}
		}
	}



	elements = document.getElementById("faqAnswers").getElementsByTagName("a");

	loc = window.location.href.split("#");

	for (var i=0;i<elements.length;i++) {
		if (elements[i].href.indexOf("#top") != "-1") {					
			elements[i].href= loc[0] + "#";
		}
	}

}


//defined messages

__messagesBox = {
	"logout" : {
		"title": "Logout?",
		"msg" : "Are you sure you want to logout?",
		"buttons" : {
			"Yes" : "javascript:__Logout();",
			"No" : "__close__"
		}
	},

	// MESSAGING 
	"messagingErrorToEmpty" : {
		"title" : "Error",
		"msg" : "Please enter the recipient username!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"messagingErrorToInvalid" : {
		"title" : "Error",
		"msg" : "Please enter a valid username!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"messagingErrorToSelf" : {
		"title" : "Error",
		"msg" : "You cant send messages to yourself!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"messagingErrorSubjectEmpty" : {
		"title" : "Error",
		"msg" : "Please enter the subject for the message!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"messagingErrorBodyEmpty" : {
		"title" : "Error",
		"msg" : "Please enter a text for the message!",
		"buttons" : {
			"Close" : "__close__"
		}
	},
	
	"messagingSentOk" : {
		"title" : "Success",
		"msg" : "Your message was successfuly sent. Click close to return to inbox.",
		"buttons" : {
			"Close" : "javascript:window.location='" + _URL + 'account/messages/inbox.html' + "'"
		}
	},

	"messagingSentOkDetails" : {
		"title" : "Success",
		"msg" : "Your message was successfuly sent.",
		"buttons" : {
			"Close" : "javascript:MessagingHideCompose();HideMessageBox();"
		}
	},

	"messagingSentError" : {
		"title" : "Error",
		"msg" : "There was an error sending the message. Please try again later.",
		"buttons" : {
			"Close" : "javascript:window.location='" + _URL + 'account/messages/inbox.html' + "'"
		}
	},

	"messagingNewFolder" : {
		"title" : "New Folder",
		"msg" : "<form name='newFolder' action='javascript:MessageCreateFolder()'>Folder Name:<br><input name='folder' /></form>",
		"buttons" : {
			"Create" : "javascript:document.forms['newFolder'].submit();",
			"Cancel" : "__close__"
		}
	},

	"messagingNewFolderExists" : {
		"title" : "Folder Exists",
		"msg" : "The folder you are trying to create already exists. Please use differnt name",
		"buttons" : {
			"Ok" : "javascript:MessageNewFolder();"
		}
	},

	"messagingSelect" : {
		"title" : "Error",
		"msg" : "You need to select at least one message in order to perform an action.",
		"buttons" : {
			"Ok" : "__close__"
		}
	},

	"messagingSelectError" : {
		"title" : "Error",
		"msg" : "Error performing the requested operation.",
		"buttons" : {
			"Ok" : "__close__"
		}
	},

	"messagingDeleteFolder" : {
		"title" : "Delete Folder?",
		"msg" : "Are you sure you want to delete? <br><br><center>'<font color=red>{FOLDER}</font>'</center>  <br/> <font color=red>All the messages inside that folder will be lost!</font>",
		"buttons" : {
			//do not change the yes, it its used in messaging.js to put the proper delete function there
			"Yes" : "custom",
			"No" : "__close__"
		}
	},

	"messagingDeleteSingleMsg" : {
		"title" : "Success",
		"msg" : "Are you sure you want to delete the selected message(s)?",
		"buttons" : {
			"Yes" : "javascript:DeleteSingleMessage();",
			"No" : "__close__"
		}
	},
	
	"messagingDeleteMsg" : {
		"title" : "Success",
		"msg" : "Are you sure you want to delete the selected message(s)?",
		"buttons" : {
			"Yes" : "javascript:MessageAction('delMsg');",
			"No" : "__close__"
		}
	},


	"contactPopup" : {
		"title" : "Error",
		"msg" : "Please select a common question first.",
		"buttons" : {
			"Close" : "__close__"
		}
	},






	"registerCheckOk" : {
		"title" : "Success",
		"msg" : "Username is available. ",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"registerCheckExists" : {
		"title" : "Error",
		"msg" : "Username already exists. Please try other one.",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"registerCheckError" : {
		"title" : "Error",
		"msg" : "Please fill in the username you want to verify.",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"registerFields" : {
		"title" : "Error",
		"msg" : "Please fill all the fields with valid info.",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"registerFieldsCode" : {
		"title" : "Error",
		"msg" : "Security Code doesnt match with the image",
		"buttons" : {
			"Close" : "javascript:document.forms['RegisterForm'].code.focus();HideMessageBox();"
		}
	},

	"registerFieldsPass" : {
		"title" : "Error",
		"msg" : "Password and confirmation doesnt match.",
		"buttons" : {
			"Close" : "javascript:document.forms['RegisterForm'].password.focus();HideMessageBox();"
		}
	},

	"registerFieldsUser" : {
		"title" : "Error",
		"msg" : "Username already exists. Please try other one.",
		"buttons" : {
			"Close" : "javascript:document.forms['RegisterForm'].username.focus();HideMessageBox();"
		}
	},

	"registerFieldsEmail" : {
		"title" : "Error",
		"msg" : "Email address already exists.",
		"buttons" : {
			"Close" : "javascript:document.forms['RegisterForm'].email.focus();HideMessageBox();"
		}
	},

	"registerFieldsAgree" : {
		"title" : "Error",
		"msg" : "You must accept the Flash Components Terms of Service.",
		"buttons" : {
			"Close" : "__close__"
		}
	},


	"loginFields" : {
		"title" : "Error",
		"msg" : "Please fill in all the fields.",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"loginInvalid" : {
		"title" : "Error",
		"msg" : "Invalid username or password!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"loginCode" : {
		"title" : "Error",
		"msg" : "Security code and image doesnt match!",
		"buttons" : {
			"Close" : "javascript:document.forms['LoginForm'].code.focus();HideMessageBox();"
		}
	},

	"recoverOk" : {
		"title" : "Error",
		"msg" : "Check your email address for an email with your login informations.",
		"buttons" : {
			"Close" : "javascript:window.location = _URL + 'signin.html';HideMessageBox();"
		}
	},

	"recoverEmail" : {
		"title" : "Error",
		"msg" : "Invalid email address!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"recoverFields" : {
		"title" : "Error",
		"msg" : "Please fill in all the fields!",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"recoverCode" : {
		"title" : "Error",
		"msg" : "Security code and image doesnt match!",
		"buttons" : {
			"Close" : "javascript:document.forms['RecoverForm'].code.focus();HideMessageBox();"
		}
	},


	"rateOk" : {
		"title" : "Success",
		"msg" : "Your rating was succesfuly submited!",
		"buttons" : {
			"Close" : "javascript:window.location.reload();HideMessageBox();"
		}
	},

	"rateError" : {
		"title" : "Error",
		"msg" : "Unexpected error! Please contact the administrator.",
		"buttons" : {
			"Close" : "javascript:HideMessageBox();"
		}
	},

	"rateExists" : {
		"title" : "Error",
		"msg" : "You already rated resource, you cant rate it again.",
		"buttons" : {
			"Close" : "javascript:HideMessageBox();"
		}
	},

	"rateLogin" : {
		"title" : "Error",
		"msg" : "You need to be logged in in order to rate a resource.",
		"buttons" : {
			"Close" : "javascript:HideMessageBox();",
			"Login" : "/signin.html?redirect=" + escape(window.location)
		}
	},


	"newsletterRegistered" : {
		"title" : "Success",
		"msg" : "Thank you for joining our newsletters.",
		"buttons" : {
			"Close" : "__close__"
		}
	},
	"newsletterUnregistered" : {
		"title" : "Success",
		"msg" : "We are sorry you decide to renounce to our newslettrs.",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"newsletterExists" : {
		"title" : "Error",
		"msg" : "You are already registred.",
		"buttons" : {
			"Close" : "__close__"
		}
	},

	"newsletterNotexists" : {
		"title" : "Error",
		"msg" : "The email you entered isnt in our system.",
		"buttons" : {
			"Close" : "__close__"
		}
	}


}

/* add some javascript missing functions */

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}	

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

var bites = document.cookie.split("; ");

function getCookie(name) { 
for (var i=0; i < bites.length; i++) {
  nextbite = bites[i].split("=");
  if (nextbite[0] == name)
	return unescape(nextbite[1]);
}
return null;
}

var today = new Date();
var expiry = new Date(today.getTime() + 60 * 60 * 24 * 1000); // plus 1000 days
var expiry_past = new Date(today.getTime() - 60 * 60 * 24 * 1000); // plus 1000 days

function setCookie(name, value) {
	if (value != null && value != "")
		document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
	bites = document.cookie.split("; ");
}
	
function delCookie(name) {
	document.cookie=name + "=_; expires=" + expiry_past.toGMTString();
	bites = document.cookie.split("; ");
}
	



function RegisterAvailable() {
	url = _URL + "private/register/check_availability";

	var response = HTTPPostRequest(false , url, {
			"user" : document.forms["RegisterForm"].username.value
			});

	switch (response) {
		case "ok":
			UserBox("registerCheckOk");
		break;

		case "exists":
			UserBox("registerCheckExists");

			document.forms["RegisterForm"].username.focus();
		break;

		default:
			UserBox("registerCheckError");
			document.forms["RegisterForm"].username.focus();
		break;
	}
}

function SubmitRegister() {
	url = _URL + "private/register/submit";

	//check the form first 
	var fields = Array("username" , "password" , "password_confirm" , "email" , "code");
	var error = false;
	var current = "";
	var response = "";
	for (i = 0 ; i< fields.length ; i++ ) {
		eval('response = document.forms["RegisterForm"].' + fields[i] + '.value.length;');

		if ( response < 2) {
			error = true;

			if (current == "") {
				current = fields[i];
			}
		}
	}

	if (error) {
		UserBox("registerFields");
		//focus the first element with problems
		eval('document.forms["RegisterForm"].' + current + '.focus()');
	}else {
		//seems okay, check for the passwords to match

		if (document.forms["RegisterForm"].password.value == document.forms["RegisterForm"].password_confirm.value) {

			//okay, check if the license was accepted
			if (document.forms["RegisterForm"].agree.checked == true) {
				//send the data to the server
				var response = HTTPPostRequest(
						false,
						url , 
						{
							"username" : document.forms["RegisterForm"].username.value,
							"password" : document.forms["RegisterForm"].password.value,
							"password_confirm" : document.forms["RegisterForm"].password_confirm.value,
							"email" : document.forms["RegisterForm"].email.value,
							"code" : document.forms["RegisterForm"].code.value
						}
					);


				switch (response) {
					case "code":
						UserBox("registerFieldsCode");
//						document.forms["RegisterForm"].code.focus();
					break;

					case "user:exists":
						UserBox("registerFieldsUser");
						//alert("Screen name already exists!");
						//document.forms["RegisterForm"].username.focus();
					break;

					case "email:exists":
						UserBox("registerFieldsEmail");
						//alert("Email already exists!");
						//document.forms["RegisterForm"].email.focus();
					break;

					default:						
						window.location=_URL + "account/index.html";
					break;

				}
			} else
				UserBox("registerFieldsAgree");
				//alert("You must accept the Flash Components Terms of Service");
		} else
			UserBox("registerFieldsPass");
			//alert("Password and confirmation doesnt match!");
	}
}

function UserLogout(){
	UserBox("logout");
}

function __Logout(){
	delCookie("fc_user" );
	delCookie("fc_pass");

	window.location = '/account/logout.html';

}

function UserLogin() {
	var fields = Array("login" , "password" /*, "code"*/);
	var error = false;
	var current = "";
	for (i = 0 ; i< fields.length ; i++ ) {
		if (eval('document.forms["LoginForm"].' + fields[i] + '.value.length') < 2) {
			error = true;

			if (current == "") {
				current = fields[i];
			}
		}
	}

	if (error) {
		UserBox("loginFields");
		//focus the first element with problems
		eval('document.forms["LoginForm"].' + current + '.focus()');
	} else {
		url = _URL + "private/account/submit";

		var response = HTTPPostRequest(
				false,
				url , 
				{
					"login" : document.forms["LoginForm"].login.value,
					"password" : document.forms["LoginForm"].password.value,
					//"code" : document.forms["LoginForm"].code.value,
					"remember" : document.forms["LoginForm"].remember.checked ? 1 : 0
				}
			);

		if (response.indexOf("okay;") != "-1") {

				//store the cookie
				if (document.forms["LoginForm"].remember.checked) {
					data = response.split(";");

					setCookie("fc_user" , document.forms["LoginForm"].login.value);
					setCookie("fc_pass" , data[1]);
				}

				//redirect the user to its account
				if (document.forms["LoginForm"].redirect.value != "")
					window.location = document.forms["LoginForm"].redirect.value;
				else
					window.location = _URL + "account/index.html";
		}

		switch (response) {
			case "okay":
			break;

			case "error":
				UserBox("loginInvalid");
				//alert("Invalid username or password!");
			break;

			case "code":
				UserBox("loginCode");
				//alert("Security code and image doesnt match!");
				//document.forms["LoginForm"].code.focus();
			break;
		}

	}


}

function UserRecover() {
	var fields = Array("email" , "code");
	var error = false;
	var current = "";
	for (i = 0 ; i< fields.length ; i++ ) {
		if (eval('document.forms["RecoverForm"].' + fields[i] + '.value.length') < 2) {
			error = true;

			if (current == "") {
				current = fields[i];
			}
		}
	}

	if (error) {
		UserBox("recoverFields");
		//focus the first element with problems
		eval('document.forms["RecoverForm"].' + current + '.focus()');
	} else {
		url = _URL + "private/account/recover";

		var response = HTTPPostRequest(
				false,
				url , 
				{
					"email" : document.forms["RecoverForm"].email.value,
					"code" : document.forms["RecoverForm"].code.value
				}
			);
		switch (response) {
			case "ok":
				UserBox("recoverOk");
				//alert("Check your email");
				//redirect the user to its account
			break;

			case "error":
				UserBox("recoverEmail");
				//alert("Invalid email!");
			break;

			case "code":
				UserBox("recoverCode");
				//alert("Security code and image doesnt match!");
				//document.forms["RecoverForm"].code.focus();
			break;
		}

	}

}


function ReloadSecurityImage(img) {
	img.src= _URL + "images/code.jpg?" +  (new Date()).getTime();
}

function PreviewSample(url){

	var h = 150;
	var w = 300;
	var winl = 150 ;
	var wint = 150 ;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,menubar=no,statusbar=no,status=no,resizable=yes'


	popup = window.open(url, "", winprops);	

	if (typeof(popup) == "undefined") {
		if (navigator.userAgent.indexOf("Safari") != "-1") {
			alert("We cant open a popup. Please disable your popup filter or press CTRL+SHIFT+K.");
		} else {
			alert("We cant open a popup. Please disable your popup filter.");
		}
	}
}



function SubmitComponent() {
	var fields = {
				"component_name" : "title",
				"component_cat" : "category",
				"component_brief" : "brief",
				"component_description" : "description"
			}
	

	url = _URL + "account/components/add.html";

	var query = {};

	var val = "";
	var errors = new Array();
	var count = 1;

	for (i in fields) {
		eval("val = document.forms['component']." + i + ".value");

		if (val == "") {
			errors[count] = fields[i];
			count++;
		}
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['component'].action = url;
			document.forms['component'].submit();
	}

}

function ComponentChangeImage(nw){
	var img = document.getElementById("ImageBig");
	var link = document.getElementById("ImageBigHref");

	img.src = str_replace("tn/" , "med/" , nw.src);
	link.href = str_replace("tn/" , "large/" , nw.src);

}



function ComponentChangeImage2(nw){
	var img = document.getElementById("ImageBig");
	var link = document.getElementById("ImageBigHref");

	img.src = str_replace("tn/" , "med/" , nw.src);
	link.href = str_replace("images.php?image=" , "" , str_replace("tn/" , "large/" , nw.src));

}





/*component management only, put it in other js file*/

function SubmitComponentDownload() {
	var fields = {
				"file_title" : "title",
				"file_version" : "version"
			}
	

	url = _URL + "account/components/details.html?component=" + document.forms["download"].file_component.value + "&section=4&do=store";

	var query = {};

	var val = "";
	var errors = new Array();
	var count = 1;

	for (i in fields) {
		eval("val = document.forms['download']." + i + ".value");

		if (val == "") {
			errors[count] = fields[i];
			count++;
		}
	}

	var file = 0;
	try {
		file = document.forms['download'].has_file.value;
	} catch (e) {
	}

	if (file == 0) {
		if (!document.forms['download'].file_archive.value) {
			errors[count] = "archive file";
			count++;
		}
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['download'].action = url;
			document.forms['download'].submit();
	}

}



function SubmitComponentSample() {
	var fields = {
				"sample_title" : "title"
				//"sample_description" : "description"
			}
	
	url = _URL + "account/components/details.html?component=" + document.forms["download"].sample_component.value + "&section=2&do=store";

	var query = {};

	var val = "";
	var errors = new Array();
	var count = 1;

	for (i in fields) {
		eval("val = document.forms['download']." + i + ".value");

		if (val == "") {
			errors[count] = fields[i];
			count++;
		}
	}

	var file = 0;
	try { file = document.forms['download'].has_file.value; } catch (e) {}

	if ((document.forms['download'].sample_archive.value || file )&& !document.forms['download'].sample_flash.value) {
		errors[count] = "movie file";
		count++;
	}

	if (document.forms['download'].sample_archive.value && (document.forms['download'].sample_archive.value.indexOf(".zip") == -1) && !file) {
		errors[count] = "archive must be zip";
		count++;
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['download'].action = url;
			document.forms['download'].submit();
	}
}







function SubmitComponentFeature() {
	var fields = {
				"feature_title" : "title",
				"feature_description" : "description"
			}
	
	url = _URL + "account/components/details.html?component=" + document.forms["download"].feature_component.value + "&section=1&do=store";

	var query = {};

	var val = "";
	var errors = new Array();
	var count = 1;

	for (i in fields) {
		eval("val = document.forms['download']." + i + ".value");

		if (val == "") {
			errors[count] = fields[i];
			count++;
		}
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['download'].action = url;
			document.forms['download'].submit();
	}
}



function SubmitComponentHelp() {
	var fields = {
				"help_title" : "question",
				"help_description" : "answer"
			}
	
	url = _URL + "account/components/details.html?component=" + document.forms["download"].help_component.value + "&section=3&do=store";

	var query = {};

	var val = "";
	var errors = new Array();
	var count = 1;

	for (i in fields) {
		eval("val = document.forms['download']." + i + ".value");

		if (val == "") {
			errors[count] = fields[i];
			count++;
		}
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['download'].action = url;
			document.forms['download'].submit();
	}
}



function SubmitComment(){
	//check here if the use is loogged in else rediret him there

	document.getElementById("post").style.display = "block";
	document.getElementById("subcompbutton").style.display = "none";
}

function HideComment(){
	//check here if the use is loogged in else rediret him there

	document.getElementById("post").style.display = "none";
	document.getElementById("subcompbutton").style.display = "block";
}

function __submitComment(){
	var fields = {
				"subject" : "subject",
				"message" : "message"
			}
	
	url = _URL + "component/" + document.forms["subcomment"].component.value + "/comment.html";

	var query = {};

	var val = "";
	var errors = new Array();
	var count = 1;

	for (i in fields) {
		eval("val = document.forms['subcomment']." + i + ".value");

		if (val == "") {
			errors[count] = fields[i];
			count++;
		}
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {

		var response = HTTPPostRequest(false , url, {
				"subject" : document.forms["subcomment"].subject.value,
				"message" : document.forms["subcomment"].message.value
		});


		switch (response) {
			case "login":
				ShowMessageBox( 
					"Error!", 
					"You must be logged in in order to post a comment to this component. Do you want to login ?",
					{ 
						"Yes" : _URL + "signin.html?redirect=" + escape("/components/" + document.forms["subcomment"].component.value + ".html"),
						"No" : "__close__" 
					}
				);
			break;

			case "error":
				ShowMessageBox( 
					"Error!", 
					"Your message coudnt be posted becouse of an unexpected error",
					{ 
						"Close" : "__close__" 
					}
				);
			break;

			case "ok":

				ShowMessageBox( 
					"Success", 
					"Your message was succesfuly posted.",
					{ 
						"Close" : "javascript:HideComment();HideMessageBox();" 
					}
				);

				window.location.reload();
			break;

		}
	}
}


function openImagePopup(){

	var h = 300;
	var w = 405;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,toolbar=no,menubar=no,statusbar=no,status=no,resizable=yes'


	popup = window.open("", "componentImage", winprops);	

	if (typeof(popup) == "undefined") {
		if (navigator.userAgent.indexOf("Safari") != "-1") {
			alert("We cant open a popup. Please disable your popup filter or press CTRL+SHIFT+K.");
		} else {
			alert("We cant open a popup. Please disable your popup filter.");
		}
	}
}

function PreviewComponent(comp){

	var h = 500;
	var w = 670;
	var winl = 100 ;
	var wint = 100 ;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,menubar=no,statusbar=no,status=no,resizable=yes'


	popup = window.open("/popup/component/" + comp + ".html", "", winprops);	

	if (typeof(popup) == "undefined") {
		if (navigator.userAgent.indexOf("Safari") != "-1") {
			alert("We cant open a popup. Please disable your popup filter or press CTRL+SHIFT+K.");
		} else {
			alert("We cant open a popup. Please disable your popup filter.");
		}
	}
}


function SubmitProfile() {
	

	url = _URL + "account/profile/edit.html";

	var val = "";
	var errors = new Array();
	var count = 1;

	if (document.forms["profile"].user_email.value=='') {
		errors[count++] = "email";
	}

	if ((document.forms["profile"].user_password.value !='') && (document.forms["profile"].user_password.value != document.forms["profile"].user_password_confirm.value )) {
		errors[count++] = "password and confirmation";
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['profile'].action = url;
			document.forms['profile'].submit();
	}
}


function SubmitTutorialPage() {
	

	url = _URL + "account/tutorials/details.html?tutorial=" + document.forms["download"].page_tutorial.value + "&section=1&do=store";


	var val = "";
	var errors = new Array();
	var count = 1;

	if (document.forms["download"].page_title.value=='') {
		errors[count++] = "page title";
	}

	if (document.forms["download"].page_order.value=='') {
		errors[count++] = "page order";
	}

	if (document.forms["download"].page_body.value=='') {
		errors[count++] = "page body";
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['download'].action = url;
			document.forms['download'].submit();
	}
}


function SubmitTutorial() {
	url = _URL + "account/tutorials/store.html";


	var val = "";
	var errors = new Array();
	var count = 1;

	if (document.forms["tutorial"].tutorial_title.value=='') {
		errors[count++] = "title";
	}

	if (document.forms["tutorial"].tutorial_resume.value=='') {
		errors[count++] = "brief";
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['tutorial'].action = url;
			document.forms['tutorial'].submit();
	}
}


function SubmitArticle() {
	url = _URL + "account/articles/store.html";


	var val = "";
	var errors = new Array();
	var count = 1;

	if (document.forms["article"].article_title.value=='') {
		errors[count++] = "title";
	}

	if (document.forms["article"].article_body.value=='') {
		errors[count++] = "body";
	}

	if (count > 1) {
		ShowMessageBox( 
			"Error!", 
			"Please fill the following fields in order to continue: <ul>" + errors.join("<li>") + "</ul>",
			{ "Close" : "__close__" }
		);
	} else {
			//replace the submig
			document.forms['article'].action = url;
			document.forms['article'].submit();
	}
}
function ShowTab( id ) {
	switch (id) {
		case "1":
			document.getElementById('homeTabNew').style.display = "block";
			document.getElementById('homeTabRate').style.display = "none";
			document.getElementById('homeTabDown').style.display = "none";
		break;

		case "2":
			document.getElementById('homeTabNew').style.display = "none";
			document.getElementById('homeTabRate').style.display = "block";
			document.getElementById('homeTabDown').style.display = "none";
		break;

		case "3":
			document.getElementById('homeTabNew').style.display = "none";
			document.getElementById('homeTabRate').style.display = "none";
			document.getElementById('homeTabDown').style.display = "block";
		break;

	}
}
/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * This is the integration file for JavaScript.
 *
 * It defines the FCKeditor class that can be used to create editor
 * instances in a HTML page in the client side. For server side
 * operations, use the specific integration system.
 */

// FCKeditor Class
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
{
	// Properties
	this.InstanceName	= instanceName ;
	this.Width			= width			|| '100%' ;
	this.Height			= height		|| '200' ;
	this.ToolbarSet		= toolbarSet	|| 'Default' ;
	this.Value			= value			|| '' ;
	this.BasePath		= FCKeditor.BasePath ;
	this.CheckBrowser	= true ;
	this.DisplayErrors	= true ;

	this.Config			= new Object() ;

	// Events
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
}

/**
 * This is the default BasePath used by all editor instances.
 */
FCKeditor.BasePath = '/fckeditor/' ;

/**
 * The minimum height used when replacing textareas.
 */
FCKeditor.MinHeight = 200 ;

/**
 * The minimum width used when replacing textareas.
 */
FCKeditor.MinWidth = 750 ;

FCKeditor.prototype.Version			= '2.6 Beta 1' ;
FCKeditor.prototype.VersionBuild	= '18219' ;

FCKeditor.prototype.Create = function()
{
	document.write( this.CreateHtml() ) ;
}

FCKeditor.prototype.CreateHtml = function()
{
	// Check for errors
	if ( !this.InstanceName || this.InstanceName.length == 0 )
	{
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
		return '' ;
	}

	var sHtml = '' ;

	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
	{
		sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;
		sHtml += this._GetConfigHtml() ;
		sHtml += this._GetIFrameHtml() ;
	}
	else
	{
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
		sHtml += '<textarea name="' + this.InstanceName + '" rows="4" cols="40" style="width:' + sWidth + ';height:' + sHeight + '">' + this._HTMLEncode( this.Value ) + '<\/textarea>' ;
	}

	return sHtml ;
}

FCKeditor.prototype.ReplaceTextarea = function()
{
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
	{
		// We must check the elements firstly using the Id and then the name.
		var oTextarea = document.getElementById( this.InstanceName ) ;
		var colElementsByName = document.getElementsByName( this.InstanceName ) ;
		var i = 0;
		while ( oTextarea || i == 0 )
		{
			if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )
				break ;
			oTextarea = colElementsByName[i++] ;
		}

		if ( !oTextarea )
		{
			alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
			return ;
		}

		oTextarea.style.display = 'none' ;
		this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;
		this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ;
	}
}

FCKeditor.prototype._InsertHtmlBefore = function( html, element )
{
	if ( element.insertAdjacentHTML )	// IE
		element.insertAdjacentHTML( 'beforeBegin', html ) ;
	else								// Gecko
	{
		var oRange = document.createRange() ;
		oRange.setStartBefore( element ) ;
		var oFragment = oRange.createContextualFragment( html );
		element.parentNode.insertBefore( oFragment, element ) ;
	}
}

FCKeditor.prototype._GetConfigHtml = function()
{
	var sConfig = '' ;
	for ( var o in this.Config )
	{
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
		sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ;
	}

	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
}

FCKeditor.prototype._GetIFrameHtml = function()
{
	var sFile = 'fckeditor.html' ;

	try
	{
		if ( (/fcksource=true/i).test( window.top.location.search ) )
			sFile = 'fckeditor.original.html' ;
	}
	catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }

	var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ;
	if (this.ToolbarSet) sLink += '&amp;Toolbar=' + this.ToolbarSet ;

	return '<iframe id="' + this.InstanceName + '___Frame" src="' + sLink + '" width="' + this.Width + '" height="' + this.Height + '" frameborder="0" scrolling="no"></iframe>' ;
}

FCKeditor.prototype._IsCompatibleBrowser = function()
{
	return FCKeditor_IsCompatibleBrowser() ;
}

FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription )
{
	this.ErrorNumber		= errorNumber ;
	this.ErrorDescription	= errorDescription ;

	if ( this.DisplayErrors )
	{
		document.write( '<div style="COLOR: #ff0000">' ) ;
		document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ;
		document.write( '</div>' ) ;
	}

	if ( typeof( this.OnError ) == 'function' )
		this.OnError( this, errorNumber, errorDescription ) ;
}

FCKeditor.prototype._HTMLEncode = function( text )
{
	if ( typeof( text ) != "string" )
		text = text.toString() ;

	text = text.replace(
		/&/g, "&amp;").replace(
		/"/g, "&quot;").replace(
		/</g, "&lt;").replace(
		/>/g, "&gt;") ;

	return text ;
}

;(function()
{
	var textareaToEditor = function( textarea )
	{
		var editor = new FCKeditor( textarea.name ) ;

		editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;
		editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;

		return editor ;
	}

	/**
	 * Replace all <textarea> elements available in the document with FCKeditor
	 * instances.
	 *
	 *	// Replace all <textarea> elements in the page.
	 *	FCKeditor.ReplaceAllTextareas() ;
	 *
	 *	// Replace all <textarea class="myClassName"> elements in the page.
	 *	FCKeditor.ReplaceAllTextareas( 'myClassName' ) ;
	 *
	 *	// Selectively replace <textarea> elements, based on custom assertions.
	 *	FCKeditor.ReplaceAllTextareas( function( textarea, editor )
	 *		{
	 *			// Custom code to evaluate the replace, returning false if it
	 *			// must not be done.
	 *			// It also passes the "editor" parameter, so the developer can
	 *			// customize the instance.
	 *		} ) ;
	 */
	FCKeditor.ReplaceAllTextareas = function()
	{
		var textareas = document.getElementsByTagName( 'textarea' ) ;

		for ( var i = 0 ; i < textareas.length ; i++ )
		{
			var editor = null ;
			var textarea = textareas[i] ;
			var name = textarea.name ;

			// The "name" attribute must exist.
			if ( !name || name.length == 0 )
				continue ;

			if ( typeof arguments[0] == 'string' )
			{
				// The textarea class name could be passed as the function
				// parameter.

				var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;

				if ( !classRegex.test( textarea.className ) )
					continue ;
			}
			else if ( typeof arguments[0] == 'function' )
			{
				// An assertion function could be passed as the function parameter.
				// It must explicitly return "false" to ignore a specific <textarea>.
				editor = textareaToEditor( textarea ) ;
				if ( arguments[0]( textarea, editor ) === false )
					continue ;
			}

			if ( !editor )
				editor = textareaToEditor( textarea ) ;

			editor.ReplaceTextarea() ;
		}
	}
})() ;

function FCKeditor_IsCompatibleBrowser()
{
	var sAgent = navigator.userAgent.toLowerCase() ;

	// Internet Explorer 5.5+
	if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 )
	{
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
		return ( sBrowserVersion >= 5.5 ) ;
	}

	// Gecko (Opera 9 tries to behave like Gecko at this point).
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
		return true ;

	// Opera 9.50+
	if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 )
		return true ;

	// Adobe AIR
	// Checked before Safari because AIR have the WebKit rich text editor
	// features from Safari 3.0.4, but the version reported is 420.
	if ( sAgent.indexOf( ' adobeair/' ) != -1 )
		return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ;	// Build must be at least v1

	// Safari 3+
	if ( sAgent.indexOf( ' applewebkit/' ) != -1 )
		return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ;	// Build must be at least 522 (v3)

	return false ;
}

var CalPath = "";

if (window.location.href.indexOf("admin/") == -1) {
	CalPath = "admin/3rdparty/calendar/";
} else
	CalPath = "3rdparty/calendar/";

var CalendarLibs = new Array(
						"calendar.js",
						"calendar-en.js",
						"calendar-setup.js"
					)	

for (var library in CalendarLibs)
	document.write('<script src="' + CalPath + CalendarLibs[library] + '"></script>');


//load the css
document.write('<link href="' + CalPath + 'calendar.css" rel="stylesheet" type="text/css" />');




function OpenTOS(){

	var h = 800;
	var w = 675;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no,menubar=no,statusbar=no,status=no,resizable=no'

	var url = "popup/resources/legal.html";


	popup = window.open(url, "", winprops);	

	if (typeof(popup) == "undefined") {
		if (navigator.userAgent.indexOf("Safari") != "-1") {
			alert("We cant open a popup. Please disable your popup filter or press CTRL+SHIFT+K.");
		} else {
			alert("We cant open a popup. Please disable your popup filter.");
		}
	}
}



		function TranStatus(id){
			var txt;

			switch (id) {
				case "0":
					txt = "N/A";
				break;

				case "1":
					txt = "completed";				
				break;

				case "2":
					txt = "pending";				
				break;

				case "3":
					txt = "fraud";				
				break;

				case "4":
					txt = "rejected";				
				break;
			}

			document.write(txt);
		}
