$(document).ready(function(){
	//home page slider
	$('#homeslides').cycle({
	    fx: 'scrollHorz',
	    speed: 1000,
	    timeout: 8000,
	    before: bgcolorChanger 
	});
	
	
	//This is to fix an IE Bug
	if ( $.browser.msie ) { $('#logo').hide().show(); }
	
	
	//Form examples
	$('#clientarea_username').example('Company Username');
	$('#clientarea_password').example('Password');
	$('#webstatements_username').example('Package Number');
	$('#webstatements_password').example('Password');
	$('form[name=calcform] input#name').example('Your Name');
	$('form[name=calcform] input#email').example('Your Email');
	$('form[name=calcform] input#phone').example('Your Phone No.');
	$('form[name=calcform] input#employer').example('Your Employer');
	
	//duallogin form
	$('form[name=duallogin_form] input').keyup(function(){
		var type="";
		type=$('form[name=duallogin_form] input[name=type]').val();
		if (type==""){
			var type=$(this).parent('fieldset').attr('id');
			if (type=="clientarea"){
				$('#webstatements input').attr('disabled', 'disabled');
			}
			if (type=="webstatements"){
				$('#clientarea input').attr('disabled', 'disabled');
			}	
			$('form[name=duallogin_form] input[name=type]').val(type);
		}
	});
	$('form[name=duallogin_form]').submit(function(){
		var type=$('form[name=duallogin_form] input[name=type]').val();
		if (type==""){
			$('#clientarea_username').example('Company Username');
			$('#clientarea_password').example('Company Password');
			$('#webstatements_username').example('Package Number');
			$('#webstatements_password').example('Password');			
			return false;
		}
		if (type=="clientarea"){
			$(this).attr('action','login');
			_gaq.push(['_trackEvent', 'Login', 'Client Area Login from Homepage']);				
		}
		if (type=="webstatements"){
			$(this).attr('action','https://reports.remunerator.com.au/logon.do');
			_gaq.push(['_trackEvent', 'Login', 'Statements Login from Homepage']);				
		}
		return true;
	});
	
	$('img[src="images/ico_expand.gif"]').hover(function(){
		$(this).attr('src','images/ico_expand_hov.gif');
	}, function() {
		$(this).attr('src','images/ico_expand.gif');
	});
	$('a[href="#login"]').click(function() {
		$('#nav li.login').addClass('active');
		$('#nav li.login').animate({
			marginTop: '-213px',
			height: '250px'
		}, 600, function() {
			$('#homeslides').cycle('pause');
			//$('#homeslides').css('opacity', '0.1');
			$('#nav li.login form').fadeIn(250);	
		});
		return false;
	});
	
	$('a.loginclose').click( function() {
		$('#nav li.login').removeClass('active');
		$('#nav li.login form').fadeOut(100);
		$('#nav li.login').animate({
			marginTop: '0',
			height: '37px'
		}, 313, function() {
			$('#homeslides').cycle('resume');
		});
		return false;
	});
	
	//CALCULATOR 
	//Start with default values and calculate them
	var defaultSalary = 70000;
	var defaultCarCost = 40000;
	var defaultKMs = 20000;
	
	$('#salaryval').val(defaultSalary);
	$('#salaryout').text('$'+defaultSalary+'/yr').commafy();
	$('#carcostval').val(defaultCarCost);
	$('#carcostout').text('$'+defaultCarCost).commafy();
	$('#kmsval').val(defaultKMs);
	$('#kmsout').text(defaultKMs+'kms').commafy();
	novatedcalculate();

	
	$('.slider#salary').slider({ 
		animate: true, 
		min: 25000, 
		max: 180000,
		step: 5000,
		value: defaultSalary,
		slide: function(event, ui){
			var num = parseInt(ui.value);
			$('#salaryval').val(num);
			$('#salaryout').text('$'+num+'/yr');
			$('#salaryout').commafy();
			novatedcalculate();
		}
	});
	 
	$('.slider#carcost').slider({ 
		animate: true, 
		min: 10000, 
		max: 100000,
		step: 500,
		value: defaultCarCost,
		slide: function(event, ui){
			var num = parseInt(ui.value);
			$('#carcostval').val(num);
			$('#carcostout').text('$'+num);
			$('#carcostout').commafy();
			novatedcalculate();
		}
	});
	$('.slider#kms').slider({ 
		animate: true, 
		min: 0, 
		max: 45000,
		step: 5000,
		value: defaultKMs, 
		slide: function(event, ui){
			var num = parseInt(ui.value);
			$('#kmsval').val(num);
			$('#kmsout').text(num+'kms');
			$('#kmsout').commafy();
			novatedcalculate();
		}
	});
	
	$('a#novatedcalcsubmit').click(function() {
		$('#novatedcalc .sliders').slideUp();
		$('#novatedcalc #calcform').slideDown();
		return false;
	});	
	
	$('a#novatedcalccancel').click(function() {
		$('#novatedcalc .sliders').slideDown();
		$('#novatedcalc #calcform').slideUp();
	});
	
	$('#novatedcalc .screen p.help a').hover(function() {
		//if currently animating, ignore it
		if ($('#novatedcalc-container .instructions:animated').length) {
			return false
		} else {
			$('#novatedcalc-container .instructions').show().animate({
				'right': '232px',
				'opacity': 1,
				 filter:''
			}, 300 );
		}
	}, function() {
		if ($('#novatedcalc-container .instructions:animated').length) {
			return false
		} else {
			$('#novatedcalc-container .instructions').animate({
				'right': '240px',
				'opacity': 0,
				 filter:''
			}, 150, function() {
				$('#novatedcalc-container .instructions').hide();
			});
		}
	});	
	
	//calc apply now form validation
	$('form[name=calcform]').submit(function() {
	//$('#novatedcalcsend').click(function(){
		errors=0;
		$('form[name=calcform] input').each(function() {
			var this_id=$(this).attr('id');
			var label=$('label[for='+this_id+']').html();
			if(label){
				if ($(this).val()==""){
					$(this).addClass('error');
					$(this).example('Please Enter '+label);
					errors=errors+1;
				}
			}
		});
		var email_address=$('#email').val();
		if (email_address!="Please Enter Email"){
			var email_valid=checkEmail(email_address);
			if (email_valid==false){
				$('#email').val('');
				$('#email').example('Please Enter Valid Email Address');
				$('#email').addClass('error');
				errors=errors+1;
			}
		}
		if (errors>0){
			return false;
		}else{
			$('form[name=calcform]').submit();
		}
	});	
	$('form[name=calcform] fieldset input,textarea').keyup(function(){
		$(this).removeClass('error');
	});		
	//Front Page announcement div
	
	$('.toggleannouncement').toggle(function() {
		$('.announcementcontent').slideDown();
		$(this).text('hide');
	}, function() {
		$('.announcementcontent').slideUp();
		$(this).text('show');
	});
	
	

	  
	
	//homepage nav wizardry
	
	//first, move each button off screen
	$('#homeslides-container #nav').children('li').children('a').css('margin-top','38px');
	$('#homeslide-glow').hide();
	
	//then animate them back up, each one slightly slower than the previous one
	// then boune them back down a little
	if ( $.browser.msie ) { $('#homeslide-glow').show() } else {  $('#homeslide-glow').fadeIn(2000); }
	
	// bounce them up a bit when hovered
	$('#homeslides-container #nav').children('li:not(.login)').children('a').hover(function() {
		$(this).animate({
			marginTop: 0
		}, 100 );
	}, function() {
		$(this).animate({
			marginTop: 2
		}, 100 );
	});
	$('#homeslides-container #nav').children('li').children('a').each(function() {
		thisLink = $(this).parent().index();
		thisTimer = (120 + (40*(thisLink + 1)));
		//$(this).text(thisTimer);
		$(this).animate({
			marginTop: 0
		}, thisTimer, function() {
			$(this).animate({
				marginTop: 2
			}, 100);
		});
	});
	
	$('ul.otmnav li a').click(function() {
		thisLink = $(this).attr('href').replace('#','');
		$('ul.otmnav li a').removeClass('current');
		$(this).addClass('current');
		$('ul.otmcontent li').hide();
		$('ul.otmcontent li#'+thisLink).show();
		return false;
		
	});
	
	
	// Hide / Show Menu Items
	
	$('#employees').hide();
	
	$('.moreNavItems a').live('click', function() {
		if ($(this).hasClass('hideNavItems')) {
			$(this).removeClass('hideNavItems');
			$(this).addClass('showNavItems');
			$(this).parent().children('.subNav').show();
		} else {
			$(this).removeClass('showNavItems');
			$(this).addClass('hideNavItems');
			$(this).parent().children('.subNav').hide();
		}
	});
	//FAQ page
	// Hide Answers for FAQs
	//
	$('dd.answer').hide();
	$('dl#faqs dt a').click(function() {
		$('dd.answer').hide();
		thisTitleID = $(this).attr('id').replace('title_','');
		$('dd.answer#quest_'+thisTitleID).toggle();
		return false;
	});
	
	
	//ALL PAGES navigation
	// Client-side "Current Page" Selector
	//		note: this is based on the URL of the current page and the href of links on the page
	//		that means it's VERY likely to at least be unreliable without some tweaks, and possibly fail completely.
	//		change/add to the stuff inside the .each() function depending on what you want to do

	//get the page filename from the URL
	thisPage = location.href.substring((location.href.lastIndexOf("/"))+1);
	thisPage = thisPage.replace('#','');
	//for each list item that has a link to this page's URL:
	$('li a[href="'+thisPage+'"]').each(function() {
		//add class="current"
		$(this).addClass('current');
		//display the parent element as block
		$(this).parents('ul').css('display','block');
		//change the color
		$(this).css('color','#223875');
		$(this).parent().parent().parent().children('a').css('color','#223875');
	});
	
	//Client Area package Calculator
	//Package Calculator
	$('div.calc').hide();
	$('li.calctab div a').click(function(){
		$('.calctab').removeClass('current');
		$(this).parent().parent().addClass('current');
		var id=$(this).parent().parent().attr('id').replace("_tab","");
		$('div.calc').hide();
		$('div#'+id).show();
		return false;
	});	
	
	//FORM VALIDATION


	// HOME PAGE VIDEO 
	$('a[href="#video"]').click(function() {
		showOverlay();
		_gaq.push(['_trackEvent', 'Video', 'Home Page Video Link Clicked']);				
	});
	
 	if (document.location.href.indexOf('#video') > 0) {
		showOverlay();
		_gaq.push(['_trackEvent', 'Video', 'Video Automatic Popup']);				
	}	
	
	$('a[href="#closeoverlay"]').click(function() {
		closeOverlay();
		$('.overlaycontent iframe').remove().clone().appendTo('.youtubecontainer');
		return false;
	});
});

	
//REFER A FRIEND 
$(document).ready(function(){
    $('a[href="#referafriend"]').click(function() {
        showReferAFriend();
    });
    
    if (document.location.href.indexOf('#referafriend') > 0) {
        showReferAFriend(); 
    }
    
    $('#refer-close').click(function() {
        $('#refer-a-friend').hide();
    });
    
    $('#refer-referee-details').children('input').attr('disabled','disabled');
    
    $('input#authorization').click(function() {
        if ($(this).attr('checked')) {  
            $('#refer-referee-details').children('input').removeAttr('disabled');
            $('#refer-referee-details').removeClass('disabled');
        } else {
            $('#refer-referee-details').children('input').attr('disabled','disabled');
            $('#refer-referee-details').addClass('disabled');
        }
    });
    $('#refer_a_friend').submit(function () {
        var errorcount = validate_form();

        //check the error count
        if (errorcount === 0) {
            //alert(errorcount);
            //all good - submit the form and carry on
            //$(this).text('huzzah!');
            //var form = $(this).parents('form:first');
            var form=$('#contact_form');
            //alert(form.attr('name'));
            form.submit();
            return true;
        } else if (errorcount === 1) {
            //something's wrong.
            $('body').animate({ scrollTop: 0 }, 'slow');
            $('p.intro').after('<p class="intro error">There is an error with the form. Please check that all the fields have been entered correctly.</p>');
        } else if (errorcount > 1) {
            $('body').animate({ scrollTop: 0 }, 'slow');
            $('p.intro').after('<p class="intro error">There are ' + errorcount + ' errors with the form. Please check that all the fields have been entered correctly.</p>');
        }
        return false;
    });
    
    //clear errors if the form field is corrected
    //$('input.error, select.error, textarea.error').live('blur', function() {  
    $('input, select, textarea').click(function(){
        var input_id=$(this).attr('id');
        var input_type=$("#"+input_id).attr('type');
        var form_field=new formField();
        form_field.input_id=input_id;
        form_field.label_text=$('label[for="'+input_id+'"]').text();
        form_field.input_type=input_type;   
        if (input_type=="checkbox" && form_field.isMandatoryField()){
            if (form_field.hasFieldValue()) {
                form_field.hideFieldError();
            }else{
                form_field.showFieldError();
            }
        }
    }); 
    $('input, select, textarea').blur(function(){
        var input_id=$(this).attr('id');
        var input_type=$("#"+input_id).attr('type');
        var form_field=new formField();
        form_field.input_id=input_id;
        form_field.label_text=$('label[for="'+input_id+'"]').text();
        form_field.input_type=input_type;
        if (form_field.isMandatoryField()){
            if (form_field.hasFieldValue()) {
                form_field.hideFieldError();
            }else{
                form_field.showFieldError();
            }
        }
    });  
    
    $('#reimbursement-claim-form').submit(function() {
        var errorcount = validate_form();

        //check the error count
        if (errorcount === 0) {
            //alert(errorcount);
            //all good - submit the form and carry on
            //$(this).text('huzzah!');
            //var form = $(this).parents('form:first');
            var form=$('#reimbursement-claim-form');
            //alert(form.attr('name'));
            form.submit();
            return true;
        } else if (errorcount === 1) {
            //something's wrong.
            $('body').animate({ scrollTop: 0 }, 'slow');
            $('p.intro').after('<p class="intro error">There is an error with the form. Please check that all the fields have been entered correctly.</p>');
        } else if (errorcount > 1) {
            $('body').animate({ scrollTop: 0 }, 'slow');
            $('p.intro').after('<p class="intro error">There are ' + errorcount + ' errors with the form. Please check that all the fields have been entered correctly.</p>');
        }
        return false;
    });	
    
    $('#bank-account-details').submit(function() {
        var errorcount = validate_form();

        //check the error count
        if (errorcount === 0) {
            //alert(errorcount);
            //all good - submit the form and carry on
            //$(this).text('huzzah!');
            //var form = $(this).parents('form:first');
            var form=$('#bank-account-details');
            //alert(form.attr('name'));
            form.submit();
            return true;
        } else if (errorcount === 1) {
            //something's wrong.
            $('body').animate({ scrollTop: 0 }, 'slow');
            $('p.intro').after('<p class="intro error">There is an error with the form. Please check that all the fields have been entered correctly.</p>');
        } else if (errorcount > 1) {
            $('body').animate({ scrollTop: 0 }, 'slow');
            $('p.intro').after('<p class="intro error">There are ' + errorcount + ' errors with the form. Please check that all the fields have been entered correctly.</p>');
        }
        return false;
    });
    
    // Hide / Show the Bank Account Details Update form
    $('input[type="checkbox"]').click(function() {
    	if ($('#changeBankDetails').is(':checked')) {
	    	$("#bankDetails").show();
	    } else {
	    	$("#bankDetails").hide();
		}
	});
	
	$('.odo_reading_login').submit(function() {
		errorcount = 0;
		//return false;
		$('label:contains("*")').each(function () {
			if ($('input#'+$(this).attr('for')).val() == '') {
				errorcount = errorcount + 1;
				return false;
			}
	   	});	
	    if (errorcount === 0) {
	        return true;
	
	    } else {
	    	$('p.error').text('All fields are required');
			return false;
	   
	    }
	 
	});
	
	$('.odo_reading_form').submit(function() {
		errorcount = 0;
		//return false;
		$('.reading_value input').each(function () {
			if ($(this).val() == '') {
				errorcount = errorcount + 1;
				return false;
			}
	   	});	
	    if (errorcount === 0) {
	        return true;
	
	    } else {
	    	$('.odo_submit p.error').text('A reading for each vehicle is required.');
			return false;
	   
	    }
	});	
	
});



