
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 Workforce Development Program (WDP)') {
opt('training.php?type=23','All Oracle Primavera Workforce Development Program (WDP) Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','WDP Primavera P6 Client / Server Training', whatTo);
opt('#','WDP Primavera P6 Web Access Training', whatTo);
opt('#','WDP Primavera Risk Analysis Training', whatTo);
}
if (whatText == 'Oracle University Primavera Training') {
opt('training.php?type=1','All Oracle University Primavera Training Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','Primavera P6 Client / Server Training', whatTo);
opt('#','Primavera P6 Web Access Training', whatTo);
opt('#','Primavera Risk Analysis Training', whatTo);
opt('#','Primavera Contract Management', whatTo);
opt('#','Primavera Contractor Training', whatTo);
}
if (whatText == 'RPCuk Microsoft Project Planning Workshops') {
opt('training.php?type=20','All RPCuk Microsoft Project Planning Workshops Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','RPCuk Microsoft Workshops', whatTo);
}
if (whatText == 'Certified Oracle Training') {
opt('training.php?type=21','All Certified Oracle Training Courses',whatTo);
opt('#','---------------',whatTo);
opt('#','BPM (Business Process Management - Oracle BEA)', whatTo);
opt('#','WebLogic (Oracle BEA)', whatTo);
opt('#','SOA (Service Oriented Architecture - Fusion Middleware)', whatTo);
opt('#','BI (Business Intelligence - OBIEE)', whatTo);
}
}



function showLink3(text) {
	opt('#','Please Choose',whatTo);
        
    if (whatText == 'WDP Primavera P6 Client / Server Training') {
opt('training.php?product=49','All WDP Primavera P6 Client / Server Training Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=179','Project Management in Primavera P6 Release 7', whatTo);
opt('training.php?course=181','Advanced Project Management in Primavera P6 Release 7', whatTo);
opt('training.php?course=180','Administration in Primavera P6 and P6 Web Access Release 7', whatTo);
opt('training.php?course=182','Resource Management in Primavera P6 Release 7', whatTo);
opt('training.php?course=183','Migrating from P3 to Primavera P6', whatTo);
}
if (whatText == 'WDP Primavera P6 Web Access Training') {
opt('training.php?product=50','All WDP Primavera P6 Web Access Training Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=176','Project Management in Primavera P6 Web Access Release 7', whatTo);
opt('training.php?course=177','Resource Management in Primavera P6 Web Access Release 7', whatTo);
opt('training.php?course=178','Portfolio Management in Primavera P6 Web Access Release 7', whatTo);
}
if (whatText == 'WDP Primavera Risk Analysis Training') {
opt('#','No courses currently available', whatTo);
}
if (whatText == 'Primavera P6 Client / Server Training') {
opt('training.php?product=1','All Primavera P6 Client / Server Training 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=46','Administration in Primavera P6 and P6 Web Access', whatTo);
opt('training.php?course=129','Primavera P6 Rel 8, Primavera Risk Analysis Seminar', whatTo);
opt('training.php?course=159','What is New In Primavera P6 Rel 8', whatTo);
opt('training.php?course=161','Managing Projects in Primavera P6 Professional Rel 8.0', whatTo);
opt('training.php?course=162','Managing Resources in Primavera P6 Professional Rel 8.0', whatTo);
}
if (whatText == 'Primavera P6 Web Access Training') {
opt('training.php?product=44','All Primavera P6 Web Access Training Courses', whatTo);
opt('#','---------------', 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=160','Primavera P6 Rel 8.0 Fundamentals', whatTo);
opt('training.php?course=163','Managing Portfolios in Primavera P6 Rel 8.0', whatTo);
}
if (whatText == 'Primavera Risk Analysis Training') {
opt('training.php?product=2','All Primavera Risk Analysis Training Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=62','Managing Risk in Primavera Risk Analysis 8.6', whatTo);
}
if (whatText == 'Primavera Contract Management') {
opt('training.php?product=47','All Primavera Contract Management Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=165','Primavera Contract Manager Release 13', whatTo);
}
if (whatText == 'Primavera Contractor Training') {
opt('training.php?product=4','All Primavera Contractor Training Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=19','Managing Projects in Primavera Contractor', whatTo);
}
if (whatText == 'RPCuk Microsoft Workshops') {
opt('training.php?product=43','All RPCuk Microsoft Workshops Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=49','Project Planning Essentials with Microsoft Office Project Professional 2007', whatTo);
opt('training.php?course=169','Project Planning Essentials with Microsoft Office Project Professional 2010', whatTo);
}
if (whatText == 'BPM (Business Process Management - Oracle BEA)') {
opt('training.php?product=45','All BPM (Business Process Management - Oracle BEA) Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=164','Oracle BPM 11g Modeling', whatTo);
opt('training.php?course=166','Oracle BPM 11g: Implement the Process Model', whatTo);
}
if (whatText == 'WebLogic (Oracle BEA)') {
opt('training.php?product=38','All WebLogic (Oracle BEA) Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=142','Oracle WebLogic Server 11g: Administration Essentials Ed 2', whatTo);
opt('training.php?course=143','Oracle WebLogic Server 11g: Advanced Administration Ed 2', whatTo);
opt('training.php?course=173','Oracle WebLogic Server 11g: Monitor and Tune Performance Ed 2', whatTo);
}
if (whatText == 'SOA (Service Oriented Architecture - Fusion Middleware)') {
opt('training.php?product=39','All SOA (Service Oriented Architecture - Fusion Middleware) Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=144','Oracle SOA Suite 11g: Essential Concepts Ed 1', whatTo);
opt('training.php?course=145','Oracle SOA Suite 11g: Administration Ed 1', whatTo);
opt('training.php?course=167','Oracle Service Bus 11g: System Administration', whatTo);
opt('training.php?course=168','Oracle Service Bus 11g: Design & Integrate Services', whatTo);
opt('training.php?course=146','Oracle SOA Suite 11g: Build Composite Applications Ed 2', whatTo);
}
if (whatText == 'BI (Business Intelligence - OBIEE)') {
opt('training.php?product=46','All BI (Business Intelligence - OBIEE) Courses', whatTo);
opt('#','---------------', whatTo);
opt('training.php?course=147','Oracle BI 11g R1: Build Repositories', whatTo);
opt('training.php?course=149','Oracle BI 11g R1: Create Analyses and Dashboards', 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 Workforce Development Program (WDP)',appendfirst);
opt(false,'Oracle University Primavera Training',appendfirst);
opt(false,'RPCuk Microsoft Project Planning Workshops',appendfirst);
opt(false,'Certified Oracle Training',appendfirst);
reshow1();
reshow2();

});
