/* 
clancybrothers.js: library of javascript for Trainers Learning Skillnet web site
    david.kelly@fanore.com (http://www.fanore.com/website_design.htm)
    
    
  validate_search_form: test that user has entered valid keywords  
*/
var ssl_on=false;
var pausecontent=false; // global variable used for scrolling news area
var icon=false; // used for icon representing position on map

function setup_page(){
    
        //var f=$('js_init_form')
        var s_base=$F('u_base');
        if (s_base.toString().include('https')){
            ssl_on=true;
        }
    //alert("initialising ..");
    fix_height();
    var el=get_el("training_news");

    if (el){
        start_scroller();
    }
    var el=get_el("txt_username");
    if (el){
        Event.observe('txt_username', 'click', clear_text, false);
    }
    var el=get_el("map");
    if ((el)&&(!ssl_on)){
        eval('load_map();');
    }
    var el=get_el("list_dates");
    if (el){
        Event.observe('list_dates', 'click', go_there, false);
    }
    var el=get_el("employer");
    if (el){
        eval('setup_employer_form();');
    }
    var el=get_el('personal');
    if (el){
        eval('setup_personal_form();');
    }
    var el=get_el('personalac');
    if (el){
        eval('setup_personal_ac_form();');
    }
    var el=get_el('education');
    if (el){
        eval('setup_education_form();');
    }
    var el=get_el('invoice');
    if (el){
        eval('enable_tab_tracking(\'invoice\');');
    }
    var el=get_el('changepassword');
    if (el){
        eval('enable_tab_tracking(\'changepassword\');');
    }
    var el=get_el("register");
    if (el){
    eval('enable_tab_tracking(\'register\');');
    }
    
    var el=get_el('rates_information');
    if (el){
        eval('$(\'rates_information\').show();');
    }
    var el=get_el('ev_detail_area');
    if (el){
        eval('track_download();');
    }
    
}


function track_download(){
    var children=$('ev_detail_area').select('a');
    var ev_click=function(el){
        var c = el.href;
        el.href="javascript: open_link('" + c + "');"
    }
    children.each(ev_click);
}

function fix_height(){
    var h=(document.viewport.getHeight()-212).toString() + 'px';
    
    var b=$('main_panel').getStyle('height')
    if (parseInt(b.toString().replace('px',''))< parseInt(h.replace('px',''))){
        $('main_panel').setStyle({height: h});
    }
    else{
        $('main_panel').setStyle({height: 'auto'});
    }
    /*
    var el=get_el('e_terms');
    if (el){
        var t=(document.viewport.getHeight()-100).toString() + 'px';
        $('e_terms').setStyle({top: t}); 
    }
     */
}



function go_there(){
    var el=get_el("list_dates");
    window.location.href=el.options[el.selectedIndex].value;

}
function load_map() {

	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl())
//        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(53.24184851164888, -6.667842864990234), 12);

        var point = new GPoint(parseFloat( -6.667842864990234), parseFloat(53.24184851164888));
        var marker = new GMarker(point);
        
        //Longitude , Latitude 
//(-7.411994934082031, 52.34844860104819
        var icon = new GIcon();
        icon.image = "../images/trainers.gif";
        icon.iconSize = new GSize(32,32);
        icon.iconAnchor = new GPoint(0,32);
        icon.infoWindowAnchor = new GPoint(10, 20);
        
        var marker = new GMarker(point,icon);
        marker.title="Carrick-On-Suir"
        GEvent.addListener(marker, "click", function() {
//        showMapBlowup(point, opts?)
        marker.showMapBlowup({maxWidth:80});
        });
        
        map.addOverlay(marker);
        return marker

    }
 }
 
function load_venue_map() {
    //alert("venue map");
    var lat=0;
    var lon=0;
    var img='';
    var title='';
    lat=$F('v_lat');
    lon=$F('v_lon');
//    title=$('v_title').innerHTML();
    //alert(lat);
	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("venue_map"));
        map.addControl(new GLargeMapControl())
//        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(lat, lon), 12);

        var point = new GPoint(parseFloat(lon), parseFloat(lat));
        var marker = new GMarker(point);
        
        //Longitude , Latitude 
//(-7.411994934082031, 52.34844860104819
        //var blueIcon = new GIcon(G_DEFAULT_ICON);
        //blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
        var icon = new GIcon(G_DEFAULT_ICON);
        icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
        icon.iconSize = new GSize(32,32);
        icon.iconAnchor = new GPoint(0,32);
        icon.infoWindowAnchor = new GPoint(6, 15);
        
        var marker = new GMarker(point,icon);
        
        //marker.title=title;
        map.addOverlay(marker);
        //alert(marker.getTitle());
        GEvent.addListener(marker, "click", function() {
           //var w=marker.getTitle();
           //alert(w)
          // w.show();
          // marker.openInfoWindowHtml(w)
//        showMapBlowup(point, opts?)
//        marker.showMapBlowup({maxWidth:60});
        });
        return marker

    }
 }
 

function clear_text(){
    var el=get_el("txt_username");
    if (el){
        el.value='';
    }
}

//validate_search_form: test that user has entered valid keywords 
function validate_search_form(){
    var el=get_el("txt_keywords");
    if (el){
        
    }
    return true;
}


function start_scroller(){
    var el=get_el("news_data_feed");
    pausecontent=new Array()
//pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
    
    if (el){
        var buffer=el.value;
        if (buffer.charAt(buffer.length - 1) == "|") buffer = buffer.substr(0,buffer.length - 1);
	    var news=buffer.split("|");
        for (var i=0;i<news.length;i++){
            var feed=news[i];
            if (feed.charAt(feed.length - 1) == "$") feed = feed.substr(0,feed.length - 1);
            var array_feed=feed.split("$");
            var html='<a class="news_headline" href="' + array_feed[2] + '">'+ array_feed[0] + '</a><p></p><a class="news_text" href="' + array_feed[2] + '">' + array_feed[1] + '</a>';
            pausecontent[i]=html;
        }
        new pausescroller(pausecontent, "skillnet_news", "", 3000)
        //alert(buffer);
    
    }
    return void[0];
}


function open_link(url){
 var settings='Height=' + screen.height + ',Width=' + screen.width + ',Top=0,left=0,scrollbars=yes,resizable=1, location=1,status=1'
 var w=window.open(url,'clancybrothers',settings);    
}

