$().ready(function() {
  var currentpage='home';
	if (window.location.search){
		var rx = /page=([^&]+)/
		if (match = rx.exec(window.location.search)){
				currentpage=match[1];
		}
	}

	//track call me click
	$('a[target*=Callback_RingMe]').click(function(){
		$.get('index.php',{page:'$$logclick',action:'option2'});
		//alert('Page= ' +currentpage+ ' Button click to call');
		try{
			if (pageTracker!==undefined) {
				pageTracker._trackEvent('Button', 'Click To Call', currentpage);
			}
		}
		catch(err) {}

	});

	//track apply now click
	$('a[href*=apply-now]').click(function(){
		$.get('index.php',{page:'$$logclick',action:'option1'});
		//alert('Page= ' +currentpage+ ' Button Apply Now');

		try{
			if (pageTracker!==undefined) {
				pageTracker._trackEvent('Button', 'Apply Now', currentpage);
			}
		}
		catch(err) {}

	});

	//track submit form

	$('form[name="quickform"]').attr('onsubmit', '');
	$('form[name="quickform"]').bind('submit', function (e){
		var result = quickformValidations(this);
		
		if (result){
			//alert('Form submitted');
			$.get('index.php',{page:'$$logclick',action:'option3'});
			try{
				if ($(this).attr('name')!='MaintForm' && pageTracker!==undefined) {
					pageTracker._trackEvent('Button', 'Option 3 Submit', currentpage);
				}
			}
			catch(err) {}
		}
		return result;
	});

});
