function get_pdf_page_values()
{
	
	//***ALERT*** If any of these values change, they will also need to change creativebrowser/generate_pdf.php
	
	var pdf_page_values = new Array();
	pdf_page_values['letter'] = new Array();
	pdf_page_values['letter']['portrait'] = new Array();
	pdf_page_values['letter']['landscape'] = new Array();
	
	pdf_page_values['legal'] = new Array();
	pdf_page_values['legal']['portrait'] = new Array();
	pdf_page_values['legal']['landscape'] = new Array();
	
	pdf_page_values['letter']['portrait']['total_width'] = 612;
	pdf_page_values['letter']['portrait']['total_height'] = 792;
	pdf_page_values['letter']['portrait']['margin_left'] = 54;
	pdf_page_values['letter']['portrait']['margin_right'] = 54;
	pdf_page_values['letter']['portrait']['margin_top'] = 54;
	pdf_page_values['letter']['portrait']['margin_bottom'] = 54;
	
	pdf_page_values['letter']['landscape']['total_width'] = 792;
	pdf_page_values['letter']['landscape']['total_height'] = 612;
	pdf_page_values['letter']['landscape']['margin_left'] = 54;
	pdf_page_values['letter']['landscape']['margin_right'] = 54;
	pdf_page_values['letter']['landscape']['margin_top'] = 54;
	pdf_page_values['letter']['landscape']['margin_bottom'] = 54;
	
	pdf_page_values['legal']['portrait']['total_width'] = 612;
	pdf_page_values['legal']['portrait']['total_height'] = 1008;
	pdf_page_values['legal']['portrait']['margin_left'] = 54;
	pdf_page_values['legal']['portrait']['margin_right'] = 54;
	pdf_page_values['legal']['portrait']['margin_top'] = 54;
	pdf_page_values['legal']['portrait']['margin_bottom'] = 54;
														
	pdf_page_values['legal']['landscape']['total_width'] = 1008;
	pdf_page_values['legal']['landscape']['total_height'] = 612;
	pdf_page_values['legal']['landscape']['margin_left'] = 54;
	pdf_page_values['legal']['landscape']['margin_right'] = 54;
	pdf_page_values['legal']['landscape']['margin_top'] = 54;
	pdf_page_values['legal']['landscape']['margin_bottom'] = 54;
	
	return pdf_page_values;

}



/**
* create a tab structure -
*/
function setTabs() {
  var tabs = $$("*[tab]");    // get all the tab links
  var selected_tab = null;    // the currently selected tab

  var selected_tabs = new Hash();

  // go through all the found tabs
  if(tabs.length > 0) {
    tabs.each(
      function(el) {
        if(!el.getProperty("default_tab")) {
          $(el.getProperty("tab")).setStyle("display","none");    // if not hide the contents (though they should be hidden using css already)
        } else {
          selected_tabs.set(el.get("tab_group"),el);
          $(el.getProperty("tab")).setStyle("display","block");
          el.addClass("tab_selected");
        }

        el.set(
          {
            "events" : {
              "mouseover" : function() {   // on mouseover set the pointer and give it some style
                      this.setStyle("cursor","pointer");
                      this.addClass("tab_selected");
                    },
              "mouseout" : function() {    // on mouseout set the cursor to normal and return the style (if it is not selected)
                      this.setStyle("cursor","normal");
                      if(selected_tabs.get(this.getProperty("tab_group")) != this) this.removeClass("tab_selected");
                    },
              "click" : function() {     // on click hide the current, show the chosen and add some style
                      if(selected_tabs.get(this.getProperty("tab_group")) != this) {
                        $(this.getProperty("tab")).setStyle("display","block");
                        if(selected_tabs.get(this.getProperty("tab_group"))) {
                          $(selected_tabs.get(this.getProperty("tab_group")).getProperty("tab")).setStyle("display","none");
                          selected_tabs.get(this.getProperty("tab_group")).removeClass("tab_selected");
                        }
                        selected_tabs.set(this.getProperty("tab_group"),this);
                      }
                    }
            }
          }
        );
      }
    );
  }
}

function copyImage() {
	
	//setTimeout('null',2000);
	var ctrlRange = document.body.createControlRange();
	ctrlRange.add(document.all('sampleImage'));
	ctrlRange.execCommand("Copy");
	
}

function copyImageSet()
{
	document.getElementById('copytype').value = 1;
	sampleswapImage();
}

function SetCookie(cookieName,cookieValue,nDays,is_unicode)
{
	var today = new Date();
	var expire = new Date();
 	var cookie_value_text = escape_url(cookieValue, is_unicode);
 
	if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+cookie_value_text+";expires="+expire.toGMTString();
}


function control_grid_background()
{
	if(document.getElementById('showGrid') != null && document.getElementById('showGrid').checked)
	{
		document.getElementById('displayArea').className = 'backgroundCanvasGrid';
		SetCookie('ldbrowser_grid',1,1,false);
	}
	else
	{
		document.getElementById('displayArea').className = 'backgroundCanvasPlain';
		SetCookie('ldbrowser_grid',-1,1,false);
	}
}

function color_picker(start_color_r, start_color_g, start_color_b)
{
	if($('colorPickerSmall') != null)
	{
		var colorPickerSmall = new MooRainbow('colorPickerSmall', {	id: 'smallColorPicker',
																		'startColor': [start_color_r, start_color_g, start_color_b],
																		onComplete: function(color) {
																			$('samplecolor').value = color.hex,
																			sampleswapImage();
																		}
		});
	}
}

function escape_url(url, is_unicode)
{ 
	if(is_unicode)
	{
		var escaped_string = escape(url);
		escaped_string = escaped_string.replace(/%/g,'%u00');
		escaped_string = escaped_string.replace('%u00u','%u');
		return escaped_string;
	}
	else
	{
		return escape(url);
	}
}