/*validate_contact_form: validate the contact us/ enquiry form
 */
 function validate_contact_form(param_type){
 
 
 
 
    // txt_company
        var el=get_el("txt_company");
        if (el){
            if (el.value.length==0){
                alert("Please enter the Company Name.");
                el.focus();
                return false;
            }
        }
    switch(param_type){
        case 2: //application form
            var el=get_el("txt_address1");
            if (el){
                if (el.value.length==0){
                    alert("Please enter at least a two line address");
                    el.focus();
                    return false;
                }
            }
            var el=get_el("txt_address2");
            if (el){
                if (el.value.length==0){
                    alert("Please enter at least a two line address");
                    el.focus();
                    return false;
                }
            }
                    
            var el=get_el("txt_address4");
            if (el){
                if (el.options.selectedIndex==0){
                    alert("Please select the county from the list provided");
                    el.focus();
                    return false;
                }
            }
            
            var el=get_el("reference");
            if (el){
                if (el.options.selectedIndex==0){
                    alert("Please select the number of employees from the list provided");
                    el.focus();
                    return false;
                }
            }
                    
        }       //end switch statement 
        
    // txt_name
        var el=get_el("txt_name");
        if (el){
            if (el.value.length==0){
                alert("Please enter a contact name.");
                el.focus();
                return false;
            }
        }
    // txt_email
        var el=get_el("txt_email");
        if (el){
            if (el.value.length==0){
                alert("Please enter a contact email address.");
                el.focus();
                return false;
            }
        }
        var s=el.value;
        if (!fixstring(s,true)){
            alert("The email address you have entered is not supported on this system, Please check your entry");
            el.focus();
            return false;
        
        }
        
        
    // txt_telephone
//        var el=get_el("txt_telephone");
//        if (el){
//            if (el.value.length==0){
//                alert("to help us assist you better, Please enter your message.");
//                el.focus();
//                return false;
//            }
//        }
    switch (param_type){    
        case 0: // ordinary 'contact us' form
        // txt_comment
            var el=get_el("txt_comment");
            if (el){
                if (el.value.length==0){
                    alert("to help us assist you better, Please enter your message.");
                    el.focus();
                    return false;
                }
            }
            break;
        
    }    
    return true;
 }
 
 //validate_application_form: builds upon the contact us form and validates the address etc.
 function validate_application_form(){
        
        return validate_contact_form(2)
 }
 
//submit_form: utility that will perform client side validation of the passed form id and allow validator to post it 
function submit_form(param_form){
    var el=get_el("cs_validation");
    if (el){
        var f=$(param_form)
        var cs_validation=f['cs_validation'];
        eval($(cs_validation).getValue());
    }
    else{
        $(param_form).submit();
    }
}

function checkout(){
    $('do_checkout').value='1';
    check_basket();
}
//check_basket: ensure that user has entered only a valid numeric for any input elements
function check_basket(){
    //alert('check_basket');
    var f=$('basket');
    var buttons=f.getInputs('text');
    for (var i=0;i<buttons.length;i++){
        if(buttons[i].id.toString().include('quantity')){
            var el_id=buttons[i].id.toString().replace('quantity_','');
            //alert(el_id);
            if ($F(buttons[i].id).blank()){
                alert("Please only enter numeric values for the number of places ");
                $(buttons[i].id).value="1"
                $(buttons[i].id).focus();
                return false;
            }
            //check is numeric
            if (isNaN($F(buttons[i].id))){
                alert("Please only enter numeric values for the number of places ");
                $(buttons[i].id).value="1"
                $(buttons[i].id).focus();
                return false;
            }
            if (parseInt($F(buttons[i].id))<= 0){
                alert("Please only enter positive values for the number of places ");
                $(buttons[i].id).value="1"
                $(buttons[i].id).focus();
                return false;
            
            }
            // work out how many places have been booked, and how many provisional bookings exist and check amount requested against these figures
            var p = parseInt($F('places_' + el_id))
            var b = $F('bookings_' + el_id)
            var provisional = parseInt($F('provisional_' + el_id))
            var requested =  parseInt($F('quantity_' + el_id))
            if (p !=0){ //there IS a cap on number of places
                var remaining = p - provisional
                if (remaining < requested){
                    alert("We're sorry but there are only " + remaining + " places remaining for the selected course");
                    $(buttons[i].id).value=remaining.toString();
                    $(buttons[i].id).focus();
                    return false;
                }
               
            }
        };
    }
    $('your_details').value='';
    $('basket').submit();
}

//check_reminder(): check that an email address has actually been entered into the password reminder dialogue
function check_reminder(){
    
    var email=$F('txt_username');
    if (email.blank()){
        alert("Please enter the email address you used to register with us");
        $('txt_username').focus();
        return false;
    }
    if (!fixstring(email,true)){
        alert("Sorry, but your email address does not seem to be valid or is in a format that is not supported on our system");
        $('email').focus();
        return false;
    }
    $('reminder_form').submit();
}


//check_company
function check_company(){
    //company_type
    if ($F('company_type').blank()){
        alert("Please select the type of company ");
        $('company_type').focus();
        return false;
    }
    var company=$F('company_type');
    if (company=="Public Sector"){
        //check public sector type
        if ($F('public_sector').blank()){
            alert("Please select the type of public sector organisation ");
            $('public_sector').focus();
            return false;
        }
        
    }
    
    //previous courses
    if ($F('previous_course').blank()){
        alert("Please select yes or no ");
        $('previous_course').focus();
        return false;
    }
    $('your_details').value='';
    $('company').submit();

}

