/**
 JS-Part for Freie Presse
*/

var ie6=document.getElementById&&document.all&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)	
if(navigator.appVersion.indexOf("MSIE 7.")!=-1 || navigator.appVersion.indexOf("MSIE 8.")!=-1) {
	ie6 = false;
}

dojo.addOnLoad( function() {
	if(ie6) {
	document.cookie = 'test=1'; 
	if( document.cookie.length > 0 ) {
		if( document.cookie.search('alreadyNotified') == "-1" ) {
				window.createIE6Notifier();
				document.cookie = 'alreadyNotified=1';
			}
		}
		document.cookie = 'test=1; expires=Thu, 01-Jan-70 00:00:01 GMT;';
	}
});


/*
	Shimmer (displayed transparent for capturing hover clicks out of a box)
*/
window.destroyShimmer = function() {
	dojo._destroyElement(Shimmer);
	if(dojo.query(".TopMenuLeft")[0]) {
		dojo.style(dojo.query(".TopMenuLeft")[0], "zIndex", 9999);
	}
}

window.createShimmer = function(Toggler) {
	Shimmer=dojo.doc.createElement("div");
	Shimmer.id = 'Shimmer';
	var vp = dijit.getViewport();
	dojo.style(Shimmer, 'display', 'block');
	dojo.style(Shimmer, 'width', vp.w-20 + "px");
	dojo.style(Shimmer, 'height', vp.h-20 + "px");
	dojo.style(Shimmer, 'z-index', '20');
	dojo.style(Shimmer, 'position', 'absolute');
	dojo.style(Shimmer, 'top', '0');
	dojo.style(Shimmer, 'left', '0');
	dojo.body().appendChild(Shimmer);
	dojo.connect(Shimmer, 'onclick', Toggler);
	document.getElementById('Shimmer').innerHTML = '&nbsp;';
}
		


/*
  Functions to show the Header-DropDownList
*/

var SFCatAnchorObj = null;
var SFCatDDListContainerObj = null;

// Box Handler Init
dojo.addOnLoad( initHeaderSearchDDBox );

function initHeaderSearchDDBox() {
	SFCatAnchorObj = dojo.byId("SearchFormCatAnchorID");
	SFCatDDListContainerObj = dojo.byId("SearchFormCatDDListContainerID");
	
	if(SFCatAnchorObj && SFCatDDListContainerObj) {
		// link to events
		dojo.connect(SFCatAnchorObj, "onclick", "toggleHeaderSearchDDList");
	
		// set the default displayed state
		SFCatDDListContainerObj.setAttribute('displayed', 'off');
	}
}

function toggleHeaderSearchDDList(e) {
	var display = SFCatDDListContainerObj.getAttribute('displayed');
	
	if (display == 'on') {
		dojo.style(SFCatDDListContainerObj, "display", "none");
		display = 'off';
		window.destroyShimmer();
	}
	else {
		dojo.style(SFCatDDListContainerObj, "display", "block");
		display = 'on';
		window.createShimmer(toggleHeaderSearchDDList);
	}
	// Remember the toggle state
	SFCatDDListContainerObj.setAttribute('displayed', display);
}

function selectCatFromList(catID, catName) {
	var searchFormObj = dojo.byId('HeaderSearchFormID');
	var SFCatAnchor = dojo.byId('SearchFormCatAnchorID');
	if((catName == null) || (catID == 'non')) {
		catID = '';
	}
	if(searchFormObj != null) {
		if(dojo.byId('hiddenCategoryID') != null) {
			dojo.byId('hiddenCategoryID').value = catID;
		}
		else {
			inputEl = dojo.doc.createElement("input");
			inputEl.type = 'hidden';
			inputEl.id = 'hiddenCategoryID';
			inputEl.value = catID;
			inputEl.name = 'Category';
			searchFormObj.appendChild(inputEl);
		}
	}
	if(SFCatAnchor != null) {
		SFCatAnchor.innerHTML = catName;
	}
	toggleHeaderSearchDDList();
}



