function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() {
  	var val,p,errors='',args=MM_validateForm.arguments;
	val=MM_findObj("Name");
	if (val.value == "") errors+='- Please include your First Name\n';
	val=MM_findObj("SName");
	if (val.value == "") errors+='- Please include your Last Name\n';
	val=MM_findObj("Email");
	if (val.value == "") errors+='- Please include your E-mail address\n';
	val=MM_findObj("City");
	if (val.value == "") errors+='- Please include your City\n';
	val=MM_findObj("Mob");
	if (val.value == "") errors+='- Please include your Mobile number\n';
	val=MM_findObj("lid");
	if (val.value == "0") errors+='- Please select your Country\n';

	var mylist = document.getElementById("myStat");
	var sstr = mylist.options[mylist.selectedIndex].text;
//	if (sstr=="Contractor" || sstr=="Perm Job Seeker")
//		{ 
//		var mylist = document.getElementById("contitle");
//		if(mylist) {
//			var gstr = mylist.options[mylist.selectedIndex].text;
//			if (gstr=="Other") {
//				val3=MM_findObj("posoth");
//				if (val3.value == "") errors+='- Please select your Position\n';
//				}
//			}
//		else {
//			errors+='- Please include your Status details\n';
//			}
//		}
	if (sstr=="End User / IT Staff")
		{ 
		val=MM_findObj("Organisation");
		if (val.value == "") errors+='- Please include your Organisation\n';
		val=MM_findObj("JobTitle");
		if (val.value == "") errors+='- Please include your Job Title\n';
		}
	if (sstr=="Please select")
		{ 
		errors+='- Please select your Status\n';
		}

	val=MM_findObj("Pass1");
	if (val.value == "") errors+='- Please include a password\n';
	val=MM_findObj("Pass1");
	mval=MM_findObj("Pass2");
	if (val.value != mval.value) errors+='- Passwords do not match, please re-type them.\n';
	if (errors) alert('Not enough info:\n'+errors);
	else document.forms['regf'].submit();
	document.MM_returnValue = (errors == '');
}

function doSpec()
{
	var mylist = document.getElementById("myStat");
	var gstr = mylist.options[mylist.selectedIndex].text;
	var pusher;
	
	var roles = "<option>SAP ABAP Development<option>SAP Basis Administration<option>SAP Business Objects<option>SAP Business Warehouse<option>SAP Cross Applications<option>SAP Customer Relationship Management<option>SAP Financials & Controlling<option>SAP Human Capital Management<option>SAP Industry Solutions<option>SAP Logistics<option>SAP Materials Management<option>SAP Netweaver<option>SAP Plant Maintenance<option>SAP Portals<option>SAP Product Lifecycle Management<option>SAP Production Planning<option>SAP Project Management<option>SAP Project Systems<option>SAP Quality Management<option>SAP Sales & Distribution<option>SAP Supplier Relationship Management<option>SAP Supply Chain Management<option>SAP Support / Dev Management<option>SAP Warehouse Management";
	var jobtitle = "<tr><td>Primary Role:</td><td><select name='jt1' id='jt1'>"+roles+"</select></td></tr><tr><td>Secondary Role:</td><td><select name='jt2' id='jt2'>"+roles+"</select></td></tr>";
	
	if (gstr=="Contractor")
		{
		pusher = "<table style='padding: 20px;'><tr><td>Availability date:</td><td><input type='text' name='availdate' id='availdate'>&nbsp;<A HREF='#' onClick=\"mycal.select(document.forms['regf'].availdate,'myanc','MM/dd/yyyy'); return false;\" title='Select Date'><img src='cal.gif' width='16' height='16' alt='Select Date' border=0 style='margin-top:3px;'></A></td></tr>";
		pusher = pusher+"<tr><td>&nbsp;</td><td><div style='width:365px;color:#999999;padding: 10px; border: 1px solid #cccccc;'>Please enter an accurate availability date as it is the criteria used by our global resourcing teams when looking for suitable SAP Contractors.</div></td></tr>";
		pusher = pusher+"<tr><td>Upload Resume/C.V.</td><td><input type=\"file\" name='userfile'><br><span style=\"color:#999999;\">(Optional, Max size 200Kb, Word or PDF)</span></td></tr>";
		pusher = pusher+jobtitle;
		document.getElementById("gspec").innerHTML=pusher;
		return;
		}
	if (gstr=="Perm Job Seeker")
		{
		pusher = "<table style='padding: 20px;'><tr><td>Upload Resume/C.V.</td><td><input type=\"file\" name='userfile'><br><span style=\"color:#999999;\">(Optional, Max size 200Kb, Word or PDF)</span></td></tr>";
		pusher = pusher+jobtitle;
		document.getElementById("gspec").innerHTML=pusher;
		return;
		}
	if (gstr=="End User / IT Staff")
		{
		document.getElementById("gspec").innerHTML="<table style='padding: 20px;'><tr><td style='width:95px;'>Organisation:</td><td><INPUT type='text' name='Organisation'></td></tr><tr><td>Job Title:</td><td><INPUT type='text' name='JobTitle'></td></tr></table>";
		return;
		}
	document.getElementById("gspec").innerHTML="";
}

function doOther()
{
	var mylist = document.getElementById("contitle");
	var gstr = mylist.options[mylist.selectedIndex].text;
	if (gstr=="Other")
		{ 
		document.getElementById("ospan").innerHTML="<table style='padding: 20px;'><tr><td style='width:95px;'>Please specify:</td><td><input type='text' name='posoth'></td></tr></table>";
		return;
		}
	document.getElementById("ospan").innerHTML="";
}