// FUNCTIONS


function showOverlay() {
	$('#overlay').show();
}

function closeOverlay() {
	$('#overlay').hide();
}


function showReferAFriend() {
    $('#refer-a-friend').show();
}

function hide_error(input_id){
    $('p#'+input_id+ '_error').hide();
    $('label[for="'+input_id+'"]').removeClass('error');
    $('p#'+input_id+ '_error').removeClass('error');
    $('p#'+input_id+ '_error').fadeOut(300);    
    /*if ($(this).hasClass('error') == false) {
        return;
    } else {
        if (!$(this).val()) {
            return;
        } else {
            this_id = $(this).attr('id');
            $('label[for="'+this_id+'"]').removeClass('error');
            $(this).removeClass('error');
            $('p#'+this_id+'_error.error').fadeOut(300);
        }
    }*/ 
}
function validate_form() {

    //required fields checkermajigger

    //reset the error count
    errorcount = 0;
    //$('p.error').remove();
    $('p.error').hide();
    //$('p.error').removeClass('error');


    //for textboxes, textareas and selects
    $('label:contains("*"):visible').each(function () {
        //if a label has a * in it, and the next form element is empty

        var input_id=$(this).attr('for');
        var input_type=$("#"+input_id).attr('type');
        var form_field=new formField();
        form_field.input_id=input_id;
        form_field.label_text=$(this).text();
        form_field.input_type=input_type;
        if (form_field.hasFieldValue()){
            form_field.hideFieldError();
        }else{
        //if (!(form_field.hasFieldValue())){
        //if ((input_type=='checkbox' && !$('input#'+input_id).attr('checked')) || $('input#'+input_id+', select#'+input_id+', textarea#'+input_id).val() == "" || $('fieldset#'+input_id).children('input, select, textarea').val() == "" || !checkFieldsetValues(input_id)) {
            form_field.showFieldError();
            //add .error to the label
            //$(this).addClass('error');

            //OFFSET (IF IT'S REQUIRED)
            //get the label's position (relative to the top)
            //var offset = $(this).position();
            //var offset_correction = -80;
            //var offset_correction = $('#offset_correction').html();
            //$(this).text(offset.top);

            //add .error to the field as well
            //$(this).next('input, select, textarea').addClass('error');
            //$('fieldset#'+input_id).children('input, select, textarea').addClass('error');

            //WITH OFFSET show an error message with <label> + "is required" (hidden by default)
            //$(this).next('input, select, textarea').after('<p id="'+$(this).attr('for')+'_error" class="error" style="top:'+(offset.top-offset_correction)+'px;">'+$(this).text().replace('*','')+'  is required</p>');
            //$(this).next('fieldset').children('input, select, textarea').after('<p class="error" style="top:'+(offset.top-offset_correction)+'px;">'+$(this).text().replace('*','')+'  is required</p>');

            //WITHOUT OFFSET
            
            
            /*if ($('p#'+input_id+ '_error').length>0){
                $('p#'+input_id+ '_error').addClass('error');
                $('p#'+input_id+ '_error').show();
            }else{
                $(this).next('input, select, textarea').after('<p id="' + input_id + '_error" class="error">' + $(this).text().replace('*', '') + '  is required</p>');    
                $('fieldset#'+input_id).after('<p id="' + input_id + '_error" class="error">' + $(this).text().replace('*', '') + '  is required</p>');
            }*/
            //add one to the error count

            errorcount = errorcount + 1;

            //show all the error messages

        }
        
    });
    $('p.error').slideDown('slow');

    return errorcount;

}

