
 //getElementsById_select('div') ;

var Last_ID = 'start' ;

function init_picker() {

// alert('1') ;	

		cp1 = new Refresh.Web.ColorPicker('cp1',{startHex: 'ffcc00', startMode:'s'});

// alert('2') ;	

}	

function close_color() {
    document.getElementById("s101_css_color_picker").style.visibility = 'hidden' ;

}

function grab_color() {


  doc_color = document.xs101_css_color_picker_form.cp1_Hex.value;

  doc_color = '#' + doc_color ;

//        alert(doc_color);
		
		  item_id = document.s101_css_color_picker_form.css_item.value;

		  item_type = document.s101_css_color_picker_form.css_item_type.value;

//        doc_color = '[' +  doc_color + ']' ;

  //      alert(item_id);
	
	    
//	        alert(item_type);
	
	if (item_type == 'background') {
	
		  document.getElementById(item_id).style.backgroundColor = doc_color;
		  }
	
		if (item_type == 'font') {
	
		  document.getElementById(item_id).style.color = doc_color;
		  }
	
		  
		  item_id2 = item_id + '_' + item_type + '_display' ;
		  
		  	  item_id3 = item_id + '_' + item_type  + '_info' ;
		  
		    document.getElementById(item_id2).style.backgroundColor = doc_color ;

	    document.getElementById(item_id3).value = doc_color ;

  
    document.getElementById("s101_css_color_picker").style.visibility = 'hidden' ;


	
}

function close_div() {

//	alert("1") ;

    document.getElementById("testdiv_5").style.visibility = 'hidden' ;

//	alert("2") ;


}


function show_color_picker(item_type) {



var i = document.div_select_editor.select_div.selectedIndex;

//         alert(i);

var item = document.div_select_editor.select_div.options[i].value;

//         alert(item);

//	alert(item_type) ;









//	alert(item) ;

//	alert(item_type) ;

	
	
	document.s101_css_color_picker_form.css_item.value = item ;
	
		document.s101_css_color_picker_form.css_item_type.value = item_type ;

	
  document.getElementById("s101_css_color_picker").style.visibility = 'visible' ;


	    
}



function initialize_items() {

	
	borderLeft = CJL_getCurrentStyle(document.getElementById("s101_css_edit_slug_header"), "backgroundColor");
		
  item_value =   getStyleById("s101_css_edit_slug_header", "backgroundColor") ;

  item_value2 = toRGBHex(item_value) ;


 document.form1.s101_css_edit_slug_header_background_info.value = '#' + item_value2 ;

  document.getElementById("s101_css_edit_slug_header_background_display").style.backgroundColor = '#' + item_value2 ;

  getElementsById_select('div') ;

    
}

function toRGBHex(num)
{
var decToHex="";
var arr = new Array();
var numStr = new String();
var num2 = num.split("(");

var num3 = num2[1] ;
var num4 = num3.split(")");

var num5 = num4[0] ;


numStr = num5;


arr = numStr.split(",");

for(var i=0;i<3;i++)
{
var hexArray = new Array( "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" );
var code1 = Math.floor(arr[i] / 16);var code2 = arr[i] - code1 * 16;
decToHex += hexArray[code1];
decToHex += hexArray[code2];
}
return (decToHex);
}


// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js
function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");
	
	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match(/\b[\w-.]+(\s*\{)/g);
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of 
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}


// setStyleById: given an element id, style property and 
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}
	
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClass(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}

	return null;
}

// setStyleByTag: given an element type, style property and 
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
		var sheets = document.styleSheets;
		if(sheets.length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				if(rules.length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
						ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								s[p] = v;
							}			
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

// getStyleByTag: given an element type and style property, return
// the property's value
// args:
//  e - element type
//  p - property
function getStyleByTag(e, p) {
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		for(var i = 0; i < sheets.length; i++) {
			var rules = sheets[i].cssRules;
			if(rules.length > 0) {
				for(var j = 0; j < rules.length; j++) {
					var s = rules[j].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[j] == e) {
							return s[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((s[p] != "") && (s[p] != null)) &&
						   (rules[j].selectorText == e)) {
							return s[p];
						}
					}

				}
			}
		}
	}

	// if we don't find any style sheets, return the value for the first
	// element of this type we encounter without a CLASS or STYLE attribute
	var elements = document.getElementsByTagName(e);
	var sawClassOrStyleAttribute = false;
	for(var i = 0; i < elements.length; i++) {
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if((node.attributes.item(j).nodeName == 'class') ||
			   (node.attributes.item(j).nodeName == 'style')){
			   sawClassOrStyleAttribute = true;
			}
		}
		if(! sawClassOrStyleAttribute) {
			return elements.item(i).style[p];
		}
	}
}



