function sm_jump(objSelect){
if (objSelect.selectedIndex<=0) return false; 
var objOpt = objSelect.options[objSelect.selectedIndex]; 
window.location.href=objOpt.value;
}

function new_window() 
{
// Name the Window, so the remote can target it
self.name = "main"; 

var new_window = "scrollbars,resizable,width=450,height=650,left=0,top=0";
OpenWindow = window.open("RegionSearch.html", "remote", new_window);
}

function paymentdate(frm) {
//var now = new Date();
//var now = now.format('mm/dd/yyyy');
var date = new Date();
var d  = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var now = (month + "/" + day + "/" + year);
//alert (now);
if (frm.PymtConfirmed.checked == true) {
frm.EmailConfirm.value = now;
}
else if (frm.PymtConfirmed.checked == false) {
frm.EmailConfirm.value = "0000-00-00";
}
}

function showhide(id){ 
if (document.getElementById){ 
obj = document.getElementById(id); 
if (obj.style.display == "none"){ 
obj.style.display = ""; 
} else { 
obj.style.display = "none"; 
} 
} 
} 

function showRemote() {
self.name = "main"; // names current window as "main"
var windowprops = "toolbar=0,location=0,directories=0,status=0, " +
"menubar=0,scrollbars=1,resizable=1,width=700,height=550";
OpenWindow = window.open("coursemap.htm", "remote", windowprops); // opens remote control
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function checkCookie()
{
username=getCookie('username');
if (username!=null && username!="")
  {
  alert('Welcome again '+username+'!');
  }
  else 
  {
  username=prompt('Please enter your name:',"");
  if (username!=null && username!="")
    {
    setCookie('username',username,365);
    }
  }
}

function WKSCalculateMT(frm) {

    var order_total1 = 0
    var item_price1 = eval(frm.m_cost.value)
    var item_quantity1 = eval(frm.qty_att.value)
    // Update the order total
             order_total1 += ((item_quantity1 * item_price1)*(1.0))
      // Display the total rounded to two decimal places
    
    frm.TOTAL.value = "$"+round_decimals(order_total1, 2)
}    

function CalculateTotal(frm) {

    /*var date = new Date();
	var curDate = null;
	do { curDate = new Date(); } 
	while(curDate-date < 1000);*/

    var order_total1 = 0
    //if (get_cookie ( "BK_vouchervalue" ) != null) {var voucher = eval(getCookie ( "BK_vouchervalue" ));} else {var voucher = 0;}
   // var voucher = eval(getCookie ( "BK_vouchervalue" ))
    //var voucherdesc = getCookie ( "BK_voucherdesc" )    
    //var voucherpercent = eval((100-(getCookie ( "BK_vouchervaluepercent" )))/100)
    //alert(voucherpercent);
    //var voucherpercent = eval(100-voucherpercent)        
      var voucher = 0
    var voucherdesc = 'voucher'    
    var voucherpercent = eval((100-0)/100)
    //alert(voucherpercent);
    var voucherpercent = eval(100-voucherpercent)  
    var item_price1 = eval(frm.m_cost.value)
    var item_promo = eval(frm.discpromo.value)    
    var item_quantity1 = eval(frm.qty_att.value)
    //var voucher = frm.voucher.value
    //var voucher = 0
    var item_discbs = eval(frm.bussup.value)
    var item_discap = eval(frm.AP.value)
    var item_discstaff = eval(frm.staff.value)    
    //alert(item_discap)    
    //if (item_quantity1 > 2 ) {    
    //var item_discmulti = 0.9;frm.discount.value='More than 3 bookings (10%)';}
    //else {var item_discmulti = 1;}
    //multiple booking discount currently suspended
    var item_discmulti = 1        
    
              // Update the order total
              if (item_discstaff<1) {order_total1 += (item_quantity1 * item_price1)*item_discstaff;frm.discount.value='MYOB Staff (100%)';}
              else if (item_promo == 2958) {order_total1 += ((item_quantity1 * item_price1)-100);frm.discount.value='NZA Promotion Bundle';}
              else if (item_promo == 3958 && item_discbs<1) {order_total1 += ((item_quantity1 * item_price1)*0.7);frm.discount.value='MYOB Accountants Offer & MYOB businesSUPPORT (30%)';}                            
              else if (item_promo == 3958) {order_total1 += ((item_quantity1 * item_price1)*0.8);frm.discount.value='MYOB Accountants Offer (20%)';}                            
              else if (item_discap<1) {order_total1 += ((item_quantity1 * item_price1)*(item_discap)-voucher);frm.discount.value='MYOB Approved Partner (20%)';}
              else if (item_discbs<1) {order_total1 += ((item_quantity1 * item_price1)*(item_discbs)-voucher);frm.discount.value='MYOB businesSUPPORT (10%)';}              
              //else {order_total1 += (((item_quantity1 * item_price1)*(item_discmulti)-voucher)*voucherpercent);frm.discount.value=voucherdesc;}
              else {order_total1 += (item_quantity1 * item_price1)*(item_discmulti);}
      // Display the total rounded to two decimal places
    if (order_total1 < 0) {order_total1 = 0;}
    //alert(voucher)
    frm.TOTAL.value = "$"+round_decimals(order_total1, 2);
    var paypalamt = round_decimals(order_total1, 2);
    
    /*frm.amount.value = string(paypalamt);*/
    frm.amount.value = paypalamt;
    //alert(paypalamt);
}   

function CalculateTotalUpgrade(frm) {

    var order_total1u = 0
    var item_price1u = eval(frm.m_cost.value)
	var item_bussupu = eval(frm.OrderBusSup.value)
	var item_training = eval(frm.trainbundle.value)
	var item_postage = eval(frm.postage.value)	
    //if (frm.cdreqd.value == null) {var item_promou = 0;} else {var item_promou = eval(frm.cdreqd.value);} 
    var item_promou = eval(frm.cdreqd.value)   
 	order_total1u += (item_price1u+item_bussupu+item_promou+item_training+item_postage)*1.125;
              
      // Display the total rounded to two decimal places
    frm.TOTALu.value = "$"+round_decimals(order_total1u, 2)
	    var paypalamt = round_decimals(order_total1u, 2);
    
    /*frm.amount.value = string(paypalamt);*/
    frm.amount.value = paypalamt;
    //alert(paypalamt);
}     

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function workshop() {
workshopid = "<?   echo $strCourseCID;?>"
//alert(workshopid);
if (workshopid == "HOW") { 
alert("Enter your Holidays Act seminar booking reference in the\nVoucher Ref field to attend this workshop for $85")
}
else if (workshopid == "KWW") {
alert("Enter your KiwiSaver seminar booking reference in the\nVoucher Ref field to attend this workshop for $85")
}
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}

function conditionsBD() 
{var new_window = "scrollbars,resizable,width=600,height=550,left=0,top=0";
OpenWindow = window.open("training_conditions_bd.htm", "remote", new_window);
}

function conditions(div) 
{var new_window = "scrollbars,resizable,width=600,height=550,left=0,top=0";
OpenWindow = window.open("training_conditions.htm", "remote", new_window);
}

function PopupCourse(URL) { 
     window.open( "Outlines/"+URL, "",  
     "resizable=1,scrollbars=1,HEIGHT=500,WIDTH=400,left=0,top=0");  
   } 
   
function countatt(frm) {
//alert("boo")
//if (frm.Attendee1.value=="test") {
//frm.qty_att.value = 99 };
if ( (frm.Attendee2.value=='') && (frm.Attendee3.value=='') && (frm.Attendee4.value=='') ){ 
frm.qty_att.value = 1 
} else if ( (frm.Attendee3.value=='') && (frm.Attendee4.value=='') ){
frm.qty_att.value = 2 
} else if (frm.Attendee4.value==''){
frm.qty_att.value = 3 
} else {
frm.qty_att.value = 4 }
}

function detectBrowser(){
var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)
if (browser=="Netscape")  {
alert("Your browser, "+browser+", version "+b_version+": may not record the total to pay correctly. We will correct manually.")
}
}

