/*
globals.js.php

Copyright (c) Gareth Hadfield 2008
*/

// Config

var OPENDOTS_WEBSITE = "http://opendots.org/";

// Char codes

var VK_ESCAPE = 27;
var VK_RETURN = 13;

var HTTP_BASE_DIR = "//";

// Globals for floating windows

var GLOBAL_FLOAT_ID = 0;
var GLOBAL_FLOAT_NAME = "float_";

var GLOBAL_FLOAT_LEFT = 0;
var GLOBAL_FLOAT_TOP = 0;

var GLOBAL_FLOAT_LEFT_INCREMENT = 10;
var GLOBAL_FLOAT_TOP_INCREMENT = 10;

var GLOBAL_FLOAT_LEFT_LIMIT = 200;
var GLOBAL_FLOAT_TOP_LIMIT = 200;

var DEFAULT_FLOAT_WIDTH = 640;
var DEFAULT_FLOAT_HEIGHT = 480;

// editing

var OPENDOTS_EDIT_MODE = "OPENDOTS_EDIT_MODE";
var OPENDOTS_DISPLAY_MODE = "OPENDOTS_DISPLAY_MODE";
var OPENDOTS_MODE = OPENDOTS_DISPLAY_MODE;
// determine if in edit mode
if(location.search.search(/edit=true/) != -1){
  OPENDOTS_MODE = OPENDOTS_EDIT_MODE;
}


var SNAP_GRID = 10;

var SIZE_INCREMENT = 5;

var USE_GTCMS_LINKS = true; // adds an "edit with gtcms" link to links that have "page="

var OPENDOTS_REMOTE_PATH = location.protocol + "\/\/" + location.host + location.pathname;

var OPENDOTS_TEMPLATE_PREFIX = "opendots_template_";
var OPENDOTS_TP = OPENDOTS_TEMPLATE_PREFIX; // shorthand

var NO_INIT_ATTRIBUTES = ["class","content","style","title","name","id","template","favicon","head_style","head_script","head_extra","document_title","head_extra","opendots_template_class","opendots_template_content","opendots_template_style","opendots_template_title","opendots_template_name","opendots_template_id","opendots_template_template","opendots_template_favicon","opendots_template_head_style","opendots_template_head_script","opendots_template_head_extra","opendots_template_document_title","opendots_template_head_extra"];


// mouse

var UNKNOWN_MOUSE_BUTTON = -1;
var LEFT_MOUSE_BUTTON  = 1;
var MIDDLE_MOUSE_BUTTON = 2;
var RIGHT_MOUSE_BUTTON  = 3;

// config

var THEME_DIR = "/opendots/themes/Donald/";
var THEME_DIR_NAME = "themes/";
var CURRENT_THEME_DIR = "themes/Donald/";


var MENU_SEPARATOR = "<div class='menu_separator'></div>";

var PROPERTIES_LIMIT = 30;

var DEFAULT_OPENDOTS_PAGE = "gtdesktop_main";

var HTTP_FULL_MAIN_DIR = "http://www.gtdesktop.com/opendots/";
var HTTP_FMD = HTTP_FULL_MAIN_DIR; // shorthand

var HTTP_RELATIVE_MAIN_DIR = "opendots/";
var HTTP_RMD = HTTP_RELATIVE_MAIN_DIR; // shorthand


// dots

var DEFAULT_DOT_TOP = 100;
var DEFAULT_DOT_LEFT = 100;
var DEFAULT_DOT_WIDTH = 600;
var DEFAULT_DOT_HEIGHT = 400;

var DEFAULT_BACKGROUND_COLOR = "#C0C0FF";

var GLOBAL_DOT_LEFT = DEFAULT_DOT_LEFT;
var GLOBAL_DOT_TOP = DEFAULT_DOT_TOP;

var GLOBAL_DOT_LEFT_INCREMENT = 10;
var GLOBAL_DOT_TOP_INCREMENT = 10;

