//JS for Members Only Site
var clkFunc = Object;
var selectedColorItem = '';
var selectedFontItem = '';

function showSitePages(ele)
{
	if(ele.value != 0)
	{
		$('redirect_custom').disabled = true;
	}
	else
	{
		$('redirect_custom').disabled = false;
	}
	xajax_mos_domain_list(ele.value);
}

function get_domain()
{
  var the_url     = window.location.href;
  var lead_slashes = the_url.indexOf("//");
  var domain_start = lead_slashes + 2;
  var without_resource = the_url.substring(domain_start, the_url.length);
  var next_slash = without_resource.indexOf("/");
  var domain = without_resource.substring(0, next_slash);
  return domain;
}

function linkHighLighter(linkId)
{
	this.currentColor = '';
	this.currentTextColor = '';	
	if(linkId == undefined)
	{
		linkId = 'list_link';
	}
	
	this.changeTo = function (e)
	{
		var hlc = '#FDDB55';
		var source = Event.element(e);
		var linkClass = source.className;
		if (source.style.backgroundColor != hlc && linkClass == linkId)
		{
			this.currentColor = source.style.backgroundColor;
			this.currentTextColor = source.style.color;
			source.style.backgroundColor = hlc;
			source.style.color = "#B0251E";
			source.style.textDecoration = "underline";
		}
	}
	
	this.changeBack = function (e)
	{
		var source = Event.element(e);
		source.style.backgroundColor = this.currentColor;
		source.style.color = this.currentTextColor;
		source.style.textDecoration = "none";
	}
	
	this.loadLinks = function()
	{
		//var ele = getElementsByClassNameArr(document,"*",linkId);
		var ele = $$('.'+linkId);
		for(var i=0; i<ele.length; i++)
		{
			Event.observe(ele[i], "mouseover", this.changeTo, false);
			Event.observe(ele[i], "mouseout", this.changeBack, false);
		}
	}	
}


function go_url(url)
{
	self.location.href = url;
}

function myopen(url, name, w, h)
{
	popupWindow=window.open(url,name,'resizable=no,width='+w+',height='+h+'');
  if (popupWindow.opener == null) popupWindow.opener = self;
  popupWindow.focus();
}

function myOpenScroll(url, name, w, h)
{
	popupWindow = window.open(url,name,'scrollbars=yes,width='+w+',height='+h+'');
  if (popupWindow.opener == null) popupWindow.opener = self;
  popupWindow.focus();
}

function help()
{ 
	var helpon = $('help_on');
	var ele = $('help');
	if(ele.style.display == '')
	{
		if(helpon)
		{
			helpon.value = 0;
		}
		Effect.BlindUp('help');
	}
	else
	{
		if(helpon)
		{
			helpon.value = 1;
		}
		Effect.BlindDown('help');
	}
}

function popUp(url) 
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=525,height=300,left=440,top=312');");
}

function del_conf(des_id, page_name, extra, desc)
{
	if(!desc)
		desc = 'Remove this item?';
	
  if (des_id > 0)
  {
    if (confirm(desc))
    {
      parent.location = page_name + "?del=" + des_id + extra;
    }
  }
}
  
function assignClassEvents()
{
	var eleArr = $$(".updateButton, .btn_banner_go, .btn_popup_go");
	eleArr.each(function(ele){
		switch(ele.className){
			case "updateButton":
				var submitUpdate = function(){document.builderForm.submit();}
				Event.observe(ele, "click", submitUpdate, false);
				break;
			case "btn_banner_go":
				var bannerSubmit = function(){document.banner_content_form.submit();}
				Event.observe(ele, "click", bannerSubmit, false);
				break;
			case "btn_popup_go":
				var popupSubmit = function(){document.popup_content_form.submit();}
				Event.observe(ele, "click", popupSubmit, false);		
				break;
		}
	});
}