/********************************************************
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 * 
 * CodeHouse.com JavaScript Library Module: Get Current Style Method
 *
 * You can obtain this script at http://www.codehouse.com
 ********************************************************/
function CJL_getCurrentStyle(elem, prop)
{
   if( elem.currentStyle )
   {  
      var ar = prop.match(/\w[^-]*/g);
      var s = ar[0];
      
      for(var i = 1; i < ar.length; ++i)		   
      {
         s += ar[i].replace(/\w/, ar[i].charAt(0).toUpperCase());
      }
           
      return elem.currentStyle[s]
   }
   else if( document.defaultView.getComputedStyle )
   {
      return document.defaultView.getComputedStyle(elem, null).getPropertyValue(prop);
   }
}




function change_body_bg() {

        //  alert('1a');
		
		borderLeft = CJL_getCurrentStyle(document.body, "margin-left");
		
		        //  alert(borderLeft);

		borderLeft = CJL_getCurrentStyle(document.getElementById("s101_css_edit_page_col2"), "width");
		
		        //  alert(borderLeft);


  item_height =   getStyleById("s101_css_edit_page_col2", "height") ;

	        //  alert(item_height) ;
			

  i = document.form1.body_bg.selectedIndex;
  doc_color = document.form1.body_bg.options[i].value;
    
        //  alert(doc_color);
  document.getElementById("s101_css_edit_page_col2").style.backgroundColor = doc_color;
}

function change_body_bg_file() {

  i = document.form1.body_bg_file.selectedIndex;
      //   alert('2');

  doc_color = document.form1.body_bg_file.value;
  
  doc_color = 'url(' + doc_color + ')' ;
  

         // alert(doc_color);
  document.getElementById("s101_css_edit_page_col2").style.backgroundImage = doc_color ;
}

function change_background_image() {

  i = document.form1.body_bg_file.selectedIndex;
       alert('2a');

  doc_color = document.form1.body_bg_file.value;
  
  doc_color = 'url(' + doc_color + ')' ;
  

         alert(doc_color);
  document.getElementById("s101_css_edit_page_col2").style.backgroundImage = doc_color ;
}

function change_body_background_image() {

  i = document.form1.body_bg_file.selectedIndex;
       alert('2a-body');

  doc_color = document.form1.body_bg_file.value;
  
  doc_color = 'url(' + doc_color + ')' ;
  

         alert(doc_color);
  document.body.style.backgroundImage = doc_color ;
}



function change_content_bg() {
  i = document.form1.content_bg.selectedIndex;
  doc_color = document.form1.content_bg.options[i].value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_page_content").style.backgroundColor = doc_color;
}

function no_content_bg() {

 alert('here');

  doc_color = '# ' ;
      alert(doc_color);
  document.getElementById("s101_css_edit_page_content").style.backgroundImage = doc_color;
}

function change_slug_bg() {
  i = document.form1.slug_bg.selectedIndex;
  doc_color = document.form1.slug_bg.value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_slug").style.backgroundColor = doc_color;
}


function change_slub_header_bg() {
  i = document.form1.slug_header_bg.selectedIndex;
  doc_color = document.form1.slug_header_bg.value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_slug_header").style.backgroundColor = doc_color;
}


function change_head() {
  i = document.form1.heading.selectedIndex;

  head_color = document.form1.heading.options[i].value;
      //  alert(head_color);
  document.getElementById("head1").style.color = head_color;
}



function change_width() {
  i = document.form1.width.selectedIndex;
  doc_width = document.form1.width.options[i].value;
      //  alert(doc_width);

  document.getElementById("s101_css_edit_page_col2").style.width = doc_width  ;

}


function change_default_font_color() {
  i = document.form1.default_font_color.selectedIndex;
  doc_color = document.form1.default_font_color.options[i].value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_slug_body").style.color = doc_color;
}


function change_default_font_size() {

         alert('font size');

var i = document.div_select_editor.select_div.selectedIndex;

         alert(i);

var item_id = document.div_select_editor.select_div.options[i].value;

          alert(item_id);

  i = document.form1.default_font_size.selectedIndex;
  doc_color = document.form1.default_font_size.options[i].value;
        //  alert(doc_color);
  document.getElementById(item_id).style.fontSize = doc_color;


}