//populate_detail: triggered by change to 'level of detail available' selection list
function populate_detail(){
    $('h_detail').value=$F('detail_level');
    if (parseInt($F('detail_level'))==0){
        $('u_option').hide();
        $('row_address1').hide();
        $('row_address2').hide();
        $('row_address3').hide();
        $('row_list_locations').hide();
        $('row_telephone').hide();
        $('row_mobile').hide();
        if (parseInt($F('flag_fetac'))==0){
            $('row_age').hide();
        }
        else{
            $('row_pps').hide();
            $('row_dob').hide();
            
        
        }
        $('row_gender').hide();
        $('emp_frame').hide();
        $('ed_frame').hide();
        $('o_frame').hide();
    }
    else{
         $('u_option').show();
        $('row_address1').show();
        $('row_address2').show();
        $('row_address3').show();
        $('row_list_locations').show();
        $('row_telephone').show();
        $('row_mobile').show();
        if (parseInt($F('flag_fetac'))==0){
            $('row_age').show();
        }
        else{
            $('row_pps').show();
            $('row_dob').show();
            
        
        }
        $('row_gender').show();
        $('emp_frame').show();
        $('ed_frame').show();
        $('o_frame').show();
    }

}
//check_personal; check that personal information has been entered 
function check_personal(){
    var fetac=parseInt($F('flag_fetac'))
    $('your_details').value="";
    var is_personal=false;
    if ($('account_id').value==$F('h_owner')){
        is_personal=true;
    }
    
    
    var l_detail=parseInt($F('h_detail'))
    //$('h_detail').value=$F('detail_level');
    //firstname
    if ($F('firstname').blank()){
        if (is_personal){
            alert("Please enter your first name");
        }
        else{
            alert("Please enter the attendee\'s first name");
        }
        $('firstname').focus();
        return false;
    }
    
    //surname
    if ($F('surname').blank()){
        if (is_personal){
            alert("Please enter your surname");
        }
        else{
            alert("Please enter  the attendee\'s surname");
        }
        $('surname').focus();
        return false;
    }
    if (l_detail==0){
        //email
        if ($F('email').blank()){
            alert("Please enter  the attendee\'s  email address");
            $('email').focus();
            return false;
        }
        var email=$F('email')
        if (!fixstring(email,true)){
            alert("Sorry, but  the attendee\'s  email address does not seem to be valid or is in a format that is not supported on our system");
            $('email').focus();
            return false;
        }
        $('personal').submit();
        return true;
    }    
    //address 1 to 4
    if ($F('address1').blank()){
        if (is_personal){
            alert("Please enter at least a two line address");
        }
        else{
            alert("Please enter at least a two line address for the attendee");
        }
        $('address1').focus();
        return false;
    }
    if ($F('address2').blank()){
        if (is_personal){
            alert("Please enter at least a two line address");
        }
        else{
            alert("Please enter at least a two line address  for the attendee");
        }
        $('address2').focus();
        return false;
    }
    if ($F('list_locations').blank()){
        alert("Please select the county from the list provided");
        $('list_locations').focus();
        return false;
    }
    $('address4').value=$F('list_locations');
    //telephone or mobile
    if (($F('telephone').blank())&&($F('mobile').blank())){
        if (is_personal){
            alert("Please enter either telephone or mobile number");
        }
        else{
            alert("Please enter either telephone or mobile number  for the attendee");
        }
        $('telephone').focus();
        return false;
    }
    
    var telephone=fix_telephone($F('telephone'));
    var mobile=fix_telephone($F('mobile'));
    $('telephone').value=telephone;
    $('mobile').value=mobile;
    if (((telephone.blank())||(telephone.length<5))&&((mobile.blank())||(mobile.length<5))){
        alert("Please check the telephone number that you have entered as it does not seem to be a valid number");
        $('telephone').value=telephone;
        $('mobile').value=mobile;
        $('telephone').focus();
        return false;
    }
    
    //email
    if ($F('email').blank()){
        if (is_personal){
            alert("Please enter your email address");
        }
        else{
            alert("Please enter  the attendee\'s  email address");
        }
        $('email').focus();
        return false;
    }
    var email=$F('email')
    if (!fixstring(email,true)){
        if (is_personal){
            alert("The email address entered does not seem to be valid or is in a format that is not supported on our system");
        }
        else{
            alert("The attendee\'s email address does not seem to be valid or is in a format that is not supported on our system");
        }
        $('email').focus();
        return false;
    }
    
    if (fetac==1){
            //pps
            if ($F('pps').blank()){
                if (is_personal){
                    alert("Please enter your PPS number");
                }
                else{
                    alert("Please enter the attendee\'s  PPS number");
                }
                $('pps').focus();
                return false;
            }
            //dob
            var rule_day='';
            var rule_month='';
            var rule_year='';
            
            var el_day=get_el("dob_day")
            if (el_day.selectedIndex < 1){
                if (is_personal){
                    alert("Please select your date of birth");
                }
                else{
                    alert("Please select the attendee\'s  date of birth");
                }
                el_day.focus();
                return false
            }
            else{
                rule_day = el_day[el_day.selectedIndex].value;
            }
            var el_month=get_el("dob_month")
            if (el_month.selectedIndex < 1){
                if (is_personal){
                    alert("Please select your date of birth");
                }
                else{
                    alert("Please select  the attendee\'s date of birth");
                }
                el_month.focus();
                return false;                }
            else{
                rule_month = el_month[el_month.selectedIndex].value;
            }
           // alert(rule_month);
           // alert(el_month[el_month.selectedIndex].text);
            var el_year=get_el("dob_year")
            if (el_year.selectedIndex < 1){
                if (is_personal){
                    alert("Please select your date of birth");
                }
                else{
                    alert("Please select the attendee\'s date of birth");        
                }
                el_year.focus();
                return false;                }
            else{
                rule_year = el_year[el_year.selectedIndex].value;
            }
            var d=new Date();
            if ((parseInt(d.getFullYear)-parseInt(rule_year))<18){
                alert("Please check the date of birth as participants must be at least 18 years of age!");
                el_year.focus();
                return false;
            
            }
            var s_date=rule_day + " " + rule_month +  " " + rule_year 
            var d=new Date(s_date);
            //alert(s_date);
            //alert(d);
            //alert(d.getDate())
            //alert((parseInt(el_day.selectedIndex)));
            //we test the date is valid by checking the date value against the selectedIndex value (should always be 1 less than selectedIndex)
            if (d.getDate()!=(parseInt(el_day.selectedIndex))){
                alert("You have selected an invalid day of the month, Please check your entry");
                el_day.focus();
                return false;
            }
            
            $('dob').value=s_date;
        }
        else{
            //not fetac ==> we need age
            if ($F('age').blank()){
                if (is_personal){
                    alert("Please select your age range from the list provided");
                }
                else{
                    alert("Please select the attendee\'s age range from the list provided");
                }
                $('age').focus();
                return false;
            }
        }
        //end fetac specific validation  
        
    //gender             
    if ($F('gender').blank()){
        if (is_personal){
            alert("Please select your gender");
        }
        else{
            alert("Please select  the attendee\'s gender");
        }
        $('gender').focus();
        return false;
    }
    
    // now check the employment details section
    if ($F('year_started').blank()){
        if (is_personal){
            alert("Please select the year that you started with current employer");
        }
        else{
            alert("Please select the year the attendee started with current employer");
        }
        $('year_started').focus();
        return false;
    }
    
    
    //check the educational section of the form
    var el=document.forms['personal'].elements['opt_qualification']
    //alert(el.length);
   // alert($F('opt_qualification'));
    //var el=get_el("opt_qualification");
    var s_value='';
    //alert(Object.inspect(el));
    for (var i=0; i<el.length;i++){
        //alert(el[i].checked);
        if (el[i].checked==true){
            s_value=el[i].value;
            
        }
    }
    if (s_value.blank()){
        if (is_personal){
            alert("Please select your highest educational qualification to date");
        }
        else{
            alert("Please select the attendee\'s highest educational qualification to date");
        }
        el[0].focus();
        return false;
    }
    $('h_qualification').value=s_value;
    //year_qualified
    if ($F('year_qualified').blank()){
        if (is_personal){
            alert("Please select the year that you achieved the level of education specified");
        }
        else{
            alert("Please select the year that the attendee achieved the level of education specified");
        }
        $('year_qualified').focus();
        return false;
    }

    
    
    $('personal').submit();
}