/*
  Functions for the Product-Slider
*/

dojo.addOnLoad( initICProductSlider );
dojo.addOnLoad( initICProductSliderAuto );

var ICPSContentWidth = 0;
var ICPSNodeWidth = 0;
var WebServerScriptUrlSSL = '';
var duration = 1000;
var GlobalAutoSlideDelay = 10000;

function ICProductSliderMove(btnLink,direction,NodeWidth,auto,singleCol) {
	var CatID = parseInt(btnLink.getAttribute('ICPSCatID'));
	var ProdID = parseInt(btnLink.getAttribute('ICPSProductID'));
	var CurrentNodeID = parseInt(btnLink.getAttribute('ICPSCurrentNode'));

	//disable btnLinks while scrolling
	if(auto == 0) {
		dojo.byId('ICSliderBtnNextID_'+CatID).setAttribute('ICPSEnabled',0);
		dojo.byId('ICSliderBtnPrevID_'+CatID).setAttribute('ICPSEnabled',0);
	}

	//Scrolling
	var ICPSContentNode = dojo.byId('ICProductSliderContent_'+CatID);

	if(direction == 'next') {

		var NewPosition = (dojo.coords(ICPSContentNode).l - NodeWidth).toString();
	}
	else {
		var NewPosition = (dojo.coords(ICPSContentNode).l + NodeWidth).toString();
	}
	
	//Reset delay if controlled manually
	if(auto == 0) {
		AutoSlideDelay = 0;
	}
	else {
		AutoSlideDelay = GlobalAutoSlideDelay;
	}
	
	dojo.fx.slideTo( {
		node: ICPSContentNode,
		top: (dojo.coords(ICPSContentNode).t).toString(),
		left: NewPosition,
		unit: "px",
		duration: duration,
		delay: AutoSlideDelay,
		onEnd: function() {
			//disable btnLinks while scrolling and auto set to 1
			if(auto == 1) {
				dojo.byId('ICSliderBtnNextID_'+CatID).setAttribute('ICPSEnabled',0);
				dojo.byId('ICSliderBtnPrevID_'+CatID).setAttribute('ICPSEnabled',0);
			}
			//Switch Nodes to get them in the new order
			var FirstSliderNode = dojo.byId('ICPSliderNode_'+CatID+'_'+(CurrentNodeID-1));
			var CurrentSliderNode = dojo.byId('ICPSliderNode_'+CatID+'_'+(CurrentNodeID));
			var LastSliderNode = dojo.byId('ICPSliderNode_'+CatID+'_'+(CurrentNodeID+1));

			if(direction == 'next') {
				dojo.place(FirstSliderNode, ICPSContentNode, "last");
			}
			else {
				dojo.place(LastSliderNode, ICPSContentNode, "first");
			}

			//Add new IDs to get the right ascending node-id-order
			if(direction == 'next') {
				FirstSliderNode.setAttribute('id', 'ICPSliderNode_'+CatID+'_'+(CurrentNodeID+1));
				CurrentSliderNode.setAttribute('id', 'ICPSliderNode_'+CatID+'_'+(CurrentNodeID-1));
				LastSliderNode.setAttribute('id', 'ICPSliderNode_'+CatID+'_'+(CurrentNodeID));
			}
			else {
				FirstSliderNode.setAttribute('id', 'ICPSliderNode_'+CatID+'_'+(CurrentNodeID));
				CurrentSliderNode.setAttribute('id', 'ICPSliderNode_'+CatID+'_'+(CurrentNodeID+1));
				LastSliderNode.setAttribute('id', 'ICPSliderNode_'+CatID+'_'+(CurrentNodeID-1));				
			}
			
			//Current position inside the Cat-Product-Array
			if(direction == 'next') {
				SliderPositions[CatID] = (SliderPositions[CatID]+1)%SliderAssignments[CatID].length;
			}
			else {
				SliderPositions[CatID] = (SliderPositions[CatID]-1)%SliderAssignments[CatID].length;
				if(SliderPositions[CatID] < 0) {
					SliderPositions[CatID] = SliderAssignments[CatID].length-1;
				}
			}
			
			var CurrentPosition = SliderPositions[CatID];
			var NextPosition = 0;
			var PrevPosition = 0;
			
			if((SliderPositions[CatID]+1) > (SliderAssignments[CatID].length-1)) { NextPosition = 0; }
			else { NextPosition = SliderPositions[CatID]+1;	}

			if((SliderPositions[CatID]-1) < 0) { PrevPosition = SliderAssignments[CatID].length-1; }
			else { PrevPosition = SliderPositions[CatID]-1;	}

			//Previous and next product holen
			var NextProdID = SliderAssignments[CatID][NextPosition];
			var PrevProdID = SliderAssignments[CatID][PrevPosition];
			
			//Load next-product
			dojo.xhrGet({
				url: WebServerScriptUrlSSL +'?ViewAction=IC_SF-PSViewProduct&ObjectID='+NextProdID+'&SCol='+singleCol+'&Currency='+GlobalCurrencyID+'&ChangeAction=BlockMonitor',
				load: function (data) {
					//Place the content in the last(right) SliderNode
					if(direction == 'next') {	FirstSliderNode.innerHTML = data;	}
					else { CurrentSliderNode.innerHTML = data; }
					//Load prev-product
					dojo.xhrGet({
						url: WebServerScriptUrlSSL +'?ViewAction=IC_SF-PSViewProduct&ObjectID='+PrevProdID+'&SCol='+singleCol+'&Currency='+GlobalCurrencyID+'&ChangeAction=BlockMonitor',
						load: function (data) {
							//Place the content in the first(left) SliderNode
							if(direction == 'next') {	CurrentSliderNode.innerHTML = data; }
							else { LastSliderNode.innerHTML = data; }
							//enable btnLinks after complete scrolling and product-load
							dojo.byId('ICSliderBtnNextID_'+CatID).setAttribute('ICPSEnabled',1);
							dojo.byId('ICSliderBtnPrevID_'+CatID).setAttribute('ICPSEnabled',1);
						}
					});					
				}
			});
			
			//Center ContentBox again
			dojo.style(ICPSContentNode, 'left' , '-'+NodeWidth.toString()+'px');
			
			if(auto == 1) {
				ICProductSliderMove(btnLink,direction,NodeWidth,1);
			}
		}
	}).play();
}

