
var whatForm, whatTo, whatText, thirdbox;


function reshow1() {
    //define boxes
	whatFrom = document.forms['courseform'].elements['selectbox1'];
    whatTo = document.forms['courseform'].elements['selectbox2'];	
	thirdbox = document.forms['courseform'].elements['selectbox3'];
	
    //sort third box
	thirdbox.disabled=true;//disable 3rd box on change of first always
    thirdbox.options[0].value = "Please Choose";
    thirdbox.options[0].selected = true;
    
    for (var i = whatTo.length;i > 0;i--)
        whatTo.options[0] = null;
	
	//define option selected
    whatText = whatFrom.options[whatFrom.selectedIndex].text;
	
	//If whatText is Please Choose, disable other objects
	if(whatText=="Please Choose" || whatText=="---------------"){
		whatTo.disabled = true;
		
	}else{
		whatTo.disabled = false;
	}

	//renders options in second box
    showLink2();
	
    //whatTo.options[0].selected = true;
    
}


//Second box function
function reshow2() {
    //define boxes
	whatFrom = document.forms['courseform'].elements['selectbox2'];
    whatTo = document.forms['courseform'].elements['selectbox3'];
	
    for (var i = whatTo.length;i > 0;i--)
        whatTo.options[0] = null;
	
	//define option selected
    whatText = whatFrom.options[whatFrom.selectedIndex].text;
    
    
	//If whatText is 'Please Choose', disable other objects
	if(whatText=="Please Choose" || whatText=="---------------" || whatText=="No products currently available"){
		whatTo.disabled = true;
	}else{
		whatTo.disabled = false;
	}

	//renders options in second box
    showLink3();
	
    whatTo.options[0].selected = true;
}



function load(el) {
    //what = document.forms['courseform'].elements['selectbox3'];
    where = el.options[el.selectedIndex].value;
    if(where!='#'){
        window.location.href = where;
    };
    return false;
}


function load2(el,url) {
    where = url + el.options[el.selectedIndex].value;
    if(where!='#'){
        window.location.href = where;
    };
    return false;
}




function showLink2() {
	opt('#','Please Choose',whatTo);//Default 
	
	if (whatText == 'Oracle Primavera') {
opt('training.php?type=1','All Oracle Primavera Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','Primavera P6 Enterprise Project Portfolio Management', whatTo);
opt('#','Primavera Risk Analysis', whatTo);
opt('#','Primavera P3 Project Planner', whatTo);
opt('#','Primavera Contractor', whatTo);
opt('#','Primavera SureTrak', whatTo);
}
if (whatText == 'Microsoft') {
opt('training.php?type=2','All Microsoft Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','Microsoft Office Project Professional 2007', whatTo);
opt('#','Microsoft Office Project Server 2007', whatTo);
}
if (whatText == 'Portfolio and Project Management') {
opt('training.php?type=3','All Portfolio and Project Management Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','Portfolio Management (PfM)', whatTo);
opt('#','Association for Project Management (APM)', whatTo);
opt('#','General Project Management Skills', whatTo);
}
}



