<script type="text/javascript">
// SETTING
	var imagesDir = "<?php print _BO_ICON_WYSING ?>";
	var cssDir = "ext/openwysing/styles/";
	/* fichier css pour l'iframe editables */
	var style_for_iframes = "styles_for_iframes.css";
	var popupsDir = "<?php print _BO_POPUP_WYSING ?>";
	var path_admin = "<?php echo './' ?>";
	var Dir = "";



// SPECIFIQUE AU BOX WISYWIG
	var qsParm = new Array();
	/* ---------------------------------------------------------------------- *\
	  Function    : retrieveWYSIWYG()
	  Description : Retrieves the textarea ID for which the link will be inserted into.
	\* ---------------------------------------------------------------------- */
	function retrieveWYSIWYG() {
	  var query = window.location.search.substring(1);
	  var parms = query.split('&');
	  for (var i=0; i<parms.length; i++) {
	    var pos = parms[i].indexOf('=');
	    if (pos > 0) {
	       var key = parms[i].substring(0,pos);
	       var val = parms[i].substring(pos+1);
	       qsParm[key] = val;
	    }
	  }
	}
	retrieveWYSIWYG();
	// Inserts the table code into the WYSIWYG editor
	function insert(values) {
		window.parent.insertHTML(values, 'message');
	}



	function insertHyperLink(wiw) {
		var hyperLink = document.getElementById('linkType').value + document.getElementById('url').value;
		if (hyperLink =='') var hyperLink = document.getElementById('url1').value;
		document.getElementById('wysiwyg' + 'message').contentWindow.document.execCommand("CreateLink", false, hyperLink);
		cache('form_ajax');cache('backgd');
		return false;
	}