function ICLoadSliderCSSProperties(CatID,CurrentNodeID) {
	var ICPSContentObj = dojo.byId('ICProductSliderContent_'+CatID);
	var ICPSNodeObj = dojo.byId('ICPSliderNode_'+CatID+'_'+CurrentNodeID);
	if((ICPSContentObj != null) && (ICPSNodeObj != null)) {
		ICPSContentWidth = parseInt(dojo.style(ICPSContentObj,'width'));
		ICPSNodeWidth = parseInt(dojo.style(ICPSNodeObj,'width'));
	}
}

function initICProductSlider() {
	dojo.query('.SliderBtnNext').onclick( function(e) {
		e.preventDefault();
		if (e.target.getAttribute('ICPSEnabled') == '1') {
			//Get CSS from container-objects
			ICLoadSliderCSSProperties(
				parseInt(e.target.getAttribute('ICPSCatID')),
				parseInt(e.target.getAttribute('ICPSCurrentNode'))
			);
			var singleCol = dojo.hasClass(e.target.parentNode,'SingleColumn');
			if (singleCol == true) {
				ICProductSliderMove(e.target,'next',ICPSNodeWidth,0,1);
			}
			else {
				ICProductSliderMove(e.target,'next',ICPSNodeWidth,0,0);
			}
		}
	});
	dojo.query('.SliderBtnPrev').onclick( function(e) {
		e.preventDefault();
		if (e.target.getAttribute('ICPSEnabled') == '1') {
			//Get CSS from container-objects
			ICLoadSliderCSSProperties(
				parseInt(e.target.getAttribute('ICPSCatID')),
				parseInt(e.target.getAttribute('ICPSCurrentNode'))
			);
			var singleCol = dojo.hasClass(e.target.parentNode,'SingleColumn');
			if (singleCol == true) {
				ICProductSliderMove(e.target,'prev',ICPSNodeWidth,0,1);
			}
			else {
				ICProductSliderMove(e.target,'prev',ICPSNodeWidth,0,0);
			}
		}
	});
}

