/************************************************************************************************************ (C) www.dhtmlgoodies.com, November 2005 This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! www.dhtmlgoodies.com Alf Magne Kalleland Updated: April, 3rd, 2006: Fixed problem with initial sliding in IE. ************************************************************************************************************/
var slideSpeed = 10;	// Higher value = faster
var timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var activeId = false;
function showHideContent(e,inputId) {
  if(!inputId)inputId = this.id;
  inputId = inputId + '';
  var numericId = inputId.replace(/[^0-9]/g,'');
  var answerDiv = document.getElementById('a' + numericId);
  
  objectIdToSlideDown = false;
  
  if(!answerDiv.style.display || answerDiv.style.display=='none'){

    if(activeId &&  activeId!=numericId){
      objectIdToSlideDown = numericId;
      slideContent(activeId,(slideSpeed*-1));
    }else{
      
      answerDiv.style.display='block';
      answerDiv.style.visibility = 'visible';
      
      slideContent(numericId,slideSpeed);
    }
  }else{
    slideContent(numericId,(slideSpeed*-1));
    activeId = false;
  }	
}

function slideContent(inputId,direction){
  var obj =document.getElementById('a' + inputId);
  var contentObj = document.getElementById('ac' + inputId);
  height = obj.clientHeight;
  height = height + direction;
  rerunFunction = true;
  if(height>contentObj.offsetHeight){
    height = contentObj.offsetHeight;
    rerunFunction = false;
  }
  if(height<=1){
    height = 1;
    rerunFunction = false;
  }

  obj.style.height = height + 'px';
  var topPos = height - contentObj.offsetHeight;
  if(topPos>0)topPos=0;
  contentObj.style.top = topPos + 'px';
  if(rerunFunction){
    setTimeout('slideContent(' + inputId + ',' + direction + ')',timer);
  }else{
    if(height<=1){
      obj.style.display='none'; 
      if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
        document.getElementById('a' + objectIdToSlideDown).style.display='block';
        document.getElementById('a' + objectIdToSlideDown).style.visibility='visible';
        slideContent(objectIdToSlideDown,slideSpeed);				
      }
    }else{
      activeId = inputId;
    }
  }
}

function initShowHideDivs() {

  var divs = document.getElementsByTagName('DIV');
  var divCounter = 1;
  for(var no=0;no<divs.length;no++){
    if(divs[no].className=='question'){
      divs[no].onclick = showHideContent;
      divs[no].id = 'q'+divCounter;
      
      var answer = divs[no].nextSibling;
      while(answer && answer.tagName!='DIV'){
        answer = answer.nextSibling;
      }
      
      answer.id = 'a'+divCounter;	
      
      contentDiv = answer.getElementsByTagName('DIV')[0];
      contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
      contentDiv.className='answer_content';
      contentDiv.id = 'ac' + divCounter;
      answer.style.display='none';
      answer.style.height='1px';
      divCounter++;
    }		
  }	
}

