function initCstProductDetailPop(containerId) {
		jQuery("#"+containerId+" a").hover(function(){
			jQuery(".ground_a_box",this).addClass('ground_a_box_change');
		},function(){
			jQuery(".ground_a_box",this).removeClass('ground_a_box_change');
			})
}

function cstToggleTopMenu(srcObj, toggleFlag, useImg, outImg, overImg) {
}

function updateQuantity(strObjId, strAction) {
	if ($(strObjId).value == "") {
		$(strObjId).value = 0;
	}
	var intQty = parseInt($(strObjId).value);
	if (isNaN(intQty)) {
		intQty = 1;
	}
	if (strAction == "add") {
		intQty++;
	} else {
		if (intQty > 1) {
			intQty--;
		}
	}

	$(strObjId).value = intQty;
	return false;
}

function f_chk_naturalnumber(numVal) {
	var s = numVal;

	if (/^[0-9]+$/.test(s) && (s > 0))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function f_chk_qtyNumber(numVal) {
	var s = numVal;

	if (/^[0-9]+$/.test(s) && (s > 0))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function openPopupWindow(id) {
	Dialog.alert($(id).innerHTML, {className: "alphacube",  width:"400px", height:"296px", okLabel:"Fermer"});
}


function math_accDiv(arg1,arg2) {
    var t1=0,t2=0,r1,r2;
    try{t1=arg1.toString().split(".")[1].length}catch(e){}
    try{t2=arg2.toString().split(".")[1].length}catch(e){}
    with(Math){
        r1=Number(arg1.toString().replace(".",""))
        r2=Number(arg2.toString().replace(".",""))
        return (r1/r2)*pow(10,t2-t1);
    } 	
}
function math_accMul(arg1,arg2)
{
     var m=0,s1=arg1.toString(),s2=arg2.toString();
     try{m+=s1.split(".")[1].length}catch(e){}
     try{m+=s2.split(".")[1].length}catch(e){}
     return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
function math_accAdd(arg1,arg2){
    var r1,r2,m;
    try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
    try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
    m=Math.pow(10,Math.max(r1,r2))
    return (arg1*m+arg2*m)/m
} 
function math_accSub(arg1,arg2){      
    return accAdd(arg1,-arg2);  
}   


if(typeof Bysoft=='undefined') {
    var Bysoft = {};
}


Bysoft.effects = Class.create({
    initialize: function(){
    	this.pageDimensions = {
		width : null,
		height : null
		};
		this.dimensions = {
			viewport : {
				height : null,
				width : null,
				scrollTop : null,
				scrollLeft : null
			}
		};
		
		this.brand = 'Bysoft';
		this._getPageDimensions();
		this._setBrowserDimensions();
	},
	
	_addLoadingOverlay: function() {
		var overlay = Element.extend(document.createElement('div'));
		overlay.setAttribute('id', 'cst-loading-full-box');	
		var loadingContent = Builder.node('span', {'id':'cst-loading-content', 'class':'cst-please-wait', 'style':'z-index:999'}, Translator.translate('Loading...'));
		//overlay.appendChild(loadingContent);
		
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(loadingContent);
		body.appendChild(overlay);	
	},
	
	_addFullOverlay:function() {
		var overlay = Element.extend(document.createElement('div'));
		overlay.setAttribute('id', 'cst-overlay-full-box');	
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(overlay);

	},
	
	showLoadingOverlay: function() {
		if (! $('cst-loading-full-box')) {
			this._addLoadingOverlay();
		}
		this._setBrowserDimensions();
		
		var overlay = $('cst-loading-full-box');
		overlay.setStyle({
			height: this.pageDimensions.height+'px',
			display: "block"
		});
		
		$('cst-loading-content').setStyle({
			top: (Math.round(this.dimensions.viewport.height/2) + this.dimensions.viewport.scrollTop - 20) + 'px',
			position: 'absolute',
			display: "block"			
		});
	},
	
	hideLoadingOverlay: function() {
		if (! $('cst-loading-full-box')) {
			this._addLoadingOverlay();
		}
		
		var overlay = $('cst-loading-full-box');
		overlay.setStyle({
			display: "none"
		});
		$('cst-loading-content').setStyle({
			display: "none"			
		});
	},

	popInCenter: function(popEl) {
		if (! $('cst-overlay-full-box')) {
			this._addFullOverlay();
		}
		this._setBrowserDimensions();
		
		var overlay = $('cst-overlay-full-box');
		overlay.setStyle({
			height: this.pageDimensions.height+'px',
			display: "block"
		});		
		popEl.setStyle({
			top: (Math.round(this.dimensions.viewport.height/2) + this.dimensions.viewport.scrollTop - 20) + 'px',
			position: 'absolute',
			display: "block"			
		});		
	},
	
	hidePopInCenter: function(popEl) {	
		if (! $('cst-overlay-full-box')) {
			this._addFullOverlay();
		}
		
		var overlay = $('cst-overlay-full-box');
		overlay.setStyle({
			display: "none"
		});
		popEl.setStyle({
			display: "none"			
		});		
	},
	
	_setBrowserDimensions : function() {
		if (Prototype.Browser.IE) {
            this.dimensions.viewport.height = document.documentElement.clientHeight;
            this.dimensions.viewport.width = document.documentElement.clientWidth;   
        } else {
            this.dimensions.viewport.height = window.innerHeight;
            this.dimensions.viewport.width = document.width || document.body.offsetWidth;
        }
        this.dimensions.viewport.scrollTop = window.pageYOffset || document.documentElement.scrollTop ||document.body.scrollTop || 0;
        this.dimensions.viewport.scrollLeft = window.pageXOffset || document.documentElement.scrollLeft ||document.body.scrollLeft || 0;
	},
	
	_getPageDimensions : function() {
		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){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	

		if(yScroll < windowHeight){
			this.pageDimensions.height = windowHeight;
		} else { 
			this.pageDimensions.height = yScroll;
		}

		if(xScroll < windowWidth){	
			this.pageDimensions.width = windowWidth;
		} else {
			this.pageDimensions.width = xScroll;
		}
	}		
});


Bysoft.Price = Class.create();

Bysoft.Price.prototype = {	
    initialize: function(){
		this.brand = 'Bysoft';
	},
	
	/*getProductViewUniquePrice: function(pIdFull) {
		var result = {displayStr:'', num:0};

		if ($('price-including-tax-'+pIdFull)) {
			var priceIncStr = $('price-including-tax-'+pIdFull).innerHTML;
			result['displayStr'] = priceIncStr.stripTags().strip();
		}else if ($('product-price-'+pIdFull)) {
			var priceIncStr = $('product-price-'+pIdFull).innerHTML;
			result['displayStr'] = priceIncStr.stripTags().strip();
		}
		result['num'] = result['displayStr'].scan(/\w+/);
		return result;
	},*/
	
	getProductViewUniquePrice: function(pId) {
		var result = {'num':0, 'display':' '};

		var uPriceNumEls = document.getElementsByName("unique-product-price-num-"+pId);
		if (uPriceNumEls.length > 0) {
			result.num = uPriceNumEls[0].value;
		}
		var uPriceDispEls = document.getElementsByName("unique-product-price-display-"+pId);
		if (uPriceDispEls.length > 0) {
			result.display = uPriceDispEls[0].value;
		}
		
		return result;
	},
	
	getProductViewOldPrice: function(pId) {
		var result = {'num':0};

		var oldPriceNumEls = document.getElementsByName("old-product-price-num-"+pId);
		if (oldPriceNumEls.length > 0) {
			result.num = oldPriceNumEls[0].value;
		}	
		if (result.num == "N") {
			var uPriceNumEls = document.getElementsByName("unique-product-price-num-"+pId);
			if (uPriceNumEls.length > 0) {
				result.num = uPriceNumEls[0].value;
			}else {
				result.num = 0;
			}			
		}
			
		return result;		
	},
	
	setProductViewUniquePrice: function(pId, uniquePriceNum, uniquePriceDisplay, idSuffix) {
		var uPriceNumEls = document.getElementsByName("unique-product-price-num-"+pId);
		if (uPriceNumEls.length <= 0) {
			return false;
		}
		var uPriceNumEl = uPriceNumEls[0];
		uPriceNumEl.value = uniquePriceNum;
		
		var uPriceDispEls = document.getElementsByName("unique-product-price-display-"+pId);
		if (uPriceDispEls.length <= 0) {
			return false;
		}
		var uPriceDispEl = uPriceDispEls[0];
		uPriceDispEl.value = uniquePriceDisplay;

	},
	
	setProductViewOldPrice: function(pId, oldPriceNum) {
		var oldPriceNumEls = document.getElementsByName("old-product-price-num-"+pId);
		if (oldPriceNumEls.length <= 0) {
			return false;
		}
		var oldPriceNumEl = oldPriceNumEls[0];
		oldPriceNumEl.value = oldPriceNum;	
	}
}


/*-----------------------------------------------------------------------------------------------*/

Event.observe(window, 'load', myBysoftInit, false);

//	Set up all 
function myBysoftInit() {
	myBysoftEffects = new Bysoft.effects();
}