function initICProductSliderAuto() {
	var aSliderObjects = new Array();
	var SliderProps = null;
	
	//Get all slider, defined in MBO
	dojo.query('.ICProductSlider').forEach(	function(elem){
		var aSliderProperties = new Array();
		
		SliderProps = elem.getAttribute('ICPSAutoSlideProps');
		if(SliderProps != null) {
			aSliderProperties = SliderProps.split('_');
		}
		if(aSliderProperties[0] == '1') {
			//get and set properties
			ICLoadSliderCSSProperties(		
				aSliderProperties[1],
				aSliderProperties[2]
			);
		}

		var CatID = aSliderProperties[1];
		var CurrentNodeID = aSliderProperties[2];
		if(CatID != null && CurrentNodeID != null) {
			btnLink = dojo.byId('ICSliderBtnPrevID_'+CatID);
			
			var singleCol = dojo.hasClass(btnLink.parentNode,'SingleColumn');
			if (singleCol == true) {
				ICProductSliderMove(btnLink,'next',ICPSNodeWidth,1,1)
			}
			else {
				ICProductSliderMove(btnLink,'next',ICPSNodeWidth,1,0)
			}
		}
		
		aSliderProperties = null;
	});
}


/*
  Functions for the TicketDetailView
*/

var DisplayedObjID = null;

dojo.addOnLoad( initTicketDetailView );

function toggleTicketDetails(BoxID) {
	var EventRowObj = dojo.byId('ICEventRID_'+BoxID);
	var EventDetailObj = dojo.byId('ICEventHCID_'+BoxID);

	if(DisplayedObjID != null) {
		var DisplayedEventRowObj = dojo.byId('ICEventRID_'+DisplayedObjID);
		var DisplayedEventDetailObj = dojo.byId('ICEventHCID_'+DisplayedObjID);
		
		if((DisplayedEventRowObj != null) && (DisplayedEventDetailObj != null)) {
			dojo.removeClass(DisplayedEventRowObj,'hovered');
			dojo.style(DisplayedEventDetailObj, 'display', 'none');
			if(DisplayedObjID != BoxID) {
				DisplayedEventDetailObj.setAttribute('displayed','0');
			}
		}
	}
	
	if((EventRowObj != null) && (EventDetailObj != null)) {
		if(EventDetailObj.getAttribute('displayed') == 0) {
			dojo.addClass(EventRowObj,'hovered');
			dojo.style(EventDetailObj,'display','block');
			EventDetailObj.setAttribute('displayed','1');
			DisplayedObjID = BoxID;
		}
		else {
			dojo.removeClass(EventRowObj,'hovered');
			dojo.style(EventDetailObj,'display','none');
			EventDetailObj.setAttribute('displayed','0');
		}
	}
}