/*
  $Id: general.js,v 1.3 2003/02/10 22:30:55 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

function roundit(which){
	return Math.round(which*100)/100
} 

function cmconvert(){
	if (document.getElementById) {
		var value=parseFloat(document.getElementById("js_cm").value);
		
		if (isNaN(value)) {
			value=0; 
		}
		
		if (document.getElementById("js_feet")) {
			document.getElementById("js_feet").value = roundit(value / 30.48); 
		}
		
		if (document.getElementById("js_inch")) {
			document.getElementById("js_inch").value = roundit(value / 2.54); 
		}
	}
}

function inchconvert(){
	if (document.getElementById) {
		var value=parseFloat(document.getElementById("js_inch").value);
		
		if (isNaN(value)) {
			value=0; 
		}
		
		if (document.getElementById("js_cm")) {
			document.getElementById("js_cm").value = roundit(value * 2.54); 
		}
		
		if (document.getElementById("js_feet")) {
			document.getElementById("js_feet").value = roundit(value * 12); 
		} 
	} 
}


/*
  $Id: general.js,v 1.3 2003/02/10 22:30:55 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/
function clickAttribute(evt) {
	var additional=true;
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	
	while (obj.nodeName.search(/tr/gi)==-1) {
		obj=obj.parentNode;
	}
	
	var radio_obj = obj.getElementsByTagName("input")[0];
	
	if (radio_obj.disabled) {
		return;
	}
	
	var list=obj.parentNode.getElementsByTagName("tr");
	for (var i=0;i<list.length;i++) {
		if (list[i].className.indexOf("moduleRowSelected")!=-1) {
			if (obj==list[i]) {
				additional=false;
			} else {
				list[i].className=list[i].className.replace(/ ?moduleRowSelected/gi,"");
			}
		}
	}
	
	if (additional) {
		obj.className+=" moduleRowSelected";
		var inputs = obj.getElementsByTagName("input");
		
		if (inputs.length > 0 && inputs[0]) {
			var input = inputs[0];
			
			if (input.type.search(/radio/gi)!=-1) {
				if (input.click) {
					input.click();
				} else {
					input.checked = true;
					if (!window.stkmsg) {
					
					}
				}
				
				
				if (navigator.userAgent.search(/safari/gi)!=-1) {
					var xCoord=window.pageXOffset;
					var yCoord=window.pageYOffset;
					if (window.scrollTo) {
						window.scrollTo(0,0);
						window.scrollTo(xCoord, yCoord);
					}
				}
			}
			
			
		}
	}
}

function rowOverAttribute(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/tr/gi)==-1) {
		obj=obj.parentNode;
	}
	
	var radio_obj = obj.getElementsByTagName("input")[0];
	
	if (obj.getElementsByTagName("input")[0].disabled) {
		return;
	}
	
	if (obj.className.indexOf("moduleRowSelected")==-1) {
		obj.className=obj.className+" moduleRowOver";
	}
	if (obj.getElementsByTagName && obj.getElementsByTagName("td")[2].getElementsByTagName("img").length>0) {
		obj.getElementsByTagName("td")[2].getElementsByTagName("img")[0].style.display="";
	}
}

function rowOverAttributeSet(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/tr/gi)==-1) {
		obj=obj.parentNode;
	}
	
	var radio_obj = obj.getElementsByTagName("input")[0];
	
	if (document.getElementById && document.getElementById('fabric_large_image') && attribute_set_large_image[radio_obj.value]) {
		document.getElementById('fabric_large_image').src = attribute_set_large_image[radio_obj.value].src;
		document.getElementById('fabric_large_image').width = attribute_set_large_image[radio_obj.value].width;
		document.getElementById('fabric_large_image').height = attribute_set_large_image[radio_obj.value].height;
		document.getElementById('fabric_large_image').style.display = ""; 
	}
	
	
}



function rowOutAttribute(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/tr/gi)==-1) {
		obj=obj.parentNode;
	}
	
	if (obj.className.indexOf("moduleRowOver")!=-1) {
		obj.className=obj.className.replace(/ ?moduleRowOver/gi,"");
	}
if (obj.getElementsByTagName && obj.getElementsByTagName("td")[2].getElementsByTagName("img").length>0) {
		obj.getElementsByTagName("td")[2].getElementsByTagName("img")[0].style.display="none";
	}
	
	
	if (document.getElementById && document.getElementById('fabric_large_image') ) {
		document.getElementById('fabric_large_image').style.display = "none"; 
	}
}

function rowOverCart(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/tr/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.className.indexOf("moduleRowSelected")==-1) {
		obj.className=obj.className+" moduleRowOverCart";
	}
	if (obj.getElementsByTagName && obj.getElementsByTagName("td")[2].getElementsByTagName("img").length>0) {
		obj.getElementsByTagName("td")[2].getElementsByTagName("img")[0].style.display="";
	}
}



function rowOutCart(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/tr/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.className.indexOf("moduleRowOverCart")!=-1) {
		obj.className=obj.className.replace(/ ?moduleRowOverCart/gi,"");
	}
if (obj.getElementsByTagName && obj.getElementsByTagName("td")[2].getElementsByTagName("img").length>0) {
		obj.getElementsByTagName("td")[2].getElementsByTagName("img")[0].style.display="none";
	}
}

function SetFocus(TargetFormName) {
	return;
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target = i;
        break;
      }
    }
  }

  var TargetForm = document.forms[target];
    
  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") && (TargetForm.elements[i].type != "hidden") && (TargetForm.elements[i].type != "reset") && (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();

      if ( (TargetForm.elements[i].type == "text") || (TargetForm.elements[i].type == "password") ) {
        TargetForm.elements[i].select();
      }

      break;
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString) {
    TargetElement.value = "";
  }

  TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value)) {
    return true;
  } else {
    return false;
  }
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}

function product_reviews_popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function product_reviews_write_popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function product_reviews_info_popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function product_info_popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function popup_image_resize() {
  var i=0;
  if (navigator.appName == 'Netscape') {
  	i=40;
  }
  if (document.images[0]){
  	window.resizeTo(document.images[0].width +30, document.images[0].height+60-i);
  } 
  self.focus();
}

function advanced_search_popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150')
}

function rowOverEffect(object) {
  if (object.className == 'moduleRow'){
  	object.className = 'moduleRowOver';
  }
   
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver'){
  	object.className = 'moduleRow';
	}
}

function account_newsletter_checkBox(object) {
  document.account_newsletter.elements[object].checked = !document.account_newsletter.elements[object].checked;
}

function account_notifications_checkBox(object) {
  document.account_notifications.elements[object].checked = !document.account_notifications.elements[object].checked;
}

var checkout_payment_selected;

function checkout_payment_selectRowEffect(object, buttonSelect) {
  if (!checkout_payment_selected) {
    if (document.getElementById) {
      checkout_payment_selected = document.getElementById('defaultSelected');
    } else {
      checkout_payment_selected = document.all['defaultSelected'];
    }
  }

  if (checkout_payment_selected){
  	checkout_payment_selected.className = 'moduleRow';
  } 
  object.className = 'moduleRowSelected';
  checkout_payment_selected = object;

	//one button is not an array
  if (document.checkout_payment.payment[0]) {
    document.checkout_payment.payment[buttonSelect].checked=true;
  } else {
    document.checkout_payment.payment.checked=true;
  }
}

var checkout_address_selected;

function checkout_address_selectRowEffect(object, buttonSelect) {
  if (!checkout_address_selected) {
    if (document.getElementById) {
      checkout_address_selected = document.getElementById('defaultSelected');
    } else {
      checkout_address_selected = document.all['defaultSelected'];
    }
  }

  if (checkout_address_selected){
  	checkout_address_selected.className = 'moduleRow';
	}
  object.className = 'moduleRowSelected';
  checkout_address_selected = object;

// one button is not an array
  if (document.checkout_address.address[0]) {
    document.checkout_address.address[buttonSelect].checked=true;
  } else {
    document.checkout_address.address.checked=true;
  }
}


function check_form_optional(form_name) {
  var form = form_name;

  var firstname = form.elements['firstname'].value;
  var lastname = form.elements['lastname'].value;
  var street_address = form.elements['street_address'].value;

  if (firstname == '' && lastname == '' && street_address == '') {
    return true;
  } else {
    return check_form(form_name);
  }
}


var checkout_shipping_selected;

function checkout_shipping_selectRowEffect(object, buttonSelect) {
  if (!checkout_shipping_selected) {
    if (document.getElementById) {
      checkout_shipping_selected = document.getElementById('defaultSelected');
    } else {
      checkout_shipping_selected = document.all['defaultSelected'];
    }
  }

  if (checkout_shipping_selected){
		checkout_shipping_selected.className = 'moduleRow';
	}
  object.className = 'moduleRowSelected';
  checkout_shipping_selected = object;

// one button is not an array
  if (document.checkout_address.shipping[0]) {
    document.checkout_address.shipping[buttonSelect].checked=true;
  } else {
    document.checkout_address.shipping.checked=true;
  }
}

function RowOverBGC(obj,color){
  obj.style.backgroundColor=color ;
}

function cancelBubble(e){
	if (!e) var e = window.event;
	if (e.stopPropagation){
		e.stopPropagation();
	} else {
		e.cancelBubble=true;
	}
}

function gotoURL(URL){
	document.location.href=URL;
}

function ShowLink(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/^(table|a|td)$/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.nodeName.search(/^(td)$/gi)!=-1) {
		anchors=obj.getElementsByTagName("a");
		if (anchors.length>0) {
			window.status=(anchors[0].href);
		}
	}
}

function HideLink(evt) {
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	window.status="";
}

function ClickLink(evt){
	if (!evt) var evt = window.event;
	//cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/^(table|a|td)$/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.nodeName.search(/^(td)$/gi)!=-1) {
		anchors=obj.getElementsByTagName("a");
		if (anchors.length>0) {
			gotoURL(anchors[0].href);
		}
	}
	
}

function RowOverHeaderNavigation(evt){
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/^(table|td)$/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.nodeName.search(/^(td)$/gi)!=-1 && obj.onmouseover==null) {
		RowOverBGC(obj,'#ff9806');
		ShowLink(evt);
	}
}

function RowOutHeaderNavigation(evt){
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/^(table|td)$/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.nodeName.search(/^(td)$/gi)!=-1 && obj.onmouseout==null) {
		RowOverBGC(obj,'');
		HideLink(evt);
	}
}

function RowOverColumnLeftNavigation(evt){
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/^(table|td)$/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.nodeName.search(/^(td)$/gi)!=-1) {
		anchors=obj.getElementsByTagName("a");
		if (anchors.length>0) {
			ShowLink(evt);
			if (typeof(anchors[0].className)=="undefined" || anchors[0].className==""){
				anchors[0].className="mouseOver";
			} else if (anchors[0].className.search(/^mouseOver$/gi)==-1) {
				anchors[0].className+=" mouseOver";
			}
			
			
		}
	} else {
	}
}

function RowOutColumnLeftNavigation(evt){
	if (!evt) var evt = window.event;
	cancelBubble(evt);
	var obj=evt.srcElement || evt.target;
	while (obj.nodeName.search(/^(table|td)$/gi)==-1) {
		obj=obj.parentNode;
	}
	if (obj.nodeName.search(/^(td)$/gi)!=-1) {
		anchors=obj.getElementsByTagName("a");
		if (anchors.length>0) {
			HideLink(evt);
			if (typeof(anchors[0].className)!="undefined" && anchors[0].className!="" && anchors[0].className.search(/^mouseOver$/gi)!=-1) {
				anchors[0].className=anchors[0].className.substring(0, anchors[0].className.indexOf("mouseOver"));
			}
		}
	} 
}


// Copyright 2006 | Thierry Koblentz - www.TJKDesign.com All Rights reserved
// TJK_ToggleDL() Version 1.5.4 report bugs or errors to thierry@tjkdesign.com
		
function TJK_ToggleDLopen(){//we open all of them
  var zDT=document.getElementsByTagName('dt');
  for(var i=0;i<zDT.length;i++){
    var parent=zDT[i].parentNode;
    if (parent.nodeName.search(/^dl$/gi)!=-1) {
    	nextObj=zDT[i].nextSibling;
    	nextObj.className="showDD";
 			zDT[i].className="DTminus";
    }
  }
  return false;
}

function TJK_ToggleDLclose(){//we close all of them	
  var zDT=document.getElementsByTagName('dt');
  for(var i=0;i<zDT.length;i++){
    var parent=zDT[i].parentNode;
    if (parent.nodeName.search(/^dl$/gi)!=-1) {
    	nextObj=zDT[i].nextSibling;
    	nextObj.className="hideDD";
 			zDT[i].className="DTplus";
    }
  }
  return false;
}

function TJK_Toggle(obj){
	nextObj=obj.nextSibling;
 	if (typeof(obj.className)!="undefined" && obj.className=="DTplus") {
 		nextObj.className="showDD";
 		obj.className="DTminus";
 	} else {
 		nextObj.className="hideDD";
 		obj.className="DTplus";
 	}
}

function TJK_clickChild(obj){
  while (obj.nodeName.search(/^(dt|body)$/gi)==-1){
    obj=obj.parentNode;
  }
  if (obj.nodeName.search(/^dt$/gi)!=-1) {
  	TJK_Toggle(obj);
  }
}

function getEditorValue(form, instanceName ) {  
  var return_value="";
  if (typeof(FCKeditorAPI)=="undefined") {
  		var textarea=form.elements[instanceName];
	  	if (textarea) {
	  		return_value=textarea.value;
	  	}
  	} else {
  		// Get the editor instance that we want to interact with.
		  var oEditor = FCKeditorAPI.GetInstance(instanceName  ) ;
		  // Get the editor contents as XHTML.
		  return_value= oEditor.GetXHTML( false ) ;  // "true" means you want it formatted.
  	}
  	return return_value;
}  

function setEditorFocus(evt){
	if (!evt) {
		evt=window.event;
	}
	var obj=evt.srcElement || evt.target;
	alert(obj.nodeName);
}

function ResizeAnimator() {
	var doc = defaultDocumentHelper;
	var imgBuffer = doc.create('img');
	var imgArea = doc.create('img');
	var displayArea = doc.create('div');
	var operatorTable = doc.create('table');
	var controlTable = doc.create('table');
	var container = null;
	var toWidth = 0;
	var toHeight = 0;
	var resizeWidth = 2;
	var resizeHeight = 2;
	var resizeTimeSpan = 1000;
	var left = 0;
	var top = 0;
	var type = 0;
	var finalLeft = 0;
	var finalTop = 0;
	var currentWidth = 0;
	var currentHeight = 0;
	var imgSizes = new Array();
	var aniStarted = false;
	var moveEnabled = false;
	var defaultIndex = 0;
	var currentIndex = 0;
	var toIndex = 0;
	var oX = 0;
	var oY = 0;
	var X = 0;
	var Y = 0;
	
	imgBuffer.style.display = 'none';
	displayArea.style.border = '1px solid #000000';
	displayArea.style.overflow = 'hidden';
	operatorTable.style.fontSize = '12px';
	operatorTable.style.textAlign = 'center';
	controlTable.style.fontSize = '12px';
	controlTable.style.fontSize = '12px';
	imgArea.style.cursor = 'pointer';
	imgArea.style.position = 'relative';
	imgArea.style.left = left;
	imgArea.style.top = top;
	imgArea.title = imgArea.alt = 'Click on the image to move.';
	
	imgArea.onclick = toggleMoveState;
	displayArea.onmouseout = unregisterMoveState;
	setDisplaySize(350, 350);
	
	this.setTimeSpan = setTimeSpan;
	this.setContainer = setContainer;
	this.setDefaultImage = setDefaultImage;
	this.setDisplaySize = setDisplaySize;
	this.setImgAreaSize = setImgAreaSize;
	this.setBothSize = setBothSize;
	this.addSize = addSize;
	this.clearSizes = clearSizes;
	this.refreshControlTable = refreshControlTable;
	this.constructLayout = constructLayout;
	this.moveImage = moveImage;
	this.resizeToIndex = resizeToIndex;
	this.getDefaultIndex = getDefaultIndex;
	this.getCurrentIndex = getCurrentIndex;
	this.reset = reset;
	
	function getDefaultIndex() {
		return defaultIndex;
	}
	
	function clearSizes() {
		imgSizes = new Array();
	}
	
	function setDisplaySize(w, h) {
		displayArea.style.width = w + 'px';
		displayArea.style.height = h + 'px';
	}
	
	function getCurrentIndex() {
		return currentIndex;
	}
	
	function setImgAreaSize(w, h) {
		imgArea.style.width = w + 'px';
		imgArea.style.height = h + 'px';
	}
	
	function setBothSize(w, h) {
		setDisplaySize(w, h);
		setImgAreaSize(w, h);
	}
	
	function setDefaultImage(i) {
		if (i < 0 || i > imgSizes.length) {
			i = 0;
		}
		var s = imgSizes[i];
		imgArea.src = s.source;
		currentWidth = s.width;
		currentHeight = s.height;
		defaultIndex = i;
		if (currentIndex != defaultIndex && !aniStarted) {
			resizeToIndex(defaultIndex);
		}
	}
	
	function reset() {
		if (currentIndex >= imgSizes.length) {
			currentIndex = imgSizes.length - 1;
		}
		var s = imgSizes[currentIndex];
		imgArea.src = s.source;
		currentWidth = s.width;
		currentHeight = s.height;
		if (!aniStarted) {
			resizeToIndex(currentIndex);
		}
		moveImage(0,0);
	}
	
	function toggleMoveState(evt) {
		if (moveEnabled) {
			unregisterMoveState(evt);
		} else {
			registerMoveState(evt);
		}
	}
	
	function registerMoveState(evt) {
		moveEnabled = true;
		imgArea.style.cursor = 'move';
		addObjectEvent(displayArea, 'mousemove', dragImage);
		recordLocation(evt);
	}
	
	function unregisterMoveState(evt) {
		moveEnabled = false;
		imgArea.style.cursor = 'pointer';
		removeObjectEvent(displayArea, 'mousemove', dragImage);
	}
	
	function recordLocation(evt) {
		var e = (window.event)? window.event: evt;
		oX = e.screenX;
		oY = e.screenY;
		X = left;
		Y = top;
	}
	
	function dragImage(evt) {
		if (moveEnabled) {
			var e = (window.event)? window.event : evt;
			var x = e.screenX;
			var y = e.screenY;
			moveImage(x - (oX - X), y - (oY -Y));
		}
	}
	
	function moveImage(x, y) {
		left = x;
		top = y;
		imgArea.style.left = left + 'px';
		imgArea.style.top = top + 'px';
	}
	
	function setContainer(c) {
		container = c;
	}
	
	function constructLayout() {
		clearTable(operatorTable);
		clearTable(controlTable);
		var r = operatorTable.insertRow(0);
		var c = r.insertCell(0);
		c.appendChild(displayArea);
		displayArea.appendChild(imgArea);
		c = r.insertCell(1);
		c.appendChild(controlTable);
		for (var i = 0; i < imgSizes.length; i++) {
			addControlButton(controlTable.insertRow(i).insertCell(0), imgSizes[i], i);
		}
		addResizeTable();
	}
	
	function refreshControlTable() {
		clearTable(controlTable);
		for (var i = 0; i < imgSizes.length; i++) {
			addControlButton(controlTable.insertRow(i).insertCell(0), imgSizes[i], i);
		}
		addShowImageButton(controlTable.insertRow(i).insertCell(0));
	}
	
	function addShowImageButton(c) {
		c.appendChild(doc.createText('Img'));
		c.alt = c.title = 'View full image';
		c.style.cursor = 'pointer';
		c.style.border = '1px solid #BF7235';
		c.style.backgroundColor = '#FFFFFF';
		c.style.color = '#BF7235';
		c.onclick = showImage;
		c.style.width = '15px';
		c.style.height = '15px';
		c.style.textAlign = 'center';
		c.onmouseover = hightButton;
		c.onmouseout = unhightButton;
	}
	
	function showImage() {
		var newWin = window.open();
		var newDoc = newWin.document;
		newDoc.writeln('<img src='+imgArea.src+' width=\''+currentWidth+'\' height=\''+currentHeight+'\'>');
		newDoc.close();
	}
	
	function addControlButton(c, s, i) {
		c.appendChild(doc.createText(s.name));
		c.index = i;
		c.source = s.source;
		c.onclick = startResize;
		setButtonStyle(c);
	}
	
	function hightButton(evt) {
		var t = getEventTarget(evt);
		t.style.backgroundColor = '#FFF153';
	}
	
	function unhightButton(evt) {
		var t = getEventTarget(evt);
		t.style.backgroundColor = '';
	}
	
	function setButtonStyle(c) {
		c.style.cursor = 'pointer';
		c.style.border = '1px solid #BF7235';
		c.style.backgroundColor = '#FFFFFF';
		c.style.color = '#BF7235';
		c.onclick = startResize;
		c.style.width = '15px';
		c.style.height = '15px';
		c.style.textAlign = 'center';
		c.onmouseover = hightButton;
		c.onmouseout = unhightButton;
	}
	
	function addResizeTable() {
		if (container != null) {
			container.appendChild(operatorTable);
		}
	}
	
	function removeResizeOperator() {
		if (container != null) {
			container.remvoeChild(operatorTable);
			container = null;
		}
	}
	
	function clearTable(t) {
		while (t.rows.length > 0) {
			t.deleteRow(0);
		}
	}
	
	function setTimeSpan(t) {
		resizeTimeSpan = t;
	}
	
	function addSize(n, w, h, s) {
		imgSizes.push(new Size(n, w, h, s));
	}
	
	function startResize(evt) {
		var t = getEventTarget(evt);
		resizeToIndex(t.index);
	}
	
	function resizeToIndex(i) {
		if (i >= 0 && i < imgSizes.length && !aniStarted) {
			toWidth = imgSizes[i].width;
			toHeight = imgSizes[i].height;
			imgBuffer.src = imgSizes[i].source;
			var count = resizeTimeSpan / 50;
			imgArea.style.width = currentWidth;
			imgArea.style.height = currentHeight;
			resizeWidth = (toWidth - currentWidth) / count;
			resizeHeight = (toHeight - currentHeight) / count;
			finalLeft = parseInt(imgArea.style.left) + ((currentWidth - toWidth) / 2);
			finalTop = parseInt(imgArea.style.top) + ((currentHeight - toHeight) / 2);
			toIndex = i;
			resizeAni();
		}
	}
	
	function resizeAni() {
		aniStarted = true;
		var w = parseInt(imgArea.style.width) + resizeWidth;
		var h = parseInt(imgArea.style.height) + resizeHeight;
		/*
		var l = parseInt(imgArea.style.left) - (resizeWidth / 2);
		var t = parseInt(imgArea.style.top) - (resizeHeight / 2);
		*/
		setBothSize(w, h);
		moveImage(0, 0);
		if ((currentWidth < toWidth && (w < toWidth || h < toHeight)) ||
			(currentWidth > toWidth && (w > toWidth || h > toHeight))) {
			setTimeout(resizeAni, 50);
		} else {
			finalize();
		}
	}
	
	function finalize() {
		aniStarted = false;
		setBothSize(toWidth, toHeight);
		currentWidth = toWidth;
		currentHeight = toHeight;
		imgArea.src = imgBuffer.src;
		currentIndex = toIndex;
		moveImage(0, 0);
	}
}