var GLOBAL_DOT_LEFT_LIMIT = 400;
var GLOBAL_DOT_TOP_LIMIT = 400;

// used for saving dots
var XML_HEADER = "<"+"?xml version='1.0' encoding='UTF-8'?>\n";

// properties page edit field colors
var menuHtml = "onmouseover='this.style.backgroundColor=\"#FFFFEE\";' onmouseout='this.style.backgroundColor=\"#F0F0F0\";'";

// attributes that can be edited and saved
var DOT_ATTRIBUTES = Array("class", "content", "style", "title", "id", "parent_id", "z_index", "content_url", "cache_content", "sub_class", "link_url", "opacity", "onclick", "onload", "onmouseover", "onmouseout", "include", "fixed");
var ALLOWED_ATTRIBUTES = Array("class", "content", "style", "title", /*"name",*/ "id", "parent_id", "z_index", "content_url", "cache_content", "sub_class", "head_style", "head_script", "document_title", "template", "link_url", "opacity", "favicon", "onclick", "onload", "onmouseover", "onmouseout", "head_extra", "include", "fixed"); // todo help text for all these
// attributes that should be assigned on a copy (eg don't copy id)
var COPY_ATTRIBUTES = Array("class", "content", "style", "title", /*"name",*/ "parent_id", "z_index", "content_url", "cache_content", "sub_class", "head_style", "head_script", "document_title", "template", "link_url", "opacity", "favicon", "onclick", "onload", "onmouseover", "onmouseout", "head_extra", "fixed");
// attributes that are events that exist already for an element eg document.onload
var EVENT_ATTRIBUTES = Array("onclick", "onload", "onmouseover", "onmouseout");

// Help text for attributes
var HELP_ATTRIBUTES = Array();

HELP_ATTRIBUTES["class"] = "The CSS class for this element/dot.";
HELP_ATTRIBUTES["content"] = "The HTML contents for this element/dot.";
HELP_ATTRIBUTES["style"] = "The CSS information for this element/dot. This style info is contained within the style= attribute of this element. In the properties window, click on the ? beside each CSS attribute for help that attribute.";
HELP_ATTRIBUTES["title"] = "The title attribute for this element/dot. This shows up as a tooltip in most browsers";
HELP_ATTRIBUTES["name"] = "An alternate identifier for this element/dot.";
HELP_ATTRIBUTES["id"] = "The basic identifier for this element/dot.";
HELP_ATTRIBUTES["parent_id"] = "The id of the element/dot that is the DOM parentNode for this element/dot. Change this to the id of any element/dot or set it to document.body (which is the id for the document.body element).";
HELP_ATTRIBUTES["z_index"] = "The position within the childNodes list of the DOM parentNode for this element/dot. (NB this is not the CSS z-index)";
HELP_ATTRIBUTES["content_url"] = "When content_url is specified, the dot gets its content from the supplied url.";
HELP_ATTRIBUTES["cache_content"] = "When false, this makes sure the content fetched from content_url is refreshed every time the page is loaded.";
HELP_ATTRIBUTES["sub_class"] = "CSS provides the 'class' property to specify a CSS class for an html element. However, in addition to the 'class' property, you can specify a second CSS class here and the info from that class will be added to the style info for this opendot. "+
  "You must include the dot (.) or hash (#) to match a class or id. You can match the CSS for any element by specifying the element name (eg. H2). "+
  "Matching is not case sensitive. Special sub_classes can provide additional processing such as the '.shadow' class which wraps the dot in a shadow.";