function slider(id, loc)
{
	new Control.Slider('slide'+id,'slideBar'+id,{
		minimum: 0, maximum: 200, increment: 2, sliderValue: (loc/360),
		onSlide:function(v){$('textAngle'+id).value = parseInt(v*360)},
    onChange:function(v){$('textAngle'+id).value = parseInt(v*360);
    	document.builderForm.submit();}
    });
}

function showFaq(ele)
{
	var theTr = ele.parentNode.parentNode.nextSibling;
	//alert(theTr.style.display);
	if(navigator.appName.indexOf("Microsoft") > -1)
	{
		var canSee = 'block'
	} else {
		var canSee = 'table-row';
	}

	if(theTr.style.display == canSee)
	{
		theTr.style.display = "none";
	}
	else
	{
		theTr.style.display = canSee;
	}
}

function get_list_details(list_id, lead_id,e)
{
	var ele = $("leadrowd"+lead_id);
	if(ele)
		Element.remove(ele);
	else
		xajax_mos_list_details(list_id, lead_id);
}

function get_commission_details(td, month, year)
{
	var ele = $("commrowd"+month+year);
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View Details";
	}
	else
	{
		xajax_mos_commission_details(month, year);
		setTimeout(function(){var lh = new linkHighLighter('list_link2');lh.loadLinks();},500);
		td.innerHTML = "Hide Details";
	}
}

function get_order_details(td, id)
{
	var ele = $("odrowd"+id);
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View Details";
	}
	else
	{
		xajax_mos_order_details(id);
		td.innerHTML = "Hide Details";
	}
}

function get_member_details(td,memid)
{
	var ele = $("memrowd"+memid);
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View "+memid;
	}
	else
	{
		xajax_mos_member_details(memid);
		td.innerHTML = "Hide "+memid;
	}
}

function mos_sim_details(td,proid)
{
	var ele = $("msgd"+proid);
	
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View "+proid;
	}
	else
	{
		xajax_mos_sim_details(proid);
		td.innerHTML = "Hide "+proid;
	}
}

function mos_show_msg(td, id)
{
	var ele = $("msgd"+id);
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View Message";
	}
	else
	{
		xajax_mos_msg_details(id);
		td.innerHTML = "Hide Message";
	}
}


function get_commission_breakdown(td,month,year,level)
{
	var ele = $("cbrowd"+month+year+level);
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View Breakdown";
	}
	else
	{
		xajax_mos_commission_breakdown(month,year,level);
		td.innerHTML = "Hide Breakdown";
	}
}

function get_memail_details(td,series_id)
{
	var ele = $("cbrowd"+series_id);
	var rem = td.nextSibling.nextSibling;
	
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View Emails";
	}
	else
	{
		xajax_mos_memail_details(series_id);
		setTimeout(function(){var lh = new linkHighLighter('list_link2');lh.loadLinks();},500);
		td.innerHTML = "Hide Emails";
	}
}


function get_payment_details(td, month, year)
{
	var ele = $("payd"+month+year);
	if(ele)
	{
		Element.remove(ele);
		td.innerHTML = "View Details";
	}
	else
	{
		xajax_mos_payment_details(month, year);
		td.innerHTML = "Hide Details";
	}
}
function remote_sim_launch()
{
	messenger = window.open("http://"+get_domain()+"/members/messenger_remote_list.php", "sim_remote_list", "location=no, statusbar=no, status=no, scrollbars=no, width=600, height=315");
} 

function show_dl_details(obj)
{
	while (obj)
	{
		if(obj.className == "dlExtra")
		{
			var found = obj;
			break;
		}
		obj = obj.nextSibling;
	}

	if (found.style.display == 'block')
	{
		found.style.display = 'none'
	}
	else
	{
		found.style.display = 'block'
	}
}

function show_news(id)
{
	var ele = $("x"+id);
	if(ele)
	{
		xajax_mos_show_news(id,"hide");
		//td.innerHTML = "Show Breakdown";
	}
	else
	{
		xajax_mos_show_news(id,"show");
		//td.innerHTML = "Hide Breakdown";
	}
}