function initTicketDetailView() {
	var ICTarget;
	dojo.query('.OpenTicketDetail').onclick( function(e) {
		if (e.target) ICTarget = e.target;
		else if (e.srcElement) ICTarget = e.srcElement;

		if (ICTarget.nodeType == 3) // defeat Safari bug
			ICTarget = ICTarget.parentNode;

		if(ICTarget.type == null) // defeat Chrome Bug
			ICTarget = ICTarget.parentNode;

		var BoxID = ICTarget.id.split('_');
		if((BoxID != null) && (BoxID != '')) { BoxID = BoxID[1] }
		toggleTicketDetails(BoxID);
	});

	dojo.query('.CloseTicketDetail').onclick( function(e) {
		if (e.target) ICTarget = e.target;
		else if (e.srcElement) ICTarget = e.srcElement;

		if (ICTarget.nodeType == 3) // defeat Safari bug
			ICTarget = ICTarget.parentNode;

		if(ICTarget.type == null) // defeat Chrome Bug
			ICTarget = ICTarget.parentNode;
			
		var BoxID = e.target.id.split('_');
		if((BoxID != null) && (BoxID != '')) { BoxID = BoxID[1] }
		toggleTicketDetails(BoxID);
	});
	
	/*auto-open, if id is set*/
	if((typeof AutoOpenID != 'undefined') && (AutoOpenID != '')) {
		toggleTicketDetails(AutoOpenID);
	}
}


/*
  Functions for the Promotion Box
*/


var DisplayedPBImgIndex = new Object();
var AutoSlidePromotionBoxStates = new Object();
var PromotionBoxAnimation = new Object();

dojo.addOnLoad( initSwitchPromoBox );

function initSwitchPromoBox() {
	dojo.query('.PromotionBox').forEach( function(elem){
		var IDelements = elem.id.split('_');
		var CatID = IDelements[1];
		DisplayedPBImgIndex[CatID] = 0;
		SliderProps = elem.getAttribute('ICPSAutoSlideProps');
		if(SliderProps != null) {
			AutoSlidePromotionBoxStates[CatID] = SliderProps;
			switchPromoBox(0,CatID,0);
		}
	});
	
	dojo.query('.ICPBBtn').onclick( function(e) {
		e.preventDefault();

		var PBImgID = '';
		if((e.target.id != null) && (e.target.id != '')) {
			PBImgID = e.target.id.split('_');
		}
		else {
			PBImgID = e.target.parentNode.id.split('_');
		}
		
		var PBCatID = PBImgID[1];
		var PBNewImgIndex = PBImgID[2];

		switchPromoBox(parseInt(PBNewImgIndex),PBCatID,1);
	});
}

function switchPromoBox(NewIndex,PBCatID,isClicked) {

	var NewImgObj = dojo.byId('ICPB_'+PBCatID+'_'+NewIndex);
	var CurrentImgObj = dojo.byId('ICPB_'+PBCatID+'_'+DisplayedPBImgIndex[PBCatID]);
	var AutoDelay = GlobalAutoSlideDelay;
	AutoDelay = 5000;
	
	if (isClicked==1) {
		AutoDelay = 0;
		if (PromotionBoxAnimation[PBCatID] != null) {
			PromotionBoxAnimation[PBCatID].stop();
		}
	}
	
	if (NewIndex == DisplayedPBImgIndex[PBCatID]) {
		switchPromoBox((NewIndex+1)%AutoSlidePromotionBoxStates[PBCatID],PBCatID,0);
	} else {
		PromotionBoxAnimation[PBCatID] = dojo.fadeOut({	
			node: CurrentImgObj,
			duration: 200,
			delay: AutoDelay,
			onEnd: function() {
				dojo.style(CurrentImgObj,'top','202px');
				dojo.style(NewImgObj,'top','0');
				
				PromotionBoxAnimation[PBCatID] = dojo.fadeIn({
					node: NewImgObj,
					duration: 200,
		  			onEnd: function() {
		  				DisplayedPBImgIndex[PBCatID] = NewIndex;  	  			
		  				if (AutoSlidePromotionBoxStates[PBCatID] != null && isClicked!=1) {
							switchPromoBox((NewIndex+1)%AutoSlidePromotionBoxStates[PBCatID],PBCatID,0);
		  				}
		  			}
				}).play();
			}
		}).play();	
	}
}