HELP_ATTRIBUTES["head_style"] = "Page-specific style information. This text will be placed between <style></style> tags in the <head></head> section.";
HELP_ATTRIBUTES["head_script"] = "Page-specific javascript information. This text will be placed between <script></script> tags in the <head></head> section.";
HELP_ATTRIBUTES["document_title"] = "The title of the document. This text appears in the title bar of most browsers and is stored within the <title></title> tags in the <head></head> section.";
HELP_ATTRIBUTES["template"] = "A template page is an Opendots page that provides common information that should be included in this page. If you specify the name of a page here, then all the details from that page will be loaded into this page. This allows you to reuse standard page info on several pages.";
HELP_ATTRIBUTES["link_url"] = "This provides a quick way to turn a dot into a hyperlink. Enter a url here and clicking on this dot will link to the url. However, be aware that the best way to do a hyperlink is with the anchor tag <a> since it is search engine friendly. If you use link_url, then make sure you also use text <a> links somewhere else on the page to ensure that search engines can index your site correctly.";
HELP_ATTRIBUTES["opacity"] = "How transparent this dot should be. Enter a value from 0 (invisible) to 100 (fully visible).";

HELP_ATTRIBUTES["favicon"] = "The icon that appears in the address box of the browser.";

HELP_ATTRIBUTES["onclick"] = "Javascript code to execute when this dot is clicked [eg. alert('hello');]. Within this Javascript code, the 'this' keyword refers to this dot.";
HELP_ATTRIBUTES["onload"] = "Javascript code to execute when this dot is loaded. This is called when a page has finished loading and all dots have been loaded. This is also called when a dot is placed on a page (eg. when using [copy/paste] or [duplicate], or when a control from the control palette may use onload to initialise the control). Within this Javascript code, the 'this' keyword refers to this dot.";
// "onmouseover", "onmouseout", - todo
HELP_ATTRIBUTES["head_extra"] = "Extra text that will be included in the <head></head> section of the document.";
HELP_ATTRIBUTES["include"] = "This provides a way to include javascript for the specific needs of each dot. Enter a comma-separated list of javascript files. Use a relative path to the Javascript file.";
HELP_ATTRIBUTES["fixed"] = "When false, the edit controls (eg drag bar and size box) will not display for this dot.";

// drag bar
var DRAG_BAR_OPACITY = 75;

// cache control
var CACHE_REVALIDATE = '<meta Http-Equiv="Cache-Control" Content="must-revalidate">';

var DEFAULT_HOVER_COLORS = " onmouseover=\"this.style.backgroundColor='#f0f0f0';\" onmouseout=\"this.style.backgroundColor='#FFFFFF';\" ";


var OPENDOTS_LOADING_MESSAGE_IMAGE = THEME_DIR+"loading16.gif";
var OPENDOTS_LOADING_MESSAGE_START = "<div class='loading_message'><center><img align='top' src='"+OPENDOTS_LOADING_MESSAGE_IMAGE+"'> ";
var OPENDOTS_LOADING_MESSAGE_END = "</center></div>";
var OPENDOTS_LOADING_MESSAGE = "Loading...";

var GLOBAL_SIZE_SELECTONS = ["100%", "50%", "25%", "10%", "1000px", "800px", "600px", "200px", "100px", "50px", "20px", "10px", "5px", "2px", "1px", "0px", "auto", "inherit", ""];

var GLOBAL_CURSOR_SELECTONS = ["default", "auto", "crosshair", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help"];

var ALLOWED_EDIT_FILES = ["class","content","style","title","name","id","template","favicon","head_style","head_script","head_extra","document_title","head_extra","opendots_template_class","opendots_template_content","opendots_template_style","opendots_template_title","opendots_template_name","opendots_template_id","opendots_template_template","opendots_template_favicon","opendots_template_head_style","opendots_template_head_script","opendots_template_head_extra","opendots_template_document_title","opendots_template_head_extra"];

var INSTALL_CONTROL_SUCCESS = "0";
var INSTALL_CONTROL_FAIL = "1";
var INSTALL_CONTROL_FAIL_EXISTS = "2";

var EXPORT_CONTROL_SUCCESS = "0";
var EXPORT_CONTROL_FAIL = "1";
var EXPORT_CONTROL_FAIL_EXISTS = "2";