/* DEB  BLOCK SPEC BOX INSERT TABLES */

	/* ---------------------------------------------------------------------- *\
	  Function    : init()
	  Description : Calls the initial functions when page loads.
	\* ---------------------------------------------------------------------- */
	function init_the_popop() {
		retrieveWYSIWYG();
		hideOnBorderStyles();
		hideOnBorderWidths();
		hideColorMenus();
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : retrieveWYSIWYG()
	  Description : Retrieves the textarea ID for which the table will be inserted into.
	\* ---------------------------------------------------------------------- */
	function retrieveWYSIWYG() {
	  var query = window.location.search.substring(1);
	  var parms = query.split('&');
	  for (var i=0; i<parms.length; i++) {
	    var pos = parms[i].indexOf('=');
	    if (pos > 0) {
	       var key = parms[i].substring(0,pos);
	       var val = parms[i].substring(pos+1);
	       qsParm[key] = val;
	    }
	  }
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : buildTable()
	  Description : Builds a table and inserts it into the WYSIWYG.
	\* ---------------------------------------------------------------------- */
	function buildTable() {

		// Checks if the table border will use the BORDER-COLLAPSE CSS attribute
		var collapse;
		if (document.getElementById('borderCollapse').checked == true) {
		  collapse = document.getElementById('borderCollapse').value;
			}
		else {
		  collapse = "separate";
			}

		// Builds a table based on the data input into the form
	  var table = '<table border="0" cellpadding="0" cellspacing="0" style="';
		table += 'BORDER-COLLAPSE: ' + collapse + ';';
		table += ' border: ' + document.getElementById('borderWidth').value + ' ' +  document.getElementById('borderStyle').value + ' ' +  document.getElementById('borderColor').value + ';';
	  table += ' width: ' + document.getElementById('tableWidth').value + document.getElementById('widthType').value + ';';
		table += ' background-color: ' + document.getElementById('shadingColor').value + ';"';
	  table += ' alignment="' + document.getElementById('alignment').value + '">\n';

		// Creates the number of rows and cols the table will have
		for (var i = 0; i < document.getElementById('rows').value; i++) {
		  table += '<tr>\n';
			  for (var j = 0; j < document.getElementById('cols').value; j++) {
			    table += '<td style="border: ' + document.getElementById('borderWidth').value + ' ' +  document.getElementById('borderStyle').value + ' ' +  document.getElementById('borderColor').value + '; padding: ' + document.getElementById('padding').value + ';">&nbsp;</td>\n';
			  }
			table += '</tr>\n';
	  }

		table += '</table>\n';


		// Inserts the table code into the WYSIWYG editor
		window.parent.insertHTML(table, 'message');
		cache('form_ajax');cache('backgd');
		return false;
	}

	/* ---------------------------------------------------------------------- *\
	  Function    : hideOnBorderWidths()
	  Description : Hides any table cell with an ID of "#px on" (e.g. "3px on").
	\* ---------------------------------------------------------------------- */
	function hideOnBorderWidths() {

	  var onBorderWidths = new Array();
	    onBorderWidths[0] = "1px on";
	    onBorderWidths[1] = "2px on";
	    onBorderWidths[2] = "3px on";
			onBorderWidths[3] = "4px on";
			onBorderWidths[4] = "5px on";
			onBorderWidths[5] = "6px on";

	  for (var j = 0; j < onBorderWidths.length;) {
	    document.getElementById(onBorderWidths[j]).style.display = 'none';
		  j++;
	  }
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : showOffBorderWidths()
	  Description : Shows all table cells with an ID of "#px" (e.g. "3px").
	\* ---------------------------------------------------------------------- */
	function showOffBorderWidths() {

	  var offBorderWidths = new Array();
	    offBorderWidths[0] = "1px";
	    offBorderWidths[1] = "2px";
	    offBorderWidths[2] = "3px";
			offBorderWidths[3] = "4px";
			offBorderWidths[4] = "5px";
			offBorderWidths[5] = "6px";

	  for (var j = 0; j < offBorderWidths.length;) {
	    document.getElementById(offBorderWidths[j]).style.display = 'block';
		  j++;
	  }
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : selectWidth()
	  Description : Selects the width to be used in the output table.
		Usage       : selectWidth("3px")
	\* ---------------------------------------------------------------------- */
	function selectWidth(id) {

	  // Hide the currently selected width
	  hideOnBorderWidths();

		// Show all of the width options as unselected
		showOffBorderWidths();

		// Hide the "off" element and replace with an "on" element so option appears selected
		document.getElementById(id).style.display = 'none';
		document.getElementById(id + ' on').style.display = 'block';

		// Assign value to <input type="hidden" id="borderWidth">
		document.getElementById('borderWidth').value = id;
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : hideOnBorderStyles()
	  Description : Hides any table cell with an ID of "borderstyle on"
			      (e.g. "dashed on").
	\* ---------------------------------------------------------------------- */
	function hideOnBorderStyles() {

	  var onBorderStyles = new Array();
	    onBorderStyles[0] = "No Border on";
	    onBorderStyles[1] = "solid on";
	    onBorderStyles[2] = "dashed on";
			onBorderStyles[3] = "dotted on";
			onBorderStyles[4] = "double on";
			onBorderStyles[5] = "inset on";
			onBorderStyles[6] = "outset on";
			onBorderStyles[7] = "groove on";
			onBorderStyles[8] = "ridge on";

	  for (var j = 0; j < onBorderStyles.length;) {
	    document.getElementById(onBorderStyles[j]).style.display = 'none';
		  j++;
	  }
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : showOffBorderStyles()
	  Description : Shows all table cells with an ID of "borderstyle"
			      (e.g. "solid").
	\* ---------------------------------------------------------------------- */
	function showOffBorderStyles() {

	  var offBorderStyles = new Array();
	    offBorderStyles[0] = "No Border";
	    offBorderStyles[1] = "solid";
	    offBorderStyles[2] = "dashed";
			offBorderStyles[3] = "dotted";
			offBorderStyles[4] = "double";
			offBorderStyles[5] = "inset";
			offBorderStyles[6] = "outset";
			offBorderStyles[7] = "groove";
			offBorderStyles[8] = "ridge";

	  for (var j = 0; j < offBorderStyles.length;) {
	    document.getElementById(offBorderStyles[j]).style.display = 'block';
		  j++;
	  }
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : selectBorder()
	  Description : Selects the border style to be used in the output table.
		Usage       : selectBorder("dashed")
	\* ---------------------------------------------------------------------- */
	function selectBorder(id) {

		// Hide the currently selected border style
	  hideOnBorderStyles();

		// Show all of the border style options as unselected
		showOffBorderStyles();

		// Hide the "off" element and replace with an "on" element so option appears selected
		document.getElementById(id).style.display = 'none';
		document.getElementById(id + ' on').style.display = 'block';

		// Assign value to <input type="hidden" id="borderStyle">
		document.getElementById('borderStyle').value = id;
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : hideColorMenus()
	  Description : Hide the menus used for selecting the border color and
			      shading color.
	\* ---------------------------------------------------------------------- */
	function hideColorMenus() {
	  document.getElementById('borderColorMenu').style.display = "none";
		document.getElementById('shadingColorMenu').style.display = "none";
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : showBorderColorMenu()
	  Description : Show the border color menu so user can select the table's
			      border color.
	\* ---------------------------------------------------------------------- */
	function showBorderColorMenu() {
	  document.getElementById('borderColorMenu').style.display = "block";
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : previewBorderColor()
	  Description : When mousing over a border color display the color in the
			      preview square.
	\* ---------------------------------------------------------------------- */
	function previewBorderColor(color) {
	  document.getElementById('borderColorPreview').style.backgroundColor = color;
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : selectBorderColor()
	  Description : Assigns the selected border color to
			      <input type="hidden" id="borderColor">.
	\* ---------------------------------------------------------------------- */
	function selectBorderColor(color) {
	  document.getElementById('borderColorPreview').style.backgroundColor = color;
		document.getElementById('borderColorMenu').style.display = "none";
		document.getElementById('borderColor').value = color;
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : showShadingColorMenu()
	  Description : Show the shading color menu so user can select the table's
			      shading color.
	\* ---------------------------------------------------------------------- */
	function showShadingColorMenu() {
	  document.getElementById('shadingColorMenu').style.display = "block";
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : previewShadingColor()
	  Description : When mousing over a shading color display the color in the
			      preview square.
	\* ---------------------------------------------------------------------- */
	function previewShadingColor(color) {
	  document.getElementById('shadingColorPreview').style.backgroundColor = color;
	}



	/* ---------------------------------------------------------------------- *\
	  Function    : selectShadingColor()
	  Description : Assigns the selected shading color to
			      <input type="hidden" id="shadingColor">.
	\* ---------------------------------------------------------------------- */
	function selectShadingColor(color) {
	  document.getElementById('shadingColorPreview').style.backgroundColor = color;
		document.getElementById('shadingColorMenu').style.display = "none";
		document.getElementById('shadingColor').value = color;
	}
/* FIN BLOCK SPEC BOX INSERT TABLES */


/* DEB BLOCK SPEC BOX INSERT COLOR */
	/* ---------------------------------------------------------------------- *\
	  Function    : retrieveWYSIWYG()
	  Description : Retrieves the textarea ID for which the color will be inserted into.
	\* ---------------------------------------------------------------------- */
// 	function retreiveColor() {
// 	  var query = window.location.search.substring(1);
// 	  var parms = query.split('&');
// 	  for (var i=0; i<parms.length; i++) {
// 	    var pos = parms[i].indexOf('=');
// 	    if (pos > 0) {
// 	       var key = parms[i].substring(0,pos);
// 	       var val = parms[i].substring(pos+1);
// 	       qsParm[key] = val;
// 	    }
// 	  }
// 	  document.getElementById('enterColor').value = "#" + (qsParm['color']);
// 	}
	/* ---------------------------------------------------------------------- *\
	  Function    : selectColor()
	  Description : Selects the color and inserts it into the WYSIWYG
	\* ---------------------------------------------------------------------- */
	function selectColor(color,qsParm2) {
// 		window.parent.document.getElementById('wysiwyg' + qsParm['wysiwyg']).contentWindow.document.execCommand(qsParm['command'], false, color);
// 		window.parent.myLightWindow.deactivate();
		document.getElementById('wysiwyg' + 'message').contentWindow.document.execCommand(qsParm2, false, color);
// 		window.parent.insertHTML(values, 'message');
		cache('form_ajax');cache('backgd');
		return false;
	}


	/* ---------------------------------------------------------------------- *\
	  Function    : previewColor()
	  Description : Updates the preview pane as the user mouses over different colors
	\* ---------------------------------------------------------------------- */
	function previewColor(color) {
	  	document.getElementById('enterColor').value = color;
		document.getElementById('PreviewColor').style.backgroundColor = color;
	}
/* FIN BLOCK SPEC BOX INSERT COLOR */
</script>