/*
  Functions for the Basket
*/

dojo.addOnLoad( initBasketFunctions );

function initBasketFunctions() {
	dojo.query('.OpenCustomerInfoBtn').onclick( function(e) {
		e.preventDefault();
		toggleCustomerInformation();
	});
	var memberFormBtnObj = dojo.byId('ShowBecomeMemberFormBtnID');
	if(memberFormBtnObj != null) {
		if(memberFormBtnObj.checked == true) {
			toggleBecomeMemberForm(1);
		}
		else {
			disableBecomeMemberForm();
		}
	}
	dojo.query('.ShowBecomeMemberFormBtn').onchange( function(e) {
		toggleBecomeMemberForm(0);
	});
}

function toggleCustomerInformation() {
	CustInfoObj = dojo.byId('BasketBelowTextID');
	Displayed = CustInfoObj.getAttribute('displayed');
	if(Displayed == 0) {
		dojo.style(CustInfoObj,'display','block');
		CustInfoObj.setAttribute('displayed', '1');
	}
	else {
		dojo.style(CustInfoObj,'display','none');
		CustInfoObj.setAttribute('displayed', '0');
	}
}

function toggleBecomeMemberForm(override) {
	BMFObj = dojo.byId('BecomeMemberFormID');
	if(override == 1) {
		dojo.style(BMFObj,'display','block');
		BMFObj.setAttribute('displayed', '1');
		enableBecomeMemberForm();
	}
	else {
		Displayed = BMFObj.getAttribute('displayed');
		if(Displayed == 0) {
			dojo.style(BMFObj,'display','block');
			BMFObj.setAttribute('displayed', '1');
			enableBecomeMemberForm();
		}
		else {
			dojo.style(BMFObj,'display','none');
			BMFObj.setAttribute('displayed', '0');
			disableBecomeMemberForm();
		}
	}
}

function disableBecomeMemberForm() {
	BMFObj = dojo.byId('BecomeMemberFormID');
	dojo.query('input', BMFObj).attr('disabled', 'disabled');
}

function enableBecomeMemberForm() {
	BMFObj = dojo.byId('BecomeMemberFormID');
	dojo.query('input', BMFObj).removeAttr('disabled');
}

/*
  Function to show the product slideshow
*/

function ProductSlideShowSliderMove(CurrentItemNo_SlideShow,ItemListLength_SlideShow) {
  var SliderNode = dojo.byId('ProductSlideShowSlider');
  var NextElementsWidth = 300;
  var NewPosition = (dojo.coords(SliderNode).l - NextElementsWidth).toString();

  dojo.byId('DetailViewLink').href = dojo.byId('DetailViewLink_'+(CurrentItemNo_SlideShow % ItemListLength_SlideShow)).href;
  dojo.byId('DetailViewLink').onclick = dojo.byId('DetailViewLink_'+(CurrentItemNo_SlideShow % ItemListLength_SlideShow)).onclick;

  dojo.fx.slideTo({
		node: SliderNode,
		top: (dojo.coords(SliderNode).t).toString(),
		left: NewPosition,
		unit: 'px',
		duration: 1000,
		delay: 6666,
		onEnd: function() {			
			dojo.place(dojo.byId('ProductSlideShowItem_'+(CurrentItemNo_SlideShow % ItemListLength_SlideShow)), SliderNode, "last");
			dojo.style(SliderNode,'left','0px');
			CurrentItemNo_SlideShow++;
			ProductSlideShowSliderMove(CurrentItemNo_SlideShow,ItemListLength_SlideShow);
		}
  }).play();
}


function initProductSlideShowSliderMove() {
	dojo.addOnLoad( ProductSlideShowSliderMove(CurrentItemNo_SlideShow,ItemListLength_SlideShow) );
}