function change_default_font_family() {

         alert('font family');

var i = document.div_select_editor.select_div.selectedIndex;

         alert(i);

var item_id = document.div_select_editor.select_div.options[i].value;

          alert(item_id);

  i = document.form1.default_font_family.selectedIndex;
  doc_color = document.form1.default_font_family.options[i].value;

  alert(doc_color);

  document.getElementById(item_id).style.fontFamily = doc_color;

  alert('done');

}

function change_font_size2(item_id) {

form_id = item_id + '_font_size' ;
          alert(form_id);

  i = document.form1.slug_header_font_size.selectedIndex;

         alert(form_id);

         alert(i);


// doc_size = document.form1.slug_header_font_size.options[i].value;

  doc_size = document.form1.slug_header_font_size.options[i].value;

          alert(doc_size);

  document.getElementById("slug_header_font_size").style.fontSize = doc_size;
}

function change_slug_header_font_size() {

         alert('size');
  i = document.form1.slug_header_font_size.selectedIndex;

         alert('size2');
//         alert(i);

  doc_color = document.form1.slug_header_font_size.options[i].value;
         alert('size3');
         alert(doc_color);
  document.getElementById("s101_css_edit_slug_header").style.fontSize = doc_color;
}

function change_default_font_family_test() {
alert('here11') ;
 i = document.form1.slug_header_font_family.selectedIndex;
  doc_color = document.form1.slug_header_font_family.options[i].value;
//  doc_color = document.form1.slug_header_font_family.value;

    alert(doc_color);
  document.getElementById("slug_header").style.fontFamily = doc_color;
}





function change_default_font_familyx() {

alert('here') ;

  i = document.form1.default_font_family.selectedIndex;
  doc_color = document.form1.default_font_family.options[i].value;
    alert(doc_color);
  document.getElementById("s101_css_edit_slug_body").style.fontFamily = doc_color;
}

function change_line_height(item_id, form_id) {

var item_id ;

var form_id ;

//alert('Line Height') ;

//alert(item_id) ;

//alert(form_id) ;

  i = eval("document.form1." + form_id + ".selectedIndex");

  doc_size = eval("document.form1." + form_id  + ".options[i].value") ;
//          alert(doc_size);

  document.getElementById(item_id).style.lineHeight = doc_size;

  //        alert('done');


}


function change_font_size(item_id, form_id) {

var item_id ;

var form_id ;

alert('Font Size') ;

//alert(item_id) ;

//alert(form_id) ;

  i = eval("document.form1." + form_id + ".selectedIndex");

  doc_size = eval("document.form1." + form_id  + ".options[i].value") ;
//          alert(doc_size);

  document.getElementById(item_id).style.fontSize = doc_size;

         alert('done');

  document.getElementsByName(item_id).style.fontSize = doc_size;

          alert('done2');


}

function change_font_family(item_id, form_id) {

var item_id ;

var form_id ;

alert(item_id) ;

alert(form_id) ;

i = eval("document.form1." + form_id + ".selectedIndex") ;

//alert(i) ;

 doc_color = eval("document.form1." + form_id + ".options[i].value") ;

    alert(doc_color);

var item_id2 = item_id + '1' ; 

//var item_id2 = item_id ; 

// item_id3 = item_id + '2' ; 

  var allHTMLTags=document.getElementsByTagName('*');

   alert('ready');

var item_list ;

  //Loop through all tags using a for loop

  for (i=0; i<allHTMLTags.length; i++) {

       var item_idx = allHTMLTags[i].className ;

	item_list = item_list + " - " +   allHTMLTags[i].className ;

   if ( item_idx == item_id2) {

   document.getElementById(item_idx).style.fontFamily = doc_color;

  }
}

   alert('done');

//  document.getElementById(item_id2).style.fontFamily = doc_color;

// document.getElementById(item_id3).style.fontFamily = doc_color;

// document.getElementsTagName(item_id).style.fontFamily = doc_color;

}


function getElementsById(id)
{
   var divs = document.getElementsByTagName(id);
   var arr = new Array();
   var temp_id = ''; 
   
//alert('css id2') ;

   for (var i=0; i < divs.length; i++)
   {

   temp_id = divs[i].id ;

   if ( temp_id.length > 0) {

     if ( temp_id != 'undefined' ) {

            var css_Items = css_Items + "<a href='#' onMouseOver=\"change_div('"+ temp_id + "', 'content_font_family', 'select');\" onMouseOut=\"change_div2('"+ temp_id + "', 'content_font_family', 'select');\" >" + temp_id + "</a><br>" ;

      }

   }
 
      if (divs[i].id == id)
      {
         alert(divs[i].id) ;

         arr[arr.length] = divs[i];


      }
   }

alert('done') ;

document.getElementById('result').innerHTML=css_Items ;

}

