var oo=new Array()
var ra=new Array()
var nw=new Array()
var nwP=new Array()
var ii=new Array()
var ro=new Array()
var dPR
var paints;
var trims;

function checkExtInt() {
 var ok = false;
 var myObj;

 if(paints != '') {
  els = paints.split(',');
  for(j=0; j<els.length-1; j++) {
   myObj = document.getElementById('opt-' + els[j]);
   if(myObj.checked == true) ok=true;
  }
  if(!ok) {
   resp = confirm("You must select a Paintwork!  Click Cancel to stop and go back.  If you wish to continue anyway, click OK.");
   if(!resp) return false;
  }
 }

 ok = false;
 if(mytrims != '') {
  els = mytrims.split(',');
  for(j=0; j<els.length-1; j++) {
   myObj = document.getElementById('opt-' + els[j]);
   if(myObj.checked == true) ok = true;
  }
  if(!ok) {
   resp = confirm("You must select a Trim!  Click Cancel to stop and go back.  If you wish to continue anyway, click OK.");
   if(!resp) return false;
  }
 }
 return true;
}

function checkOptions(chOpt) {
 var theObj = document.getElementById('opt-' + chOpt)
 var otherObj;
 //alert('opt-' + chOpt);
 if(theObj.checked) {
  for(i=0; i<oo.length; i++) {
   if(oo[i].indexOf(chOpt) != -1) {
    els = oo[i].split(',');
    for(j=0; j<els.length; j++) {
     if(els[j] != 0 && els[j] != chOpt && els[j] != dPR) {
      otherObj = document.getElementById('opt-' + els[j])
      otherObj.checked = false;
     }
    }
   }
  }
  
  for(i=0; i<ra.length; i++) {
   if(ra[i].indexOf(chOpt) != -1) {
    els = ra[i].split(',');
    if(chOpt == els[0]) {
     for(j=1; j<els.length; j++) {
      if(els[j] != 0 && els[j] != chOpt) {
       otherObj = document.getElementById('opt-' + els[j])
       otherObj.checked = true;
      }
     }
    }
   }
  }

  for(i=0; i<ii.length; i++) {
   if(ii[i].indexOf(chOpt) != -1) {
    els = ii[i].split(',');
    if(chOpt == els[0]) {
     for(j=1; j<els.length; j++) {
      if(els[j] != 0 && els[j] != chOpt) {
       otherObj = document.getElementById('opt-' + els[j])
       otherObj.checked = true;
      }
     }
    }
   }
  }

  for(i=0; i<ro.length; i++) {
   if(ro[i].indexOf(chOpt) != -1) {
    els = ro[i].split(',');
    if(chOpt == els[0]) {
     alert('This option may require you to select at least one other, please refer to the latest brochure');
    }
   }
  }

  //alert('E');
  for(i=0; i<nw.length; i++) {
   //alert(i+'/'+nwP[i]+'/'+nw[i]);
   if(nwP[i] == chOpt) {
    els = nw[i].split(',');
    for(j=0; j<els.length; j++) {
     if(els[j] != 0 && els[j] != chOpt) {
      //alert('opt-' + els[j]);
      otherObj = document.getElementById('opt-' + els[j])
      otherObj.checked = false;
     }
    }
   } else {
    els = nw[i].split(',');
    for(j=0; j<els.length; j++) {
     if(els[j] == chOpt) {
      otherObj = document.getElementById('opt-' + nwP[i])
      otherObj.checked = false;
     }
    }
   }
  }
  
 } else { // Handle Unchecks
  for(i=0; i<ra.length; i++) {
   if(ra[i].indexOf(chOpt) != -1) {
    els = ra[i].split(',');
    for(j=1; j<els.length; j++) {
     if(els[j] == chOpt) {
      otherObj = document.getElementById('opt-' + els[0])
      otherObj.checked = false;
     }
    }
   }
  }
  for(i=0; i<ii.length; i++) {
   if(ii[i].indexOf(chOpt) != -1) {
    els = ii[i].split(',');
    if(chOpt == els[0]) {
     for(j=1; j<els.length; j++) {
      if(els[j] != 0 && els[j] != chOpt) { //MCE - added check on 0
       otherObj = document.getElementById('opt-' + els[j])
       otherObj.checked = false;
      }
     }
    }
   }
  }
 }
}

function openWindow(url) {
	newwindow=window.open(url,'name','height=800,width=800, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

//Try not to use this - nasty NS/IE wars refugee
function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function invisOptions() {
 alert(document.getElementById("mopts").checked);
// var y = new getObj("mOptsDiv");
// var z = new getObj("nextA");
 if(document.getElementById("mopts").checked) {
//  y.style.visibility = 'hidden';
//  z.style.visibility = 'visible';
 } else {
//  y.style.visibility = 'visible';
//  z.style.visibility = 'hidden';
 }
}

function invisInternal() {
 var y = new getObj("intColorDiv");
 var Current = document.JobPost.intcolor.selectedIndex;

 if(document.JobPost.intcolor.options[Current].text != 'Other') {
  y.style.visibility = 'hidden';
  document.JobPost.intColorManual.value = '';
 } else {
  y.style.visibility = 'visible';
 }
}

function invisExternal() {
 var y = new getObj("extColorDiv");
 var Current = document.JobPost.extcolor.selectedIndex;

 if(document.JobPost.extcolor.options[Current].text != 'Other') {
  y.style.visibility = 'hidden';
  document.JobPost.extColorManual.value = '';
 } else {
  y.style.visibility = 'visible';
 }
}
function switchMenu(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function formSubmit()
{
  document.JobPost.submit() 
}


