/* **** CHECK BOX ************************************** */
function dCheckBox(checkBoxId) {
	
	if (document.getElementById(checkBoxId+'_dCheckBoxEnvelope').className == 'dCheckBox_NotChecked') {
		
		document.getElementById(checkBoxId+'_dCheckBoxEnvelope').className  = 'dCheckBox_Checked';
		document.getElementById(checkBoxId).value = document.getElementById(checkBoxId+'_valueIfChecked').value; 
		
	} else {
		
		document.getElementById(checkBoxId+'_dCheckBoxEnvelope').className  = 'dCheckBox_NotChecked';
		document.getElementById(checkBoxId).value = document.getElementById(checkBoxId+'_valueIfNotChecked').value 
		
	}
	
}

/* **** SELECT BOX ************************************** */
function dSelectBox_openValueSelector  (selectBoxId)            {
	
	var selectBoxWidth  = document.getElementById(selectBoxId+'_dSelectBoxOpener').offsetWidth;
	var selectBoxHeight = document.getElementById(selectBoxId+'_dSelectBoxOpener').offsetHeight;
	
	var openerPosLeft   = document.getElementById(selectBoxId+'_dSelectBoxOpener').offsetLeft;
	var openerPosTop    = document.getElementById(selectBoxId+'_dSelectBoxOpener').offsetTop;
	
	document.getElementById(selectBoxId + '_dSelectBoxOptions').style.left     = openerPosLeft + 'px'; 
	document.getElementById(selectBoxId + '_dSelectBoxOptions').style.top      = openerPosTop  + 'px'; 
	
	document.getElementById(selectBoxId + '_dSelectBoxOptions').style.width   = selectBoxWidth + 'px';
	document.getElementById(selectBoxId + '_dSelectBoxOptions').style.display = 'block';
	
}
function dSelectBox_closeValueSelector (selectBoxId,valueToSet) {
	
	document.getElementById(selectBoxId).value                   = document.getElementById(selectBoxId + '_' + valueToSet + '_id').innerHTML;
	document.getElementById(selectBoxId+'_activeText').innerHTML = document.getElementById(selectBoxId + '_' + valueToSet + '_text').innerHTML ;
	document.getElementById(selectBoxId + '_dSelectBoxOptions').style.display = 'none';
	
}

/* **** PAGE DISABLER ************************************** */
function dPageDisabler_deactivatePage() {
	
	corex.viewportCheckSize();
	
	var bodyWidth  = corex.getElementWidth("body");
	var bodyHeight = corex.getElementHeight("body"); 

	if (bodyWidth>corex.viewportWidth)   width  = bodyWidth;  else width  = corex.viewportWidth;
	if (bodyHeight>corex.viewportHeight) height = bodyHeight; else height = corex.viewportHeight;
	
	document.getElementById('dPageDisabler').style.width  = width  + 'px'; 
	document.getElementById('dPageDisabler').style.height = height + 'px'; 
	
	document.getElementById('dPageDisabler').style.display     = 'block';
    
    $('#dPageDisabler').click(function(e){
        
       e.preventDefault();
       
       var creator = getCreatorContainer('editor');
       if (typeof(creator)!='undefined') {
           //dPageDisabler_activatePage();
           creator.hideProductDetailsExternal();        
       } else {
           dPageDisabler_close(); 
       }
       
    });
	
}
function dPageDisabler_activatePage() {
	
	document.getElementById('dPageDisabler').style.display     = 'none';
	
}
function dPageDisabler_close() {
	
	document.getElementById('dPageDisablerBody').style.display = 'none';
	dPageDisabler_activatePage();
	
}
function dPageDisabler_open() {

	dPageDisabler_deactivatePage();
	
	document.getElementById('dPageDisablerBody').style.display = 'block';
	
	var contentWidth  = parseInt(corex.getElementWidth('dPageDisablerBody'));
	var contentHeight = parseInt(corex.getElementHeight('dPageDisablerBody'));
	
	leftOffset = Math.round((corex.viewportWidth/2) - (contentWidth/2));
	topOffset  = Math.round((corex.viewportHeight/2) - (contentHeight/2));
	
	if (topOffset<0)   topOffset = 0;
	if (leftOffset<0) leftOffset = 0;

	document.getElementById('dPageDisablerBody').style.left    = corex.viewportScrollLeft + leftOffset + 'px';
	document.getElementById('dPageDisablerBody').style.top     = corex.viewportScrollTop  + topOffset  + 'px';
	
}