function checkFieldsetValues(input_id){
    var retval=true;
    $('fieldset#'+input_id).children('input, select, textarea').each(function () {
        
        if ($(this).val() == ""){
            retval= false;
        }   
    });
    return retval;
}


function formField(){
    
    this.input_id="";
    
    this.input_type="";
    
    this.label_text="";
    
    this.isMandatoryField=isManadatoryField;
    
    this.hasFieldValue=hasFieldValue;
    
    this.showFieldError=showFieldError;
    
    this.hideFieldError=hideFieldError;
    
    this.getType=getType;
}

function hasFieldValue(){
    switch(this.getType())
    {
                 case 'checkbox': 
                        return $('input#'+this.input_id).attr('checked');
                 break;
                 case 'fieldset': 
                     return checkFieldsetValues(this.input_id);
                 break;
                 default:
                     return $('#'+this.input_id).val() != "";
                     //return $('input#'+this.input_id+', select#'+this.input_id+', textarea#'+this.input_id).val() != ""; 
                 break;
    }   
}

function showFieldError(){
    //add .error to the field as well
    $('#'+this.input_id).addClass('error');

    //OFFSET (IF IT'S REQUIRED)
    //get the label's position (relative to the top)
    //var offset = $(this).position();
    //var offset_correction = -80;
    //var offset_correction = $('#offset_correction').html();
    //$(this).text(offset.top);

    //add .error to the field as well
    //$(this).next('input, select, textarea').addClass('error');
    
    $('fieldset#'+this.input_id).children('input, select, textarea').addClass('error');

    //WITH OFFSET show an error message with <label> + "is required" (hidden by default)
    //$(this).next('input, select, textarea').after('<p id="'+$(this).attr('for')+'_error" class="error" style="top:'+(offset.top-offset_correction)+'px;">'+$(this).text().replace('*','')+'  is required</p>');
    //$(this).next('fieldset').children('input, select, textarea').after('<p class="error" style="top:'+(offset.top-offset_correction)+'px;">'+$(this).text().replace('*','')+'  is required</p>');

    //WITHOUT OFFSET
    switch(this.input_type)
    {
                 case 'checkbox':
                     $('label[for="'+this.input_id+'"]').addClass('error');
                 break;
                 default:
                        if ($('p#'+this.input_id+ '_error').length>0){
                            $('p#'+this.input_id+ '_error').addClass('error');
                            $('p#'+this.input_id+ '_error').show();
                        }else{          
                            $('#'+this.input_id).after('<p id="' + this.input_id + '_error" class="error">' + this.label_text.replace('*', '') + '  is required</p>');    
                            //$('fieldset#'+input_id).after('<p id="' + input_id + '_error" class="error">' + $(this).text().replace('*', '') + '  is required</p>');
                        }   
                 break;
    }       
    

}