//check_personal_ac; check that personal information has been entered 
function check_personal_ac(){
    var fetac=parseInt($F('flag_fetac'))
    $('your_details').value="";
    //firstname
    if ($F('firstname').blank()){
        alert("Please enter your first name");
        $('firstname').focus();
        return false;
    }
    
    //surname
    if ($F('surname').blank()){
        alert("Please enter your surname");
        $('surname').focus();
        return false;
    }
    //email
    if ($F('email').blank()){
        alert("Please enter  your  email address");
        $('email').focus();
        return false;
    }
    var email=$F('email')
    if (!fixstring(email,true)){
        alert("Sorry, but your  email address does not seem to be valid or is in a format that is not supported on our system");
        $('email').focus();
        return false;
    }
    //address 1 to 4
    if ($F('address1').blank()){
        alert("Please enter at least a two line address");
        $('address1').focus();
        return false;
    }
    if ($F('address2').blank()){
        alert("Please enter at least a two line address");
        $('address2').focus();
        return false;
    }
    if ($F('list_locations').blank()){
        alert("Please select the county from the list provided");
        $('list_locations').focus();
        return false;
    }
    $('address4').value=$F('list_locations');
    //telephone or mobile
    if (($F('telephone').blank())&&($F('mobile').blank())){
        alert("Please enter either telephone or mobile number");
        $('telephone').focus();
        return false;
    }
    
    var telephone=fix_telephone($F('telephone'));
    var mobile=fix_telephone($F('mobile'));
    $('telephone').value=telephone;
    $('mobile').value=mobile;
    if (((telephone.blank())||(telephone.length<5))&&((mobile.blank())||(mobile.length<5))){
        alert("Please check the telephone number that you have entered as it does not seem to be a valid number");
        $('telephone').value=telephone;
        $('mobile').value=mobile;
        $('telephone').focus();
        return false;
    }
    //not fetac ==> we need age
    if ($F('age').blank()){
        alert("Please select your age range from the list provided");
        $('age').focus();
        return false;
    }
    if (fetac==1){
    
            //pps
            if ($F('pps').blank()){
                alert("Please enter  the attendee\'s  PPS number");
                $('pps').focus();
                return false;
            }
            //dob
            var rule_day='';
            var rule_month='';
            var rule_year='';
            
            var el_day=get_el("dob_day")
            if (el_day.selectedIndex < 1){
                alert("Please select the attendee\'s  date of birth");
                el_day.focus();
                return false
            }
            else{
                rule_day = el_day[el_day.selectedIndex].value;
            }
            var el_month=get_el("dob_month")
            if (el_month.selectedIndex < 1){
                alert("Please select  the attendee\'s date of birth");
                el_month.focus();
                return false;                }
            else{
                rule_month = el_month[el_month.selectedIndex].value;
            }
           // alert(rule_month);
           // alert(el_month[el_month.selectedIndex].text);
            var el_year=get_el("dob_year")
            if (el_year.selectedIndex < 1){
                alert("Please select the attendee\'s date of birth");        
                el_year.focus();
                return false;                }
            else{
                rule_year = el_year[el_year.selectedIndex].value;
            }
            
            var s_date=rule_day + " " + rule_month +  " " + rule_year 
            var d=new Date(s_date);
            //alert(s_date);
            //alert(d);
            //alert(d.getDate())
            //alert((parseInt(el_day.selectedIndex)));
            //we test the date is valid by checking the date value against the selectedIndex value (should always be 1 less than selectedIndex)
            if (d.getDate()!=(parseInt(el_day.selectedIndex))){
                alert("You have selected an invalid day of the month, Please check your entry");
                el_day.focus();
                return false;
            }
            $('dob').value=s_date;
     }
        
    //gender             
    if ($F('gender').blank()){
        alert("Please select your gender");
        $('gender').focus();
        return false;
    }
    
    // now check the employment details section
     //company
    if ($F('emp_company').blank()){
        alert("Please enter the company name ");
        $('emp_company').focus();
        return false;
    }
    //address 1 to 4
    if ($F('emp_address1').blank()){
        alert("Please enter at least a two line address ");
        $('emp_address1').focus();
        return false;
    }
    if ($F('emp_address2').blank()){
        alert("Please enter at least a two line address ");
        $('emp_address2').focus();
        return false;
    }
    if ($F('emp_list_locations').blank()){
        alert("Please select the county from the list provided ");
        $('emp_list_locations').focus();
        return false;
    
    }
    $('emp_address4').value=$F('emp_list_locations')
    //telephone
    if ($F('emp_telephone').blank()){
        alert("Please enter the company telephone number ");
        $('emp_telephone').focus();
        return false;
    }
    var telephone=fix_telephone($F('emp_telephone'));
    $('emp_telephone').value=telephone;
    if ((telephone.blank())||(telephone.length<5)){
        alert("Please check the telephone number that you have entered as it does not seem to be a valid number ");
        $('emp_telephone').value=telephone;
        $('emp_telephone').focus();
        return false;
    }
    
    
    //job title
    if ($F('emp_jobtitle').blank()){
        alert("Please enter your job title");
        $('emp_jobtitle').focus();
        return false;
    }
    
    
    
    if ($F('year_started').blank()){
        alert("Please select the year started with current employer");
        $('year_started').focus();
        return false;
    }
    
    
    //check the educational section of the form
    var el=document.forms['personalac'].elements['opt_qualification']
    //alert(el.length);
   // alert($F('opt_qualification'));
    //var el=get_el("opt_qualification");
    var s_value='';
    //alert(Object.inspect(el));
    for (var i=0; i<el.length;i++){
        //alert(el[i].checked);
        if (el[i].checked==true){
            s_value=el[i].value;
            
        }
    }
    if (s_value.blank()){
        alert("Please select your highest educational qualification to date");
        el[0].focus();
        return false;
    }
    $('h_qualification').value=s_value;
    //year_qualified
    if ($F('year_qualified').blank()){
        alert("Please select the year that you achieved the level of education specified");
        $('year_qualified').focus();
        return false;
    }

    
    
    $('personalac').submit();
}