/* --- New Color Picker --- */
function loadColorPicker()
{	
	if(document.getElementById('colorTable'))
	{
		var color = '';
		var thumbnails = document.getElementById('pageThumbnails');
		var selRow = document.getElementById('colorSelectionRow');
		var eleArr = $$(".colorBox, .siteColorBox, .selectMultiColor");
		eleArr.each(function(ele){
			switch(ele.className){
				case "colorBox":
					ele.onmouseover = function(e) {showColorSelection(e);};
					ele.onclick = function(e) {setColor(e);};
					break;
				case "siteColorBox":
					if(thumbnails){
						ele.onmouseover = function(e) {showColorSelection(e);};
						ele.onclick = function(e) {setColor(e);};
					}
					break;
				case "selectMultiColor":
					if(selRow){
						Event.observe(ele, 'click', function(e) {showColorPicker(e)}, false);
					}
					break;
			}
		});
	}
}

function showColorPicker(e)
{
	var ele = eventSrcEle(e);
	var colorPicker = document.getElementById('colorPickerHidden');
	if(colorPicker.style.display == "none"||colorPicker.style.display == "")
	{
        /*
		try {
      colorPicker.style.display = 'table-row';
    } catch(e) {
      colorPicker.style.display = 'block';
    }
        */
          if(Prototype.Browser.IE) {
            colorPicker.style.display = 'block';
          } else {
            colorPicker.style.display = 'table-row';
          }
	}
	else
	{
		if(selectedColorItem == ele.id)
		{
			colorPicker.style.display = "none";
		}
		else
		{
			selectedColorItem = ele.id;
		}
	}
	document.getElementById('colorShow').style.backgroundColor = ele.style.backgroundColor;
	selectedColorItem = ele.id;
}

function showColorSelection(e)
{
	var ele = eventSrcEle(e);
	document.getElementById('colorShow').style.backgroundColor = ele.style.backgroundColor;
}

function setColor(e)
{
	var page       = pageName[0];
	var submitType = pageName[1];
	var variable    = 'background_color';
	if(pageName[2]) {variable = pageName[2];}

	if(typeof pageName == "undefined")
	{
		alert('There seems to be a problem with the Color Picker. \n Please submit a Support Ticket.');
	}
	else
	{
		var ele = eventSrcEle(e);
		var hex = ele.style.backgroundColor;
		if(hex.indexOf('gb') > 0)
		{
			var start = hex.indexOf('(');
			var end = hex.indexOf(')');
			hex = hex.substring(start+1,end);
			hex = hex.split(',');
			hex = rgbToHex(strTrim(hex[0]),strTrim(hex[1]),strTrim(hex[2]));
		}
		else if(hex.indexOf('#') === 0)
		{
			hex = hex.split('#')[1];
		}
		if(submitType == "get"){
			go_url(page+"?"+variable+"="+hex);
		}
		else if(submitType == "ajax") {
			document.getElementById('hidden_'+selectedColorItem).value = hex;
			document.getElementById('colorPickerHidden').style.display = "none";
			var box = document.getElementById(selectedColorItem);
			page(box, hex);
		}
		else if(submitType == "input") {
			var elem = document.getElementById(selectedColorItem);
			document.getElementById(selectedColorItem).style.backgroundColor = "#"+hex;
			if(elem.hasClassName(variable)){
				page('preview');
			}
			else {
				$(selectedColorItem).previous('input').value = hex;
				page('box');
			}
			document.getElementById('colorPickerHidden').style.display = "none";
		}
		else
		{
			document.getElementById('hidden_'+selectedColorItem).value = hex;
			document.getElementById('colorPickerHidden').style.display = "none";
  			document.forms[page].submit();
		}
	}
}

function eventSrcEle(e)
{
	if (!e) var e = window.event;
	var ele = (window.event) ? e.srcElement : e.target;
	return ele;
}

function rgbToHex(r,g,b)
{
	return toHex(r)+toHex(g)+toHex(b);
}

function toHex(N)
{
 	if (N==null) return "00";
 	N=parseInt(N);
 	if (N==0 || isNaN(N)) return "00";
 	N=Math.max(0,N);
 	N=Math.min(N,255);
 	N=Math.round(N);
 	return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
}