function Size(n, w, h, s) {
	this.name = n;
	this.width = parseInt(w);
	this.height = parseInt(h);
	this.source = s;
}

/**
 * GBMadAJAX V1.0 2006-12-20 01:25:09 By 罕疯(http://www.gbmad.net/)
 * 本代码采用“知识共享署名 2.5 中国大陆许可协议(http://creativecommons.org/licenses/by/2.5/cn/)”进行许可。
 * 简单说下吧，就是：你可以任何方式使用这些代码。但是必须保留这段署名及注释。尊重他人就是尊重自己。
 * 
 * 永久地址：http://www.gbmad.net/blog/article.asp?id=1
 * 
 * 推荐在UTF-8的页面中使用，返回的数据可以直接使用，无需再转换编码。
 * 例子：
	var xml;
	xml = new GBMadAJAX();
	function Completed() {
		document.getElementById("xmlstate").innerHTML = bb.rbody;
	}
	function AJAX() {
		//bb.method = "POST";
		bb.url = "index.asp";
		//this.async = false;
		//bb.to = 500;
		bb.rsid = "xmlstate";
		//this.rbt = 1;
		//bb.Add("name", "admin");
		//bb.Uninitialized = Uninitialized;
		//bb.Loading = Loading;
		//bb.Loaded = Loaded;
		//bb.Interactive = Interactive;
		//bb.Completed = Completed;
		bb.Open();
	}
 */