function randomString() {
	//var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789";
	var string_length = 7;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	document.formbooking.bookingref.value = randomstring;
        document.formbooking.item_number.value = randomstring;
}

function randompword() {
	//var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZ0123456789";
	var string_length = 7;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	document.form1.UserPassword.value = randomstring;
}

function SubmitForm(inquiry)
	{
	if(inquiry.Name.value == "")
		{
		alert("Please enter your name");
		inquiry.Name.focus();
		return false;
		}
	else if(inquiry.Email.value == "")
		{
		alert("Please enter your email address");
		inquiry.Email.focus();
		return false;
		}
	else if(!validEmail(inquiry.Email.value))
		{
		alert ("The email address you have entered has an invalid format");
		inquiry.Email.focus();
		inquiry.Email.select();
		return false;
		}
	else if(inquiry.Message.value == "")
		{
		alert("Please type a message or inquiry");
		inquiry.Message.focus();
		return false;
		}
	else
		{
		return true;
		}
	}

function validEmail(email)
	{
	invalidChars = "/:;,?#!& "
	for (i=0; i<invalidChars.length; i++)
		{
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1)
			{return false
			}
		}
	atPos = email.indexOf("@",1);
	if (atPos <= 0 || atPos == email.length-1)
		{return false
		}
	if (email.indexOf("@",atPos+1) > -1)
		{return false
		}
	periodPos = email.indexOf(".",atPos);
	if (periodPos == -1 || periodPos+3 > email.length)
		{return false
		}
	return true
	}