function strTrim(strText) 
{ 
	while (strText.substring(0,1) == ' ') 
    strText = strText.substring(1, strText.length);
	while (strText.substring(strText.length-1,strText.length) == ' ')
    strText = strText.substring(0, strText.length-1);
 		return strText;
}
/* --- End Color Picker --- */


/*------ Font Picker--------*/
function fontPicker()
{
	if(typeof textImageArray == "undefined")
		return null;
		
	var idNum = '';
	var scrollBox = '';
	var allImg = new Image(1,1);
	for(var i=0; i < textImageArray-2; i++)
	{
		allImg.src = textImageArray[i].split('=')[1].split('" />')[0];
	}
	allImg = null;
			
	this.showHideOptions = function(elem)
	{
		idNum = elem.id.substring(isNumeric(elem.id));
		scrollBox = document.getElementById('scrollBox'+idNum);
		var img = document.getElementById("expandArrowImg"+idNum);
		if(scrollBox.style.display == "none" || scrollBox.style.display == "")
		{
			scrollBox.style.display = "block";
			img.src = "http://"+get_domain()+"/theme/mos/hideScrollBox.gif";
		}
		else
		{
			scrollBox.style.display = "none";
			img.src = "http://"+get_domain()+"/theme/mos/showScrollBox.gif";
		}
	}
	
	this.selectionHighlight = function(ele, showHide)
	{
		if(showHide == "show")
		{
			ele.style.backgroundColor = "#FEC633";
			this.showHideExample(ele.id, 'show');
		}
		else
		{
			ele.style.backgroundColor = "white";
			this.showHideExample(ele.id, 'hide');
		}
	}

	this.showHideExample = function(eleId, showHide)
	{
		if(showHide == "show")
		{
			var pos = document.getElementById('currentSelection'+idNum);
			var toolTip = document.createElement('div');
			toolTip.id = "toolTip"+idNum;
			toolTip.className = "toolTip";
			toolTip.innerHTML = textImageArray[eleId.split('val')[1]];	
			toolTip.style.left = findPosX(pos)-40+'px';
			toolTip.style.top = findPosY(pos)-20+'px';
			document.body.appendChild(toolTip);
		}
		else
		{
			if(document.getElementById("toolTip"+idNum))
				document.body.removeChild(document.getElementById("toolTip"+idNum));
		}
	}
	
	this.selectSelected = function(ele)
	{
		var parId = ele.parentNode.id.substring(isNumeric(ele.parentNode.id));
		if(parId != idNum)
		{
			idNum = parId;
		}
		this.showHideOptions(document.getElementById('scrollBox'+idNum));
		document.getElementById('currentSelection'+idNum).innerHTML = ele.innerHTML;
		var page = pageName[0];
		var id = ele.id.split('val')[1];
		document.getElementById("hidden_text_font"+idNum).value = id;
		if(typeof(window['fontMethod']) != "undefined"){
		}
		else {
			fontMethod = '';
		}
		if(fontMethod == 'ajax'){

		}
		else
		{
	  		document.forms[page].submit();
		}
	}	
}
/*------ End Font Picker ------*/

function isNumeric(str)
{
	var ValidChars = "0123456789";
	var IsNumber = true;
	var Char;
	var pos = 0;
	if(str.length > 1)
	{
		for (i = 0; i < str.length && IsNumber == true; i++) 
	  { 
	  	Char = str.charAt(i); 
	  	if (ValidChars.indexOf(Char) != -1) 
	    	return i;
	  }
   	return false;
	}
	else
	{
		if(ValidChars.indexOf(str) != -1)
			return true;
		else
			return false;
	}
}

