var MAXIMIZE = jsLang.LBL_DETAILS;
var MINIMIZE = jsLang.LBL_MINIMIZE;
var SELECTED = jsLang.LBL_CHECK;
var NONSELECTED = jsLang.LBL_UN_CHECK;
var ALERT_SELECT_ONE = jsLang.LBL_CHECK_AT_LEAST_ONE;

var maxMinStatusArray = new Array(8);
var selectStatusArray = new Array(8);
window.addEvent('domready', function() {
	try{
		//var thebox = $('box-1');
		
		for(i=1; i<9; i++){
				maxMinStatusArray[i-1] = false;
				$('efxbot-'+i).addEvent('click', function(e) {
					//e.stop();
					var id = (this.id).split("-");
					id = id[1];
					if(!maxMinStatusArray[id-1]){
						$('box-'+id).set('styles', {
							'background' : '#F7F4F4 url(/imgs/fadeGrey.png) repeat-x scroll center bottom'						
						})
						
						// Changes the element's style to .myClass defined in the CSS
						$('box-'+id).morph('.fadeGreyMax');
						$('box-'+id).getElements('p').setStyle('display', 'block');
						$('box-'+id).setStyle('height', 'auto');
						this.innerHTML = MINIMIZE;
						this.set('class', '');
						this.set('class', 'min');
					}else{
						$('box-'+id).morph('.fadeGrey');
						$('box-'+id).getElements('p').setStyle('display', 'none');
						$('box-'+id).getElements('p[id^=primerP]').setStyle('display', 'block');;
						$('box-'+id).setStyle('height', 'auto');
						this.innerHTML = MAXIMIZE;
						this.set('class', '');
						this.set('class', 'max');
					}
					maxMinStatusArray[id-1] = !maxMinStatusArray[id-1];
					return false;
				});
		};
		
		for(y=1; y<9; y++){
			selectStatusArray[y-1] = false;
			$('buyBut-'+y).addEvent('click', function(e) {	  
				var opId = (this.id).split("-");
				opId = opId[1];
				$('op-'+opId).checked = !($('op-'+opId).checked);
				if(selectStatusArray[opId-1]){
					this.innerHTML = SELECTED;
				}else{
					this.innerHTML = NONSELECTED;
				}
				selectStatusArray[opId-1] = !selectStatusArray[opId-1];
				return false;
			});
			$('op-'+y).addEvent('click', function(e) {
				var id=(this.id).split("-");
				id = id[1];
				if(this.checked){
					$('buyBut-'+id).innerHTML = NONSELECTED;
					selectStatusArray[id-1] = true;
				}else{
					$('buyBut-'+id).innerHTML = SELECTED;
					selectStatusArray[id-1] = false;
				}
			});
	 	};
	 
	 	var anchorValue = window.location.toString().split('#')[1];
	 	if ($defined(anchorValue)) {
	 		$('efxbot-'+anchorValue).fireEvent('click');
	 		$('box-'+anchorValue).focus();
		}
		$('contactServicesForm').addEvent('submit', function(e) {
			(new Event(e)).stop();
			if(!checkForm()){
				alert(ALERT_SELECT_ONE);
			}else{
				$('contactServicesForm').submit();
			}
		});
	}catch(e){
		
	}
});

function checkForm(){
	var checkBoxes = $('contactServicesForm').getElements('input[type=checkbox]');
	var i = 0;
	var total = checkBoxes.length;
	var stop = false;
	 
	while (!stop && i<total){
		stop = checkBoxes[i].checked;
		i++;
	}
	if(stop){
		return true;
	}
	return false;
}