function GBMadAJAX() {
	var xml;
	var rs;
	var body = new Array();
	var self = this;
	var sending = false;
	var sto;
	if (window.XMLHttpRequest) {
		xml = new XMLHttpRequest();
	} else {
		try {
			xml = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
		}
	}
	this.method = "GET";//提交模式，GET、POST
	this.url = "?";//提交的URL，默认本页，最好指定
	this.async = true;//异步方式，异步时可以监控状态更改
	this.to = 0;//提交超时时间，毫秒，不设置则按xmlhttp组件默认
	this.rsid = "";//默认异步信息显示的html的dom的id
	this.rbt = 0;//返回结果类型，默认Text，1为Body，2为XML，3为Stream
	this.rbody = "";//返回结果
	this.Uninitialized = function() {};//XmlHttpRequest不能初始化时执行的函数
	this.Loading = function() {};//初始化时执行的函数
	this.Loaded = function() {};//请求时执行的函数
	this.Interactive = function() {};//发送数据时执行的函数
	this.Completed = function() {};//完成时执行的函数
	this.Error = function() {};//完成后服务器返回非200状态时执行的函数
	this.Busy = function() {};//上次请求未完成时执行的函数
	this.TimeOut = function() {};//超时后执行的函数
	this.Add = function(key, val) {//添加一个数据，input对应的name和value
		body[body.length] = encodeURIComponent(key) + "=" + encodeURIComponent(val);
	}
	this.Open = function() {//开始请求
		if (this.rsid) {
			rs = document.getElementById(this.rsid);
			this.Uninitialized = function() {
				rs.innerHTML = "Uninitialized...";
				rs.innerHTML += "Your browser don't support for XmlHttpRequest.";
			}
			this.Loading = function() {
				rs.innerHTML = "Loading...";
			}
			this.Loaded = function() {
				rs.innerHTML = "Loaded...";
			}
			this.Interactive = function() {
				rs.innerHTML = "Interactive...";
			}
			this.Completed = function() {
				rs.innerHTML = "Completed...";
				rs.innerHTML = xml.responseText;
			}
			this.Error = function() {
				rs.innerHTML = "Completed...";
				rs.innerHTML += "Status: " + xml.status + " " + xml.statusText;
			}
			this.Busy = function() {
				rs.innerHTML = "Server too busy...Please wait or click the Refresh button.";
			}
			this.TimeOut = function() {
				rs.innerHTML = "Server time out...Please click the Refresh button.";
			}
		}
		if (xml) {
			if (sending) {
				this.Busy();
			} else {
				sending = true;
				this.method = this.method.toUpperCase();
				if (this.url.indexOf("?") > -1) {
					this.url += "&" + Math.random() + "=";
				} else {
					this.url += "?" + Math.random() + "=";
				}
				if (this.method == "GET") {
					this.url += "&" + body.join("&")
				}
				xml.open(this.method, this.url, this.async);
				if (this.async) {
					xml.onreadystatechange = StateChange;
				}
				if (this.to) {
					sto = window.setTimeout(function() {Abort();}, this.to);
				}
				if (this.method == "GET") {
					xml.send("");
				} else {
					xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					xml.send(body.join("&"));
				}
				if (!this.async) {
					Received();
				}
			}
		} else {
			this.Uninitialized();
		}
	}
	function StateChange() {
		switch (xml.readyState) {
			case 0:
				self.Uninitialized();
				break;
			case 1:
				self.Loading();
				break;
			case 2:
				self.Loaded();
				break;
			case 3:
				self.Interactive();
				break;
			case 4:
				Received();
				break;
		}
	}
	function Received() {
		if (sto) {
			window.clearTimeout(sto);
		}
		body = new Array();
		sending = false;
		if (xml.status == 200) {
			switch (self.rbt) {
				case 1:
					self.rbody = xml.responseBody;
					break;
				case 2:
					self.rbody = xml.responseXML;
					break;
				case 3:
					self.rbody = xml.responseStream;
					break;
				default:
					self.rbody = xml.responseText;
					break;
			}
			self.Completed();
		} else {
			self.Error();
		}
	}
	function Abort() {
		if (sending) {
			xml.abort();
			body = new Array();
			sending = false;
			self.TimeOut();
		}
	}
	/*@cc_on @*/
	/*@if (@_jscript_version < 5.5)
	function encodeURIComponent(str) {
		var s = new Array('%00', '%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0A', '%0B', '%0C', '%0D', '%0E', '%0F', '%10', '%11', '%12', '%13', '%14', '%15', '%16', '%17', '%18', '%19', '%1A', '%1B', '%1C', '%1D', '%1E', '%1F', '%20', '!', '%22', '%23', '%24', '%25', '%26', "'", '(', ')', '*', '%2B', '%2C', '-', '.', '%2F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '%3A', '%3B', '%3C', '%3D', '%3E', '%3F', '%40', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '%5B', '%5C', '%5D', '%5E', '_', '%60', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '%7B', '%7C', '%7D', '~', '%7F');
		var r = new Array();
		var l = str.length;
		var i;
		var j = 0;
		var c;
		for (i = 0; i < l; i++) {
			c = str.charCodeAt(i);
			if (c < 128) {
				r[j++] = s[c];
			} else if (c < 2048) {
				r[j++] = "%" + ((c >> 6) + 192).toString(16).toUpperCase();
				r[j++] = "%" + ((c & 63) + 128).toString(16).toUpperCase();
			} else if (c < 65536) {
				r[j++] = "%" + ((c >> 12) + 224).toString(16).toUpperCase();
				r[j++] = "%" + (((c >> 6) & 63) + 128).toString(16).toUpperCase();
				r[j++] = "%" + ((c & 63) + 128).toString(16).toUpperCase();
			} else if (c < 2097152) {
				r[j++] = "%" + ((c >> 18) + 240).toString(16).toUpperCase();
				r[j++] = "%" + (((c >> 12) & 63) + 128).toString(16).toUpperCase();
				r[j++] = "%" + (((c >> 6) & 63) + 128).toString(16).toUpperCase();
				r[j++] = "%" + ((c & 63) + 128).toString(16).toUpperCase();
			}
		}
		return r.join("");
	}
	@end @*/
}