//check_login
function check_login(){
    if ($F('txt_email').blank()){
        alert("Please enter your email address ");
        $('txt_email').focus();
        return false;
    }
    var email=$F('txt_email');
    if (!fixstring(email,true)){
        alert("Please check the format of your email address ");
        $('txt_email').focus();
        return false;
    }
    if($F('txt_pass').blank()){
        alert("Please enter your password ");
        $('txt_pass').focus();
        return false;
    }
    $('your_details').value='';
    $('login').submit();
}


//check_other: toggle display of the 'other' data entry field
function check_other(param_list){
//alert('check');
    if ($F(param_list).blank()){
        return false;
    }
    if ($F(param_list)=='other'){
        if ($('other_' + param_list).hasClassName('hide_me')){
            $(param_list + '_other').value='';
            $('other_' + param_list).toggleClassName('show_me');
            $(param_list + '_other').focus();
        }
    }
    else{
        if ($('other_' + param_list).hasClassName('show_me')){
            $('other_' + param_list).toggleClassName('show_me');
        }
       $('other_' + param_list).hide();
       $(param_list + '_other').value=$F(param_list); 
    }
}

//setup_employer_form: make sure that list boxes reflect what user has entered previously
function setup_employer_form(){
    //industry sector
   /*
    if (!$F('sector_other').blank()){
        var el=get_el('sector');
        for (var i=0;i<el.options.length;i++){
            if ($F('sector_other')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //year started
    if (!$F('h_year_started').blank()){
        var el=get_el('year_started');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_year_started')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //occupation
    if (!$F('occupation_other').blank()){
        var el=get_el('occupation');
        for (var i=0;i<el.options.length;i++){
            if ($F('occupation_other')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
     */
    enable_tab_tracking('employer');
}