function findPosX(obj)
{
  var curleft = 0;
  if(obj.offsetParent)
    while(1)
    {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
  else if(obj.x)
      curleft += obj.x;
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if(obj.offsetParent)
    while(1)
    {
      curtop += obj.offsetTop;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}

function Clock()
{
	var hours;
	var minutes;
	var seconds;
	this.timer=null;
	
	function MakeArrayday(size)
	{
	  this.length = size;
	  for(var i = 1; i <= size; i++)
	    this[i] = "";
	  return this;
	}
	
	function MakeArraymonth(size)
	{
	  this.length = size;
	  for(var i = 1; i <= size; i++)
	    this[i] = "";
	  return this;
	}
	
	this.init = function(h,m,s)
	{
	  hours=h;
	  minutes=m;
	  seconds=s;
	  var fwork = function() { work() };
	  if(this.timer){clearInterval(this.timer);this.timer=null;}
	  this.timer=setInterval( fwork ,1000);
	}
	
	function twoDigit(_v)
	{
	  if(_v<10)_v="0"+_v;
	  return _v;
	}
	
	function work()
	{
	  if (!document.layers && !document.all && !document.getElementById) return;
	  var runTime = new Date();
	  var dn = " am";
	  var shours = hours;
	  var sminutes = minutes;
	  var sseconds = seconds;
	  /*if (shours >= 12)
	  {
	    dn = " pm";
	    shours-=12;
	  }
	  if (!shours) shours = 12;*/
	  sminutes=twoDigit(sminutes);
	  sseconds=twoDigit(sseconds);
	  shours  =twoDigit(shours  );
	  movingtime = ""+ shours + ":" + sminutes +":"+sseconds;
	  if (document.getElementById)
	    document.getElementById("clock").innerHTML=movingtime;
	  else if (document.layers)
	  {
	    document.layers.clock.document.open();
	    document.layers.clock.document.write(movingtime);
	    document.layers.clock.document.close();
	  }
	  else if (document.all)
	    clock.innerHTML = movingtime;
	
	  if(++seconds>59)
	  {
	    seconds=0;
	    if(++minutes>59)
	    {
	      minutes=0;
	      if(++hours>23)
	      {
	        hours=0;
	      }
	    }
	  }
	}
}

function stepsHelp(ele, step, state, isEditor)
{
	if (state == 'show') {
		var stepHelp = document.createElement('div');
		stepHelp.innerHTML = stepsHelpArr[step];
		stepHelp.id = "stepHelpBox";
		if (isEditor) {
			stepHelp.style.left = (findPosX(ele)-175)+'px';
		}
		else {
			stepHelp.style.left = (findPosX(ele))+'px';
			stepHelp.style.top = (findPosY(ele)+40)+'px';
		}
		stepHelp.style.backgroundPosition = "top left";
		document.body.appendChild(stepHelp);
	}
	else {
		if(document.getElementById('stepHelpBox')) {
			document.body.removeChild(document.getElementById('stepHelpBox'));
   	}
	}
}

activateMenu = function(nav) {
	/* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {
		var navroot = document.getElementById(nav);
		/* Get all the list items within the menu */
		var lis=navroot.getElementsByTagName("LI");
		for (i=0; i<lis.length; i++) {
			/* If the LI has another menu level */
			if(lis[i].lastChild.tagName=="UL"){
				/* assign the function to the LI */
				lis[i].onmouseover=function() {
					/* display the inner menu */
					this.lastChild.style.display="block";
				}
				lis[i].onmouseout=function() {
					this.lastChild.style.display="none";
				}
			}
		}
  }
}
	
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getScrollY() {
	var scrollY = 0;
	if (document.documentElement && document.documentElement.scrollTop){
		scrollY = document.documentElement.scrollTop;
	}
	else if (document.body && document.body.scrollTop){
		scrollY = document.body.scrollTop;
	}
	else if (window.pageYOffset){
		scrollY = window.pageYOffset;
	}
	else if (window.scrollY){
		scrollY = window.scrollY;
	}
	return scrollY;
}


function mos_init()
{
	//IEHoverPseudo();
	var lhr = new linkHighLighter();
	lhr.loadLinks();
	assignClassEvents();
	activateMenu('vertnav'); 
	loadColorPicker();
	fontPick = new fontPicker();
}

function header_init()
{
	var lhr = new linkHighLighter();
	lhr.loadLinks();
	assignClassEvents();
	loadColorPicker();
	fontPick = new fontPicker();
}

/***** Overlay Builder *****/
var overlayClassCnt = 1;
var overlayBuilder = Class.create();
overlayBuilder.prototype = {
	id : '',
	pageSizeArr : [],
	overlay : {},
	overlayBox : {},
	overlayBoxW : 0,
	overlayBoxH : 0,
	cFunc : {},
	
	initialize : function() {
		this.id = overlayClassCnt++;
		this.pageSizeArr = getPageSize();
		this.overlay = document.createElement('div');
		this.overlay.id = "overlay";
		this.overlay.style.width = this.pageSizeArr[0]+"px";
		this.overlay.style.height = this.pageSizeArr[1]+"px";
		this.overlay.style.display = "none";
		this.overlay.cFunc = function(){};
		Element.extend(this.overlay)
		document.body.appendChild(this.overlay);
		Event.observe(window, 'resize', function(){this.resizeAdjust()}.bind(this));
	},
	
	resizeAdjust : function() {
		this.pageSizeArr = getPageSize();
		this.overlay.style.width = this.pageSizeArr[0]+"px";
		this.overlay.style.height = this.pageSizeArr[1]+"px";
		this.setLocation(this.overlayBox);
	},
	
	buildBox : function(w) {
		this.overlayBox = document.createElement('div');
		this.overlayBox.className = "overlayBox";
		this.overlayBox.id = "overlayBox_"+this.id;
		this.overlayBoxW = w;
		this.overlayBox.style.width = w+"px";
		this.overlayBox.style.display = "none";
		this.overlayBox.innerHTML = '<h2></h2><div class="contentOlBox" id="contentOlBox_'+this.id+'"></div><div class="buttonBarOlBox" id="buttonBarOlBox_'+this.id+'"></div>';
		Element.extend(this.overlayBox)
		document.body.appendChild(this.overlayBox);
		this.addButton("close", "Close", function(){this.close()}.bind(this), "http://www.profitdev.com:81/theme/mos/iconFieldRemove.gif");
	},
	
	show : function() {
		this.setDropDowns("hide");
		this.setLocation(this.overlayBox);
		this.overlay.style.display = "block"
		this.overlayBox.style.display = "block"

	},
	
	addButton : function(id, title, callb, img) {
		var btn = document.createElement('div');
		btn.className = "buttonOlBox";
		btn.id = id+"OlBtn_"+this.id;
		btn.innerHTML = title;
		btn.style.display = "none";
		$('buttonBarOlBox_'+this.id).appendChild(btn);
		btn.style.background = btn.style.backgroundColor+" url('"+img+"') no-repeat 5px 50%";
		Event.observe(btn, 'click', callb);
		btn.show();
	},
	
	setTitle : function(title) {
		this.overlayBox.down('h2').innerHTML = title;
	},
	
	setContent : function(content) {
		$('contentOlBox_'+this.id).update(content);
	},
	
	setBoxWidth : function(width) {
		this.overlayBox.style.width = width+"px";
	},
	
	setLocation : function(ele) {
		var wh = this.overlayBox.getDimensions();
		var scrollY = getScrollY();
		ele.style.left = ((this.pageSizeArr[2]-wh.width)/2)+"px";
		ele.style.top = (((this.pageSizeArr[3]-wh.height)/2)+scrollY)+"px";
	},
	
	setDropDowns : function(state) {
		$A(document.getElementsByTagName('select')).each(function(ele){
			Element.extend(ele)
			if(!ele.up('.overlayBox')) {		
				if(state == "show")
					ele.show();
				else 
					ele.hide();
			}
		});
	},
	
	setCloseFunc : function(func) {
		this.overlay.cFunc = func;
	},
	
	close : function() {
		this.overlay.cFunc();
		this.setDropDowns("show");
		var colorPicker = $('colorPickerWrap');
		if(colorPicker != null)	colorPicker.hide();
		this.overlayBox.hide();
		this.overlay.hide();
	}
}