function get_random()
{
    var ranNum= Math.round(Math.random()*2);
    return ranNum;
}

function Popup(URL) { 
     window.open( URL,"", "HEIGHT=800,WIDTH=800,left=0,top=0,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,status=no,resizable=yes,fullscreen=no");  
   } 

function outlines() 
{self.name = "Parent_Window"; 
var new_window = "scrollbars,resizable,width=800,height=550,left=0,top=0";
OpenWindow = window.open("Outlines.htm", "remote", new_window);
}


function framePrint(){
my_frame.focus();
my_frame.print();
}

/*var floatingMenuId = 'floatdiv';
var floatingMenu =
{
    targetX: -250,
    targetY: 10,

    hasInner: typeof(window.innerWidth) == 'number',
    hasElement: document.documentElement
        && document.documentElement.clientWidth,

    menu:
        document.getElementById
        ? document.getElementById(floatingMenuId)
        : document.all
          ? document.all[floatingMenuId]
          : document.layers[floatingMenuId]
};

floatingMenu.move = function ()
{
    if (document.layers)
    {
        floatingMenu.menu.left = floatingMenu.nextX;
        floatingMenu.menu.top = floatingMenu.nextY;
    }
    else
    {
        floatingMenu.menu.style.left = floatingMenu.nextX + 'px';
        floatingMenu.menu.style.top = floatingMenu.nextY + 'px';
    }
}

floatingMenu.computeShifts = function ()
{
    var de = document.documentElement;

    floatingMenu.shiftX =
        floatingMenu.hasInner
        ? pageXOffset
        : floatingMenu.hasElement
          ? de.scrollLeft
          : document.body.scrollLeft;
    if (floatingMenu.targetX < 0)
    {
        if (floatingMenu.hasElement && floatingMenu.hasInner)
        {
            // Handle Opera 8 problems
            floatingMenu.shiftX +=
                de.clientWidth > window.innerWidth
                ? window.innerWidth
                : de.clientWidth
        }
        else
        {
            floatingMenu.shiftX +=
                floatingMenu.hasElement
                ? de.clientWidth
                : floatingMenu.hasInner
                  ? window.innerWidth
                  : document.body.clientWidth;
        }
    }

    floatingMenu.shiftY = 
        floatingMenu.hasInner
        ? pageYOffset
        : floatingMenu.hasElement
          ? de.scrollTop
          : document.body.scrollTop;
    if (floatingMenu.targetY < 0)
    {
        if (floatingMenu.hasElement && floatingMenu.hasInner)
        {
            // Handle Opera 8 problems
            floatingMenu.shiftY +=
                de.clientHeight > window.innerHeight
                ? window.innerHeight
                : de.clientHeight
        }
        else
        {
            floatingMenu.shiftY +=
                floatingMenu.hasElement
                ? document.documentElement.clientHeight
                : floatingMenu.hasInner
                  ? window.innerHeight
                  : document.body.clientHeight;
        }
    }
}

floatingMenu.doFloat = function()
{
    var stepX, stepY;

    floatingMenu.computeShifts();

    stepX = (floatingMenu.shiftX + 
        floatingMenu.targetX - floatingMenu.nextX) * .07;
    if (Math.abs(stepX) < .5)
    {
        stepX = floatingMenu.shiftX +
            floatingMenu.targetX - floatingMenu.nextX;
    }

    stepY = (floatingMenu.shiftY + 
        floatingMenu.targetY - floatingMenu.nextY) * .07;
    if (Math.abs(stepY) < .5)
    {
        stepY = floatingMenu.shiftY + 
            floatingMenu.targetY - floatingMenu.nextY;
    }

    if (Math.abs(stepX) > 0 ||
        Math.abs(stepY) > 0)
    {
        floatingMenu.nextX += stepX;
        floatingMenu.nextY += stepY;
        floatingMenu.move();
    }

    setTimeout('floatingMenu.doFloat()', 20);
};

// addEvent designed by Aaron Moore
floatingMenu.addEvent = function(element, listener, handler)
{
    if(typeof element[listener] != 'function' || 
       typeof element[listener + '_num'] == 'undefined')
    {
        element[listener + '_num'] = 0;
        if (typeof element[listener] == 'function')
        {
            element[listener + 0] = element[listener];
            element[listener + '_num']++;
        }
        element[listener] = function(e)
        {
            var r = true;
            e = (e) ? e : window.event;
            for(var i = element[listener + '_num'] -1; i >= 0; i--)
            {
                if(element[listener + i](e) == false)
                    r = false;
            }
            return r;
        }
    }

    //if handler is not already stored, assign it
    for(var i = 0; i < element[listener + '_num']; i++)
        if(element[listener + i] == handler)
            return;
    element[listener + element[listener + '_num']] = handler;
    element[listener + '_num']++;
};

floatingMenu.init = function()
{
    floatingMenu.initSecondary();
    floatingMenu.doFloat();
};

// Some browsers init scrollbars only after
// full document load.
floatingMenu.initSecondary = function()
{
    floatingMenu.computeShifts();
    floatingMenu.nextX = floatingMenu.shiftX +
        floatingMenu.targetX;
    floatingMenu.nextY = floatingMenu.shiftY +
        floatingMenu.targetY;
    floatingMenu.move();
}

if (document.layers)
    floatingMenu.addEvent(window, 'onload', floatingMenu.init);
else
{
    floatingMenu.init();
    floatingMenu.addEvent(window, 'onload',
        floatingMenu.initSecondary);
}*/