function change_div(item_id, value_type, new_value) {

var item_id ;

var value_type ;

var new_value ;

//alert(item_id) ;

//  i = document.form1.slug_font_color.selectedIndex;

//  doc_color = document.form1.slug_font_color.options[i].value;
        //  alert(doc_color);

    document.getElementById(item_id).style.background = 'green';

    document.getElementById(item_id).style.border = 'red groove';


//  document.getElementByTagName('homepage_latestnews').style.color = 'red';

//  document.getElementByTagName('homepage_latestnews').style.background = 'green';

  document.body.style.background = 'blue' ;

//alert('done') ;

}

function change_div2(item_id, value_type, new_value) {

var item_id ;

var value_type ;

var new_value ;

//alert(item_id) ;

//  i = document.form1.slug_font_color.selectedIndex;

//  doc_color = document.form1.slug_font_color.options[i].value;
        //  alert(doc_color);

    document.getElementById(item_id).style.background = 'white';

    document.getElementById(item_id).style.border = 'none';


//  document.getElementByTagName('homepage_latestnews').style.color = 'red';

//  document.getElementByTagName('homepage_latestnews').style.background = 'green';

  document.body.style.background = 'blue' ;

//alert('done') ;

}




function getElementsById_select(id)
{
   var divs = document.getElementsByTagName(id);
   var arr = new Array();
   var temp_id = ''; 
   
//alert('css id2') ;


var s101_compatible = document.form1.s101_compatible.value ;

//alert(s101_compatible) ;


var css_Items = "Choose Section of Page/Div:<br><form name='div_select_editor'><select name='select_div' id='select_div' onChange=\"change_div_select();\" >" ;


   for (var i=0; i < divs.length; i++)
   {

   temp_id = divs[i].id ;

   if ( temp_id.length > 0) {

     if ( temp_id != 'undefined' ) {

	

           if  ( s101_compatible == 'on' )  {

//            var css_Items = css_Items + "<a href='#' onMouseOver=\"change_div('"+ temp_id + "', 'content_font_family', 'select');\" onMouseOut=\"change_div2('"+ temp_id + "', 'content_font_family', 'select');\" >" + temp_id + "</a><br>" ;

	    if  ( temp_id.substring(0,5) != 's101_' )  {

              css_Items = css_Items + "<option value='" + temp_id + "'>" + temp_id + "</option>"  ;

	    }

          } else {

              css_Items = css_Items + "<option value='" + temp_id + "'>" + temp_id +"</option>"  ;

	  }	


      }

   }
 
      if (divs[i].id == id)
      {
         alert(divs[i].id) ;

         arr[arr.length] = divs[i];


      }
   }


     css_Items = css_Items + "</select></form><br><br>" ;


//alert('done') ;

document.getElementById('result').innerHTML=css_Items ;

}

function change_div_select() {

//alert('start') ;

var item_id ;

var value_type ;

var new_value ;


if (Last_ID != 'start') {

change_div_deselect()

}

var i = document.div_select_editor.select_div.selectedIndex;

item_id = document.div_select_editor.select_div.options[i].value;

Last_ID = item_id ;

//alert(item_id) ;



//  i = document.form1.slug_font_color.selectedIndex;

//  doc_color = document.form1.slug_font_color.options[i].value;
        //  alert(doc_color);

    document.getElementById(item_id).style.background = 'green';

    document.getElementById(item_id).style.border = 'red groove';


//  document.getElementByTagName('homepage_latestnews').style.color = 'red';

//  document.getElementByTagName('homepage_latestnews').style.background = 'green';

//  document.body.style.background = 'blue' ;

//alert('done') ;

}

function change_div_deselect() {

//alert('start') ;

var item_id ;

var value_type ;

var new_value ;


item_id = Last_ID ;

//alert(item_id) ;



//  i = document.form1.slug_font_color.selectedIndex;

//  doc_color = document.form1.slug_font_color.options[i].value;
        //  alert(doc_color);

    document.getElementById(item_id).style.background = 'white';

    document.getElementById(item_id).style.border = 'none';


//  document.getElementByTagName('homepage_latestnews').style.color = 'red';

//  document.getElementByTagName('homepage_latestnews').style.background = 'green';

//  document.body.style.background = 'blue' ;

//alert('done') ;

}