function showLink3(text) {
	opt('#','Please Choose',whatTo);
        
    if (whatText == 'Primavera P6 Enterprise Project Portfolio Management') {
opt('training.php?product=1','All Primavera P6 Enterprise Project Portfolio Management Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=8','Project Management in Primavera P6', whatTo);
opt('training.php?course=10','Advanced Project Management in Primavera P6', whatTo);
opt('training.php?course=41','Resource Management in Primavera P6', whatTo);
opt('training.php?course=13','Migrating from P3 to Primavera P6', whatTo);
opt('training.php?course=14','Project Management in Primavera P6 Web Access', whatTo);
opt('training.php?course=21','Resource Management in Primavera P6 Web Access', whatTo);
opt('training.php?course=50','Portfolio Management in Primavera P6 Web Access', whatTo);
opt('training.php?course=27','Primavera P6 System Administration, Configuration and Design', whatTo);
opt('training.php?course=36','Primavera P6 Overview and Reporting', whatTo);
opt('training.php?course=46','Administration in Primavera P6 and P6 Web Access', whatTo);
opt('training.php?course=44','New Features in Primavera P6 Release 7.0', whatTo);
}
if (whatText == 'Primavera Risk Analysis') {
opt('training.php?product=2','All Primavera Risk Analysis Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=62','Project Risk Management in Primavera PertMaster', whatTo);
}
if (whatText == 'Primavera P3 Project Planner') {
opt('training.php?product=3','All Primavera P3 Project Planner Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=4','Planning and Scheduling in Primavera Project Planner (P3)', whatTo);
opt('training.php?course=5','Resource and Cost Analysis in Primavera Project Planner (P3)', whatTo);
opt('training.php?course=6','Managing Project Data in Primavera Project Planner (P3)', whatTo);
}
if (whatText == 'Primavera Contractor') {
opt('training.php?product=4','All Primavera Contractor Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=19','Managing Projects in Primavera Contractor', whatTo);
}
if (whatText == 'Primavera SureTrak') {
opt('training.php?product=5','All Primavera SureTrak Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=7','Introduction to Primavera SureTrak Project Manager', whatTo);
}
if (whatText == 'Microsoft Office Project Professional 2007') {
opt('training.php?product=6','All Microsoft Office Project Professional 2007 Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=49','Microsoft Project 2007', whatTo);
}
if (whatText == 'Microsoft Office Project Server 2007') {
opt('training.php?product=7','All Microsoft Office Project Server 2007 Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=55','Microsoft EPM 2007 Features Overview', whatTo);
opt('training.php?course=52','Microsoft EPM Fundamentals', whatTo);
opt('training.php?course=53','Microsoft EPM Fundamentals for Administrators', whatTo);
}
if (whatText == 'Portfolio Management (PfM)') {
opt('training.php?product=22','All Portfolio Management (PfM) Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=56','Portfolio Management Overview', whatTo);
opt('training.php?course=57','Project/Programme Portfolio Management', whatTo);
opt('training.php?course=58','GREEN IT and Application Portfolio Management', whatTo);
opt('training.php?course=59','Strategic PfM Alignment, Ranking, Selection and Prioritisation', whatTo);
opt('training.php?course=60','PfM Budget and Resource Allocation', whatTo);
opt('training.php?course=61','PfM Benefits Management Planning and Realisation', whatTo);
}
if (whatText == 'Association for Project Management (APM)') {
opt('training.php?product=11','All Association for Project Management (APM) Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=64','Introductory Certificate in Project Management', whatTo);
opt('training.php?course=65','APMP Complete Project Management (Residential)', whatTo);
opt('training.php?course=66','APMP Complete Project Management (Non-Residential)', whatTo);
opt('training.php?course=67','APMP Examination Preparation', whatTo);
opt('training.php?course=68','Practitioner Qualification Examination Preparation', whatTo);
opt('training.php?course=69','Risk Certificate Level 1', whatTo);
opt('training.php?course=70','Risk Certificate Level 2', whatTo);
}
if (whatText == 'General Project Management Skills') {
opt('training.php?product=10','All General Project Management Skills Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=38','Fundamentals of Project Management and Planning', whatTo);
}

}

function opt(href,text,dest,selected) {
	if(selected==""){
    selected = false;
    }
    var optionName = new Option(text, href, false, selected);
    var length = dest.length;
    dest.options[length] = optionName;
}

function iedisplayfix(nou){
    var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;

    if(IE6){
        var selectedboxno = document.forms['courseform'].elements['selectbox'+nou].selectedIndex;
        document.forms['courseform'].elements['selectbox'+nou].options[selectedboxno+1].selected = true;
        //alert("sbox:"+nou+" optsel:"+selectedboxno);
    }
}


$(document).ready(function(){
						   
$("#courseformappend").html("<form action=\"#\" name=\"courseform\" method=\"post\"><label for=\"selectbox1\">Please select training type</label><select name=\"selectbox1\" id=\"selectbox1\" onChange=\"reshow1()\"></select><hr /><label for=\"selectbox2\">Select product</label><select name=\"selectbox2\" id=\"selectbox2\" onChange=\"load(this);reshow2()\" disabled=\"disabled\"><option>Please Choose</option></select><hr /><label for=\"selectbox3\">Select course</label><select name=\"selectbox3\" id=\"selectbox3\" onChange=\"load(this)\" disabled=\"disabled\"><option>Please Choose</option></select><hr /></form>");

var appendfirst = document.forms['courseform'].elements['selectbox1'];


opt(false,'Please Choose',appendfirst);
opt(false,'---------------',appendfirst);
opt(false,'Oracle Primavera',appendfirst);
opt(false,'Microsoft',appendfirst);
opt(false,'Portfolio and Project Management',appendfirst);
reshow1();
reshow2();

});