//page loading script
/*function ajaxcombo(selectobjID, loadarea){
var selectobj=document.getElementById? document.getElementById(selectobjID) : ""
if (selectobj!="" && selectobj.options[selectobj.selectedIndex].id!="")
ajaxpage(selectobj.options[selectobj.selectedIndex].id, loadarea)
}

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
document.getElementById(containerid).innerHTML="<img src='/images/icons/loading.gif' /> Requesting content..." //Display "fetching page message"
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
document.getElementById(containerid).innerHTML=page_request.responseText}
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

//menu script	
//Applies cascading behavior for the specified dropdowns 
function applyCascadingDropdown(sourceId, targetId) { 
    var source = document.getElementById(sourceId); 
    var target = document.getElementById(targetId); 
    if (source && target) { 
        source.onchange = function() { 
            displayOptionItemsByClass(target, source.value); 
        } 
        displayOptionItemsByClass(target, source.value); 
    } 
} 

//Displays a subset of a dropdown's options 
function displayOptionItemsByClass(selectElement, className) { 
    if (!selectElement.backup) { 
        selectElement.backup = selectElement.cloneNode(true); 
    } 
    var options = selectElement.getElementsByTagName("option"); 
    for(var i=0, length=options.length; i<length; i++) { 
        selectElement.removeChild(options[0]); 
    } 
    var options = selectElement.backup.getElementsByTagName("option"); 
    for(var i=0, length=options.length; i<length; i++) { 
        if (options[i].className==className) 
            selectElement.appendChild(options[i].cloneNode(true)); 
    } 
} 

//Binds dropdowns 
function applyCascadingDropdowns() { 
    applyCascadingDropdown("category", "learning"); 
    //We could even bind items to another dropdown 
    //applyCascadingDropdown("items", "foo"); 
} 

//execute when the page is ready 
window.onload=applyCascadingDropdowns;*/