	//Show hover box text
	function showtext(i){
		// hide others
		for(j=1;j<=20;j++){
			
			document.getElementById('deal_'+j).className = "hide";
		}
	
		document.getElementById('deal_'+i).className = "show";
	}

	//Show hover box
	function showbox(i) {
		for(j=1;j<=20;j++){
			document.getElementById('box'+j).style.display="none";
		}
		document.getElementById('box'+i).style.display="block";
	}
	
	//Hide hoverbox
	function hidebox(i) {
		for(j=1;j<=20;j++){
			document.getElementById('box'+j).style.display="none";
		}
		
	}
		
		//Limit comp entry to 255 characters
		function textCounter( field, countfield, maxlimit ) {
	  if ( field.value.length > maxlimit )
	  {
		field.value = field.value.substring( 0, maxlimit );
		alert( 'Textarea value can only be 255 characters in length.' );
		return false;
	  }
	  else
	  {
		countfield.value = maxlimit - field.value.length;
	  }
	}
	
	//Pre populate checkboxes by clicking icons on homepage
	function checked(n) {
       box = objById('deal-'+n);
       if (box.checked == false) {
          box.checked = true;
       } else {
          box.checked = false;
       }
    } 

		// gets object by id
	function objById(id)
	{
		if (document.getElementById)
			var returnVar = document.getElementById(id);
		else if (document.all)
			var returnVar = document.all[id];
		else if (document.layers)
			var returnVar = document.layers[id];
		return returnVar;
	}


	////Check whether they have entered the competition
	function entryCheck() {

		//Check if any of the checkboxes are checked
		var count = 0;         
          if (document.getElementById('deal-1').checked == true ) {
               count = 1;
          }
          if (document.getElementById('deal-2').checked == true ) {
               count = 1;
          }    
          if (document.getElementById('deal-3').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-4').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-5').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-6').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-7').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-8').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-9').checked == true ) {
               count = 1;
          }
		   if (document.getElementById('deal-10').checked == true ) {
               count = 1;
          } if (document.getElementById('deal-11').checked == true ) {
               count = 1;
          }
          if (count == 0) {
              var response = confirm( "Are you sure you don't want a voucher?" );
			  	if (response == true) {
					//continue on	
				} else {
					   return false;	
				}
                 
          }    
			
			////Check if comp entry box is emtpy
//			entry = document.getElementById('comp_entry').value;
//			if (entry == '') {
//				var response = confirm("Are you sure you don't want to enter the competition?");
//					if (response == true) {
//							//continue on as per normal
//					} else {
//						 return false;
//					}
//			} else {
//				alert("not empty");//this is temporay to make sure it works
//			}
		
	}


	//make brochure dropdown hidden until checkbox is ticked
	function brochureSelect() {
			document.getElementById('brox_select1').disabled = true;	
	}
	
	//shows the brochure select if the checkbox is ticked
	function show() {
		brochure = document.getElementById('request_brox');
			if (brochure.checked == false) {
				document.getElementById('brox_select1').disabled = true;
				document.getElementById('brox_select1').options.selectedIndex = 0;	
			} else {
				document.getElementById('brox_select1').disabled = false;		
			}
	}

	//integrate voucher select with CIS
	function amendVoucherSelected(){
		for(i=1 ;i<=11;i++){
			var voucher = document.getElementById('deal'+i);
			var voucherHidden = document.getElementById('deal'+i+'_hidden');
			if(voucher.checked == 1){
				//assing value to voucher hidden field need to CIS
				voucherHidden.value = voucherHidden.name;
			}else{
				voucherHidden.disabled = true;
			}
		}
	}
	