//setup_personal_form: make sure the gender drop down reflects what was entered previously
function setup_personal_form(){
    //gender
    if (!$F('h_gender').blank()){
        var el=get_el('gender');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_gender')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //year started
    if (!$F('h_year_started').blank()){
        var el=get_el('year_started');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_year_started')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //age
    if (!$F('h_age').blank()){
        var el=get_el('age');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_age')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //occupation
    if (!$F('occupation_other').blank()){
        var el=get_el('occupation');
        for (var i=0;i<el.options.length;i++){
            if ($F('occupation_other')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //qualification
    if (!$F('h_qualification').blank()){
        var el=get_el('opt_qualification');
        //alert(el.length);
        for (var i=0;i<el.length;i++){
            if ($F('h_qualification')==el[i].value){
                el[i].checked=true;
            }
        }
    }

    //year_qualified
    if (!$F('h_year_qualified').blank()){
        var el=get_el('year_qualified');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_year_qualified')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //courses
    if (!$F('h_courses').blank()){
        var el=get_el('courses');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_courses')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    enable_tab_tracking('personal');

}
//setup_personal_form: make sure the gender drop down reflects what was entered previously
function setup_personal_ac_form(){
    //gender
    if (!$F('h_gender').blank()){
        var el=get_el('gender');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_gender')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //year started
    if (!$F('h_year_started').blank()){
        var el=get_el('year_started');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_year_started')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //age
    if (!$F('h_age').blank()){
        var el=get_el('age');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_age')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //occupation
    if (!$F('occupation_other').blank()){
        var el=get_el('occupation');
        for (var i=0;i<el.options.length;i++){
            if ($F('occupation_other')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //qualification
    if (!$F('h_qualification').blank()){
        var el=get_el('opt_qualification');
        //alert(el.length);
        for (var i=0;i<el.length;i++){
            if ($F('h_qualification')==el[i].value){
                el[i].checked=true;
            }
        }
    }

    //year_qualified
    if (!$F('h_year_qualified').blank()){
        var el=get_el('year_qualified');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_year_qualified')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }

    
    //courses
    if (!$F('h_courses').blank()){
        var el=get_el('courses');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_courses')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    enable_tab_tracking('personalac');

}


//setup_education_form: populate drop-downs with information previously entered (if any)
function setup_education_form(){
    //qualification
    if (!$F('h_qualification').blank()){
        var el=get_el('qualification');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_qualification')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }

    //year_qualified
    if (!$F('h_year_qualified').blank()){
        var el=get_el('year_qualified');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_year_qualified')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }

    //nfq
    if (!$F('h_nfq').blank()){
        var el=get_el('nfq');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_nfq')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }

    //category
    /* 
    if (!$F('h_category').blank()){
        var el=get_el('category');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_category')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
     */
    //courses
    if (!$F('h_courses').blank()){
        var el=get_el('courses');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_courses')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    enable_tab_tracking('education');

}

//check_employer(): check that the employer details have been completed
function check_employer(){
    //company
    if ($F('company').blank()){
        alert("Please enter the company name ");
        $('company').focus();
        return false;
    }
    //address 1 to 4
    if ($F('address1').blank()){
        alert("Please enter at least a two line address ");
        $('address1').focus();
        return false;
    }
    if ($F('address2').blank()){
        alert("Please enter at least a two line address ");
        $('address2').focus();
        return false;
    }
    if ($F('list_locations').blank()){
        alert("Please select the county from the list provided ");
        $('list_locations').focus();
        return false;
    
    }
    $('address4').value=$F('list_locations')
    //sector
    /*
    if ($F('sector').blank()){
        alert("Please select the industry sector");
        $('sector').focus();
        return false;
    }
     */
    //telephone
    if ($F('telephone').blank()){
        alert("Please enter the company telephone number ");
        $('telephone').focus();
        return false;
    }
    var telephone=fix_telephone($F('telephone'));
    $('telephone').value=telephone;
    if ((telephone.blank())||(telephone.length<5)){
        alert("Please check the telephone number that you have entered as it does not seem to be a valid number ");
        $('telephone').value=telephone;
        $('telephone').focus();
        return false;
    }
    
    
    //year started
    /*
    if ($F('year_started').blank()){
        alert("Please select the year that you started with this employer ");
        $('year_started').focus();
        return false;
    }
    
    //occupation
    if ($F('occupation').blank()){
        alert("Please select an occupational category");
        $('occupation').focus();
        return false;
    }
     */
    //your name
    if ($F('txt_name').blank()){
        alert("Please enter your name");
        $('txt_name').focus();
        return false;
    }
    //job title
    if ($F('jobtitle').blank()){
        alert("Please enter your job title");
        $('jobtitle').focus();
        return false;
    }
    /*
    //hrcontact
    if ($F('hrcontact').blank()){
        alert("Please enter the name of the Human Resources contact ");
        $('hrcontact').focus();
        return false;
    }
     */
     $('your_details').value='';
    $('employer').submit();


}

//populate_attendee: auto-populate the 'attendee detail' form using user specific information
function populate_attendee(){
    // only accessible if user's account details are not already in use
    $('firstname').value=$F('h_firstname');
    $('surname').value=$F('h_surname');
    $('email').value=$F('h_email');
    $('address1').value=$F('h_address1');
    $('address2').value=$F('h_address2');
    $('address3').value=$F('h_address3');
    $('address4').value=$F('h_address4');
    $('telephone').value=$F('h_telephone');
    $('mobile').value=$F('h_mobile');
    //pps number 
    var el=get_el("pps");
    if (el){
        $('pps').value=$F('o_pps');
    }
    //list_locations
    if (!$F('h_address4').blank()){
        var el=get_el('list_locations');
        for (var i=0;i<el.options.length;i++){
            if ($F('h_address4')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    
    //gender
    if (!$F('o_gender').blank()){
        var el=get_el('gender');
        for (var i=0;i<el.options.length;i++){
            if ($F('o_gender')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //year started
    if (!$F('o_year_started').blank()){
        var el=get_el('year_started');
        for (var i=0;i<el.options.length;i++){
            if ($F('o_year_started')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //age
    if (!$F('o_age').blank()){
        var el=get_el('age');
        for (var i=0;i<el.options.length;i++){
            if ($F('o_age')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //occupation
    if (!$F('o_occupation').blank()){
        var el=get_el('occupation');
        for (var i=0;i<el.options.length;i++){
            if ($F('o_occupation')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    //qualification
    if (!$F('o_qualification').blank()){
    
    
        var el=document.forms['personal'].elements['opt_qualification']
        for (var i=0;i<el.length;i++){
            if ($F('o_qualification')==el[i].value){
                el[i].checked=true;
            }
        }
    }

    //year_qualified
    if (!$F('o_year_qualified').blank()){
        var el=get_el('year_qualified');
        for (var i=0;i<el.options.length;i++){
            if ($F('o_year_qualified')==el.options[i].value){
                el.selectedIndex=i;
            }
        }
    }
    
    
    
    $('account_id').value=$F('h_owner');
    $('h_detail').value='1';
    $('row_detail_level').hide();
    $('u_detail').innerHTML='Refresh form'
    $('u_link').href='javascript: unpopulate_attendee();'
    
}
//unpopulate_attendee: undo the 'populate attendee' option
function unpopulate_attendee(){
    $('firstname').value='';
    $('surname').value='';
    $('email').value='';
    $('address1').value='';
    $('address2').value='';
    $('address3').value='';
    $('address4').value='';
    $('telephone').value='';
    $('mobile').value='';
    //pps number 
    var el=get_el("pps");
    if (el){
        $('pps').value='';
    }
    
    var el=get_el('list_locations');
    el.selectedIndex=-1
    var el=get_el('gender');
    el.selectedIndex=-1
    var el=get_el('year_started');
    el.selectedIndex=-1
    var el=get_el('age');
    el.selectedIndex=-1
    var el=get_el('occupation');
    el.selectedIndex=-1
        var el=document.forms['personal'].elements['opt_qualification']
        //alert(el.length);
        for (var i=0;i<el.length;i++){
            el[i].checked=false;
            
        }

    var el=get_el('year_qualified');
    el.selectedIndex=-1
    $('account_id').value=$F('h_original');
    $('h_detail').value='0';
    $('row_detail_level').show();
    $('u_detail').innerHTML=$F('h_caption');
    $('u_link').href='javascript: populate_attendee();'
}


// populate_billing: auto-populate billing form using hidden employer detail field values
function populate_billing(){
    $('company').value=$F('e_company')
    $('address1').value=$F('e_address1');
    $('address2').value=$F('e_address2');
    $('address3').value=$F('e_address3');
    $('address4').value=$F('e_address4');
    $('telephone').value=$F('e_telephone');
    $('list_locations').value=$F('e_address4');
    //for (var i=0;i<el.options.length;i++){
   // 
    //}

}



//check_education(): validate the education details form 
function check_education(){
    //qualification
    if ($F('qualification').blank()){
        alert("Please select your highest educational achievement to date");
        $('qualification').focus();
        return false;
    }

    //year_qualified
    if ($F('year_qualified').blank()){
        alert("Please select the year that you achieved the level of education specified");
        $('year_qualified').focus();
        return false;
    }

    //nfq
//    if ($F('nfq').blank()){
//        alert("Please select your current NFQ Attainment level");
//        $('nfq').focus();
//        return false;
//    }
    $('your_details').value='';
    $('education').submit();

}
//check_attendees: check that an attendee record has been selected for each of the places being booked
function check_attendees(){
    var f=$('attendees');
    var children=f.getInputs();
    //alert(children.length);
    for (var i=0;i<children.length;i++){
        if (children[i].id.toString().include('ac')){
            if (parseInt($F(children[i].id))==0){
                alert("Please make sure that you have entered at least the name and email address for each attendee");
                return false;
            }
        }
    }
    $('your_details').value='';
    $('attendees').submit();
}

//check_invoice(): validate the invoice details form
function check_invoice(){
 //company
    if ($F('company').blank()){
        alert("Please enter the company name ");
        $('company').focus();
        return false;
    }
    //address 1 to 4
    if ($F('address1').blank()){
        alert("Please enter at least a two line address ");
        $('address1').focus();
        return false;
    }
    if ($F('address2').blank()){
        alert("Please enter at least a two line address ");
        $('address2').focus();
        return false;
    }
    if ($F('list_locations').blank()){
        alert("Please select the county from the list provided ");
        $('list_locations').focus();
        return false;
    
    }
    $('address4').value=$F('list_locations')

    if (($F('contact_firstname').blank()||$F('contact_surname').blank()) && ($F('po').blank())){
        alert("Please enter either the name of the person to whom the invoice should be addressed or a purchase order number ");
        $('contact_firstname').focus();
        return false;
    }
    if ($F('telephone').blank()){
        alert("Please enter the telephone number of the person to whom the invoice should be addressed ");
        $('telephone').focus();
        return false;
    }
    var telephone=fix_telephone($F('telephone'));
    $('telephone').value=telephone;
    if ((telephone.blank())||(telephone.length<5)){
        alert("Please check the telephone number that you have entered as it does not seem to be a valid number ");
        $('telephone').value=telephone;
        $('telephone').focus();
        return false;
    }
    $('your_details').value='';
    $('invoice').submit();

}

//  check_company_type based on user selection we show/hide next element
function check_company_type(){
    //
    $('div_public').innerHTML='';
    if (parseInt($F('company_type'))==0){
        $('div_sector').hide();
        $('div_public').show();
        //$('div_public').innerHTML='Skillnets funding is only available to those in the private sector or commercial semi-state organisations';
        $('company_type_name').value='Private Sector';
        $('div_email').show();
         eval('enable_tab_tracking(\'register\');');
    }
    else{
        $('div_sector').show();
        $('company_type_name').value='Public Sector';
        $('div_public').show();
        //$('div_public').innerHTML='Skillnets funding is only available to those in the private sector or commercial semi-state organisations';
    }

}

//check_public_type: check the public sector type
function check_public_type(){
    $('div_public').innerHTML='';
    if (parseInt($F('public_sector'))==0){
        $('div_public').show();
        $('public_sector_name').value='Commercial public sector';
        //$('div_public').innerHTML='Skillnets funding is only available to those in the private sector or commercial semi-state organisations';
        $('div_email').show();
         eval('enable_tab_tracking(\'register\');');
    }
    else{
        $('div_public').show();
        $('public_sector_name').value='Non-commercial public sector';
        $('div_public').innerHTML='Unfortunately non-commercial public sector (i.e. government-funded) organisations do not qualify for the Skillnet subsidy. The full "Non-member" course fee will apply for all training booked. '
        $('div_email').show();
         eval('enable_tab_tracking(\'register\');');
        //$('register_button').hide();
    
    }

}

//check_register: checks that all required fields on the registration formm have been completed
function check_register(){
    //company type
    if ($F('company_type').blank()){
        alert("Please select your company / employer organisation type");
        $('company_type').focus();
        return false;
    }

        // firstname
        if ($F('txt_firstname').blank()){
            alert("Please enter your first name");
            $('txt_firstname').focus();
            return false;
        }
        // surname
        if ($F('txt_surname').blank()){
            alert("Please enter your surname");
            $('txt_surname').focus();
            return false;
        }
        //email address
        if ($F('txt_user').blank()){
            alert("Please enter your email address");
            $('txt_user').focus();
            return false;
        }
        
        var email=$F('txt_user')
        if (!fixstring(email,true)){
            alert("The format of the email address you have entered is not supported on this system, Please check your entry");
             $('txt_user').focus();
            return false;
        }

        $('your_details').value='';
$('register').submit();
}


//enable_tab_tracking: when displaying a form we set a highlight to indicate which 'line' a user has moved focus to
function enable_tab_tracking(param_el){
    var v=navigator.appVersion;
    if (v.toString().include('MSIE 6.0')){
        return void[0];
    }

    var cls_highlight='highlighted';
    var el=get_el('cls_highlight');
    if (el){
        cls_highlight=$('cls_highlight').value;
    }
    var children=$A($(param_el).select('input.input_element','select.input_element','textarea.input_element'));
    //alert(children.length);
    var evfocus=function(el)
    {   
        //alert(Rico);
         Event.observe(el,'focus',function(){
            var row_name='row_' + el.id;
            var r=get_el(row_name);
            if (r){
                if (!$(row_name).hasClassName(cls_highlight)){
                    $(row_name).toggleClassName(cls_highlight);
                }
            }
         });
         Event.observe(el,'blur',function(){
            var row_name='row_' + el.id;
            var r=get_el(row_name);
            if (r){
                $(row_name).toggleClassName(cls_highlight);
            }
         });
         //Rico.Corner.round(el.id);
    }
    children.each(evfocus);
   // $('save').focusFirstElement();
    
}

function fix_telephone(param_value){
    var ret_value='';
    var wip_value=param_value;
    var a_values='1234567890'
    //alert(wip_value.length);
    for (var i=0;i<=wip_value.length;i++){
    //alert(wip_value.charAt(i))
        for (var x=0;x<=a_values.length;x++){
            
            if (wip_value.charAt(i)==a_values.charAt(x)){
                ret_value+=wip_value.charAt(i)
            }
        }
    } 
    //alert(ret_value);
    return ret_value;   
}


function validate_suggestion(){
    if($F('s_name').blank()){
        alert("Please enter your name ");
        $('s_name').focus();
        return false;
    }
    if($F('s_email').blank()){
        alert("Please enter your email address ");
        $('s_email').focus();
        return false;
    }
    var email=$F('s_email')
    if (!fixstring(email,true)){
        alert("The format of the email address you have entered is not supported on this system, Please check your entry");
         $('s_email').focus();
        return false;
    }
    
    
    if($F('s_company').blank()){
        alert("Please enter your company name ");
        $('s_company').focus();
        return false;
    }
    
    if($F('s_role').blank()){
        alert("Please enter your role ");
        $('s_role').focus();
        return false;
    }
    
    if($F('list_locations').blank()){
        alert("Please select your location ");
        $('list_locations').focus();
        return false;
    }
    
    if($F('s_comment').blank()){
        alert("Please enter the courses that you would like to suggest ");
        $('s_comment').focus();
        return false;
    }
    $('your_details').value='';
    $('suggestion').submit();
}
function validate_cancellation(){
    if($F('s_company').blank()){
        alert("Please enter your company name ");
        $('s_company').focus();
        return false;
    }
    if($F('s_name').blank()){
        alert("Please enter your name ");
        $('s_name').focus();
        return false;
    }
    //email address
    if ($F('s_email').blank()){
        alert("Please enter your email address");
        $('s_email').focus();
        return false;
    }
    
    var email=$F('s_email')
    if (!fixstring(email,true)){
        alert("The format of the email address you have entered is not supported on this system, Please check your entry");
         $('s_email').focus();
        return false;
    }

    if ($F('s_telephone').blank()){
        alert("Please enter a contact telephone number");
        $('s_telephone').focus();
        return false;
    }
    var telephone=fix_telephone($F('s_telephone'));
    $('s_telephone').value=telephone;
    if ((telephone.blank())||(telephone.length<5)){
        alert("Please check the telephone number that you have entered as it does not seem to be a valid number ");
        $('s_telephone').value=telephone;
        $('s_telephone').focus();
        return false;
    }

    if($F('list_locations').blank()){
        alert("Please select your location ");
        $('list_locations').focus();
        return false;
    }
    
    $('your_details').value='';
    $('cancellation').submit();

}


//show_map: displays the map
function show_map(){
    if (!ssl_on){
    $('map_container').show();
    eval('load_venue_map();');
    $('map_button').innerHTML='Hide Map';
    $('map_link').href="javascript: hide_map();"
    }
    else{
        $('map_button').innerHTML='Unavailable';
    
    }
}
//hide_map: hide the map
function hide_map(){
    $('map_container').hide();
    //eval('load_venue_map();');
    $('map_button').innerHTML='View Map';
    $('map_link').href="javascript: show_map();"

}

//check_password: checks that user has entered identical new password values
function check_password(){
    if ($F('u_current').blank()){
        alert("Please enter your current password");
        $('u_current').focus();
        return false;
    }

    if ($F('u_new').blank()){
        alert("Please enter the new password that you want to use");
        $('u_new').focus();
        return false;
    }
    var n = $F('u_new');
    // ensure that there are between 6 and 10 characters in the password and that it does not contain invalid characters
    if (!fixstring(n,false)){
        alert("Please use only numbers and letters for your password");
        $('u_new').value='';
        $('u_confirm').value='';
        $('u_new').focus();
        return false;
    
    }
    if ((n.length < 6)||(n.length>10)){
        alert("Please use between 6 and 10 characters for your password");
        $('u_new').focus();
        return false;
    
    }

    if ($F('u_confirm').blank()){
        alert("Please confirm the new password that you want to use");
        $('u_confirm').focus();
        return false;
    }

    if (($F('u_confirm')!=$F('u_new'))){
        alert("Please check your entry as the password and confirm password values do not match");
        $('u_confirm').value='';
        $('u_confirm').focus();
        return false;
    }
    $('your_details').value='';
    $('changepassword').submit();
}


// display the users addressbook
function address_book(){
         
         var l=$('u_book').cumulativeOffset().left-100;
         var t=$('u_book').cumulativeOffset().top-200;
         var w=document.viewport.getWidth()-420;
         var d_top=document.viewport.getHeight-400;
         if (parseInt(l) > parseInt(w)){
         //   l=w;
         }
         if (parseInt(t)> parseInt(d_top)){
          //  t=d_top;
         } 
        $('m_addressbook').setStyle({top: t + 'px', left: l + 'px'}); 
        $('m_addressbook').show();
        //new Effect.Appear('m_addressbook');


}
//use_addressbook: process the users selection from addressbook
function use_addressbook(){
    var el=get_el("opt_use")
    if (el.length){
                for (var i=0;i<=el.length;i++){
                    if (el[i].checked){
                        // remote control the attendee details form; hide all non-critical fields and populate firstname, surname & email address
                        var s_id=el[i].value
                        $('account_id').value=s_id;
                        $('firstname').value=$('first' + s_id).value;
                        $('surname').value=$('surname' + s_id).value;
                        $('email').value=$('email' + s_id).value;
                    $('u_option').hide();
                    $('row_address1').hide();
                    $('row_address2').hide();
                    $('row_address3').hide();
                    $('row_list_locations').hide();
                    $('row_telephone').hide();
                    $('row_mobile').hide();
                    if (parseInt($F('flag_fetac'))==0){
                        $('row_age').hide();
                    }
                    else{
                        $('row_pps').hide();
                        $('row_dob').hide();
                        
                    
                    }
                    $('row_gender').hide();
                    $('emp_frame').hide();
                    $('ed_frame').hide();
                    $('o_frame').hide();
                    $('h_detail').value='0'; 
                    $('detail_level').value='0'; 
                    $('h_addressbook').value='1'; 
                    $('row_detail_level').hide(); 
                    $('m_addressbook').hide();
                    return void[0];  
                    }
                }
          }
     else{
        if (el.checked){
            // remote control the attendee details form; hide all non-critical fields and populate firstname, surname & email address
            var s_id=el.value
            $('account_id').value=s_id;
            $('firstname').value=$('first' + s_id).value;
            $('surname').value=$('surname' + s_id).value;
            $('email').value=$('email' + s_id).value;
        $('u_option').hide();
        $('row_address1').hide();
        $('row_address2').hide();
        $('row_address3').hide();
        $('row_list_locations').hide();
        $('row_telephone').hide();
        $('row_mobile').hide();
        if (parseInt($F('flag_fetac'))==0){
            $('row_age').hide();
        }
        else{
            $('row_pps').hide();
            $('row_dob').hide();
            
        
        }
        $('row_gender').hide();
        $('emp_frame').hide();
        $('ed_frame').hide();
        $('o_frame').hide();
        $('h_detail').value='0'; 
        $('detail_level').value='0'; 
        $('h_addressbook').value='1'; 
        $('row_detail_level').hide(); 
        $('m_addressbook').hide();
        return void[0];  
        }
     
     }
    //get to here then nothing was selected
    alert("Please select the addressbook entry you wish to use!");
    return void[0];
}

//close_addressbook
function close_addressbook(){
    $('m_addressbook').hide();
}


function delete_basket(param_id){
    var text="Are you sure you want to delete your shopping basket ?"
    var url="../asp/fanore.asp"
    var params="?action=deletebasket"
    if (confirm(text)){
        ajax_get_url(url,params,'', '');
        window.location.href='../'
    }
    return void[0]
}

function delete_basket_item(param_id, param_title){
    var text="Are you sure you want to delete " + param_title + " from your shopping basket ?"
    var url="basket-action-deleteitem-z-book-step-0-recordid-" + param_id + ".htm"
    if (confirm(text)){
        
        window.location.href=url
    }
    return void[0]

}