function hideFieldError(){

    switch(this.input_type)
    {
                 case 'checkbox':
                     $('label[for="'+this.input_id+'"]').removeClass('error');
                 break;
                 default:
                        $('p#'+this.input_id+ '_error').removeClass('error');
                        $('p#'+this.input_id+ '_error').hide(); 
                 break;
    }   
}

function isManadatoryField(){
    return this.label_text.indexOf("*") != -1;
}

function getType(){
    if ($('fieldset#'+this.input_id).length>0){
        return 'fieldset';
    }
    return this.input_type;
}	
	
	
	
	
	
	
	
	
	
	
	
	
// functions	


//HTTPS REDIRECT
/*
function httpsRedirect() {
	var href = location.href;	  
	if ( href.substring(0,7) == "http://" ){
		self.location = href.split("http://").join("https://");
	}
}
httpsRedirect();
function httpRedirect() {
          var href = location.href;
            if ( href.substring(0,8) == "https://" )
                        self.location = href.split("https://").join("http://");
}
httpRedirect();
*/




//homepage background colour changer
function bgcolorChanger() {
	//$(this).children('h1').append(' '+thisBG);
	$("#homeslides-container").animate({
	      backgroundColor: '#'+$(this).attr('class')
	  }, 1000 );
} 

//novated calculator	
function novatedcalculate() {
	//sample formula - NOT CORRECT AT ALL
	//saving = Math.round((($('#carcostval').val()/2.7182818285)+($('#salaryval').val()/3.1415926536)-$('#kmsval').val()/1.61803398874));
	 $.getJSON('calculator_json.php?carcostval='+$('#carcostval').val()+"&salaryval="+$('#salaryval').val()+"&kmsval="+$('#kmsval').val()+'&callback=?', function(calculator) {
		 //calculator={"carcostval":"20000","salaryval":"50000","kmsval":"29000","saving":"2255.90"};
		 $('#novatedsaving').text('$'+calculator.saving);
		 //saving = Math.round((($('#carcostval').val()/2.7182818285)+($('#salaryval').val()/3.1415926536)-$('#kmsval').val()/1.61803398874));	
		 //$('#novatedsaving').text('$'+saving);
		 $('#novatedsaving').commafy();
	 });
}
//add commas to numbers
$.fn.commafy = function(){ 
    return this.each(function(){ 
        $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
    })
}
//calcform check email
function checkEmail(email) {
    var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return pattern.test(email);
}

function change(id){
	$('#'+id).toggle();
}

function hide_only(id){
	$('#'+id).hide();
}
function show(id){
	$('#'+id).show();
}

//op_childcare
function Convert_To_Decimal(num,x){
	  var fgh=num+'';
	  var ghj=fgh.substring(fgh.length-2,fgh.length-3);
	  var tyu=fgh.substring(fgh.length-1,fgh.length-2);
	  var add="";
	  if (x==2 && ghj!="." && tyu!=".") add+=".00";
	  if (x==2 && tyu==".") add+="0";
	 return num+add;
	}