/* getElementByClass
/**********************/
var allHTMLTags = new Array();
function getElementByClass(theClass) {

alert('css') ;

// var = css_Items ;

  //Create Array of All HTML Tags
  var allHTMLTags=document.getElementsByTagName("*");
  //Loop through all tags using a for loop
  for (i=0; i<allHTMLTags.length; i++) {
  //Get all tags with the specified class name.
     if (allHTMLTags[i].className==theClass) {
       //Place any code you want to apply to all
       //pages with the class specified.
       //In this example is to ?display:none;? them
       //Making them all dissapear on the page.
       allHTMLTags[i].style.display='none';

     }

   var css_Items = css_Items + " - " + allHTMLTags[i].className ;
      
  }



document.getElementById('result').innerHTML=css_Items ;

}




function change_slug_font_color() {
  i = document.form1.slug_font_color.selectedIndex;
  doc_color = document.form1.slug_font_color.options[i].value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_slug").style.color = doc_color;
}


function change_slug_font_size() {
  i = document.form1.slug_font_size.selectedIndex;
  doc_color = document.form1.slug_font_size.options[i].value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_slug").style.fontSize = doc_color;
}

function change_slug_font_family() {
  i = document.form1.slug_font_family.selectedIndex;
  doc_color = document.form1.slug_font_family.options[i].value;
  //  alert(doc_color);
  document.getElementById("s101_css_edit_slug").style.fontFamily = doc_color;
}


function change_slug_header_font_color() {
  i = document.form1.slug_header_font_color.selectedIndex;
  doc_color = document.form1.slug_header_font_color.options[i].value;
        //  alert(doc_color);
  document.getElementById("s101_css_edit_slug_header").style.color = doc_color;
}



function change_slug_header_font_family() {
   alert('font');

  i = document.form1.slug_header_font_family.selectedIndex;
  doc_color = document.form1.slug_header_font_family.options[i].value;
   alert(doc_color);
  document.getElementById("s101_css_edit_slug_header").style.fontFamily = doc_color;
}


function close_color() {
    document.getElementById("s101_css_color_picker").style.visibility = 'hidden' ;

}

function grab_color2() {


  doc_color = document.s101_css_color_picker_form.cp1_Hex.value;

  doc_color = '#' + doc_color ;

       // alert(doc_color);
		
		  item_id = document.s101_css_color_picker_form.css_item.value;

		  item_type = document.s101_css_color_picker_form.css_item_type.value;

//        doc_color = '[' +  doc_color + ']' ;

//       alert(item_id);
	
	    
//	        alert(item_type);
	
	if (item_type == 'background') {

	       if (item_id == 'body') {

    //  alert('body');
	
		  document.body.style.background = doc_color;
   //   alert('body1');

		
		} else {

  //    alert('other');


		  document.getElementById(item_id).style.backgroundColor = doc_color;

//      alert('other2');

		}

          }
	
		if (item_type == 'font') {
	
		  document.getElementById(item_id).style.color = doc_color;
		  }
	

// Update the Display
		  
		  item_id2 = item_id + '_' + item_type + '_display' ;
		  
		  	  item_id3 = item_id + '_' + item_type  + '_info' ;

//alert(item_id2) ;
		  
		    document.getElementById(item_id3).style.background = doc_color ;


//alert('almost done2') ;


	    document.getElementById(item_id3).value = doc_color ;

//alert('almost done3') ;

  
    document.getElementById("s101_css_color_picker").style.visibility = 'hidden' ;

//alert('done') ;
	
}



function show_color_picker2(item, item_type) {


	var css_item = item ;
	
//	alert(item) ;

//	alert(item_type) ;

	
	
	document.s101_css_color_picker_form.css_item.value = item ;
	
		document.s101_css_color_picker_form.css_item_type.value = item_type ;

	
  document.getElementById("s101_css_color_picker").style.visibility = 'visible' ;


	    
}


function ahah(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function showPageEditor() {
//   alert("here") ;
   load('/js/page_edit/page_css_editor.html','s101_css_editor_popup_html');
//   alert("here2") ;
   getElementsById_select('div') ;

}


function load(name, div) {
	ahah(name,div);
  document.getElementById(div).style.visibility = 'visible' ;
  document.getElementById("s101_css_editor_popup_dragbar").style.visibility = 'visible' ;
  document.getElementById("s101_css_editor_popup_close").style.visibility = 'visible' ;


	return false;
}


function close_editor() {
  document.getElementById("s101_css_editor_popup").style.visibility = 'hidden' ;
  document.getElementById("s101_css_editor_popup_dragbar").style.visibility = 'hidden' ;
  document.getElementById("s101_css_editor_popup_close").style.visibility = 'hidden' ;
  document.getElementById("s101_css_editor_popup_html").style.visibility = 'hidden' ;

	return false;
}