/*
	function to shift the menu to get it right-aligned
*/

function getAttributes(obj) {
  var pos = { x:0, y:0, h:0, w:0 };

  pos.h = obj.offsetHeight;
  pos.w = obj.offsetWidth;
  
  do {
    pos.x += obj.offsetLeft;
    pos.y += obj.offsetTop;
  } while (obj = obj.offsetParent);

  return pos;
}

function toggleNavSubMenu(callingObject) {
	var SubMenuAttr = null;
	var MainMenuAttr = null;
	var MainMenuBtnAttr = null;
	var MainMenuID = null;
		
	MainMenuObj = dojo.byId('ICMainMenuID');
	MainMenuAttr = getAttributes(MainMenuObj);
	
	MainMenuID = callingObject.id;
	SubMenuObj = dojo.byId('navSubMenuContainerID_'+MainMenuID);
	
	MainMenuBtnAttr = getAttributes(callingObject);
	
	if(SubMenuObj != null) {
		dojo.style(SubMenuObj,'display','block');
		SubMenuAttr = getAttributes(SubMenuObj);
		
		if(SubMenuAttr.w < MainMenuBtnAttr.w) {
			dojo.style(SubMenuObj,'width',MainMenuBtnAttr.w+'px');
		}
		else {
			dojo.style(SubMenuObj,'width',(SubMenuAttr.w-2)+'px');
		}
		
		if((MainMenuAttr.x+MainMenuAttr.w) < (SubMenuAttr.x+SubMenuAttr.w)) {
			var Offset = 0;
			Offset = (MainMenuAttr.x+MainMenuAttr.w)-SubMenuAttr.w;
			dojo.style(SubMenuObj,'left',Offset+'px');
			dojo.addClass(SubMenuObj,'MenuShiftDelta');
		}
	}
}

function hideNavSubMenu(callingObject) {
	var MainMenuID = null;
	MainMenuID = callingObject.id;
	
	SubMenuObj = document.getElementById('navSubMenuContainerID_'+MainMenuID);
	if(SubMenuObj != null) {
		dojo.style(SubMenuObj,'display','none');
	}
}


dojo.addOnLoad( initProductDetailText );

var TextBoxHeight = 0;
var FullTextBoxHeight = 0;

function initProductDetailText() {
	dojo.query('.ReadMore').onclick( function(e) {
		e.preventDefault();
		
		var TextBoxObj = dojo.byId('ProductText');
		var FullTextBoxObj = dojo.byId('ProductTextFull');

		TextBoxHeight = dojo.marginBox(TextBoxObj).h;
		TextBoxObj.style.height = TextBoxHeight+"px";
				
		var sliceText = TextBoxObj.innerHTML;
		var fullText = FullTextBoxObj.innerHTML;
		
		TextBoxObj.innerHTML = fullText;
		FullTextBoxObj.innerHTML = sliceText;
		
		initProductDetailText();
		
		dojo.fx.wipeIn({ node: 'ProductText', duration:800 }).play();
	});
	
	dojo.query('.ReadLess').onclick( function(e) {
		e.preventDefault();
	
		var TextBoxObj = dojo.byId('ProductText');
		var FullTextBoxObj = dojo.byId('ProductTextFull');

		FullTextBoxHeight = dojo.marginBox(TextBoxObj).h;
		TextBoxObj.style.height = FullTextBoxHeight+"px";
		
		var sliceText = TextBoxObj.innerHTML;
		var fullText = FullTextBoxObj.innerHTML;
		
		dojo.animateProperty({
			node: 'ProductText',
			duration:800,
			properties: {
				height: { start: FullTextBoxHeight, end: TextBoxHeight }
			},
			onEnd: function() {
				TextBoxObj.innerHTML = fullText;
				FullTextBoxObj.innerHTML = sliceText;
				initProductDetailText();
			}
		}).play();
	
	});
}

