// Global Vars
var questionPointer = '<span class="arrow"></span>';
var questionImg ='/Templates/RSA/Images/question_mark.png';
var questionImgRollover = '/Templates/RSA/Images/question_mark_rollover.png';
var jPlayer = '<div id="jquery_jplayer"></div><div class="jp-playlist-player"><div class="jp-interface"><ul class="jp-controls"><li id="jplayer_play" class="jp-play">play</li><li id="jplayer_pause" class="jp-pause">pause</li><li id="jplayer_stop" class="jp-stop">stop</li><li id="jplayer_volume_min" class="jp-volume-min">min volume</li><li id="jplayer_volume_max" class="jp-volume-max">max volume</li><li id="jplayer_previous" class="jp-previous">previous</li><li id="jplayer_next" class="jp-next">next</li></ul><div class="jp-progress"><div id="jplayer_load_bar" class="jp-load-bar"><div id="jplayer_play_bar" class="jp-play-bar"></div></div></div><div id="jplayer_volume_bar" class="jp-volume-bar"><div id="jplayer_volume_bar_value" class="jp-volume-bar-value"></div></div><div id="jplayer_play_time" class="jp-play-time"></div><div id="jplayer_total_time" class="jp-total-time"></div></div><div id="jplayer_playlist" class="jp-playlist"><ul></ul></div></div>';

// Init Function
$(function() {
	if($('#notifications').length > 0) 
	{
		$('#notifications #notifications-wrapper').cycle({
			height: 32,
			pause:  1
		});
	}
	if($('#tab-nav').length > 0)
	{
		rolloverTabNav();
	}
	
	if($('.first-question').length > 0)
	{
		observeQuestions();
	}
	
	if($('#accordion').length > 0)
	{
		$("#accordion").accordion
			({ 
			 	autoHeight: false,
				change: function(event, ui) { 
					pgView('/virtual/contactus/tab-'+ui.newHeader.text().toLowerCase()); 
				}
			});
	}
	
	if($('#social-links').length > 0)
	{
		addSocialLinks();
	}
	
	if($('#di_keyword').length > 0)
	{
		observe_dikeyword();
	}
	
	if($('.map-menu h2').length > 0)
	{
		setupMapUse();
	}
	
	if($('.modulequestion h1').length > 0)
	{
		setupMapUse2();
	}
	
//	if($('.video-warning').length > 0)
//	{
//		showVideoWarning();
	//	}

	if ($('.radio-ads').length > 0) {
	    setUpAudioPlayer();
	}
	
	if ($('a#clearRegisterform').length) {
		$('a#clearRegisterform').click(function() {
  			clearForm();
		});
	}

	if ($('div#feedbackForm').length) {
		// In the event of an error on the screen, make sure the correct fields are
		// showing on entry
		if ($("input[name='ctl00$MainContentRegion$FeedbackForm1$communicMethod']:checked").val() == 'email')
			{
				$('#email-row').show();
				$('#addressDetails').hide();
			}
			else
			{
				$('#email-row').hide();
				$('#addressDetails').show();
			}
			
		// On click show / hide the correct divs
		$("input[name='ctl00$MainContentRegion$FeedbackForm1$communicMethod']").click(function(){
			if ($("input[name='ctl00$MainContentRegion$FeedbackForm1$communicMethod']:checked").val() == 'email')
				// Code for handling value 'email'
				{
				$('#email-row').slideDown();
				$('#addressDetails').slideUp();
				}
			else if ($("input[name='ctl00$MainContentRegion$FeedbackForm1$communicMethod']:checked").val() == 'post')
				// Code for handling value 'post'
				{
					$('#email-row').slideUp();
					$('#addressDetails').slideDown();
					
				}
		});
	}
	if ($('div#complaintForm').length) {
		// In the event of an error on the screen, make sure the correct fields are
		// showing on entry
		if ($("input[name='ctl00$MainContentRegion$ComplaintsForm1$communicMethod']:checked").val() == 'email')
			{
				$('#email-row').show();
				$('#addressDetails').hide();
			}
			else
			{
				$('#email-row').hide();
				$('#addressDetails').show();
			}
			
		// On click show / hide the correct divs
		$("input[name='ctl00$MainContentRegion$ComplaintsForm1$communicMethod']").click(function(){
			if ($("input[name='ctl00$MainContentRegion$ComplaintsForm1$communicMethod']:checked").val() == 'email')
				// Code for handling value 'email'
				{
				$('#email-row').slideDown();
				$('#addressDetails').slideUp();
				}
			else if ($("input[name='ctl00$MainContentRegion$ComplaintsForm1$communicMethod']:checked").val() == 'post')
				// Code for handling value 'post'
				{
					$('#email-row').slideUp();
					$('#addressDetails').slideDown();
					
				}
		});
	}
	if ($('#ctl00_MainContentRegion_ComplaintsForm1_complaintType').length) {
		// In the event of an error on the screen, make sure the correct fields are
		// showing on entry
			$('#driver-number-row').hide();
			$('#car-reg-row').hide();
			$('#car-webpage-row').hide();
			$('#road-safety-info').hide();
			$('#testing').hide();
			if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "Driver Testing")
			//if ($("input[name='complaintType']:selected").val() == 'Driver Testing')
				{		
					$('#driver-number-row').slideDown();
					$('#testing').slideDown();
				}
				else if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "NCT (National Car Test)")
				{
					$('#car-reg-row').slideDown();
					$('#testing').slideDown();
				}
				else if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "Website")
				{
					$('#car-webpage-row').slideDown();
				}
				else if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "Road Safety")
				{
					$('#road-safety-info').slideDown();
				}
			
		// On click show / hide the correct divs
		$("#ctl00_MainContentRegion_ComplaintsForm1_complaintType").change(function(){
			$('#driver-number-row').hide();
			$('#car-reg-row').hide();
			$('#car-webpage-row').hide();
			$('#road-safety-info').hide();
			$('#testing').hide();
			
			if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "Driver Testing")
			//if ($("input[name='complaintType']:selected").val() == 'Driver Testing')
				{		
					$('#driver-number-row').slideDown();
					$('#testing').slideDown();					
				}
				else if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "NCT (National Car Test)")
				{
					$('#car-reg-row').slideDown();
					$('#testing').slideDown();					
				}
				else if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "Website")
				{
					$('#car-webpage-row').slideDown();
				}
				else if ($("#ctl00_MainContentRegion_ComplaintsForm1_complaintType option:selected").text() == "Road Safety")
				{
					$('#road-safety-info').slideDown();
				}
		});
	}
	if ($('div#news-overlay').length) {
		$("a#close-overlay").click(function(){
				$('div#news-overlay').slideUp();
		});
	}
	
	if($('#inner-feature').length > 0) {
	    $('#inner-feature #inner-feature-wrapper').cycle({
			height: 192,
			pause:  1
		});
	}
	
	if ($('div.offence-bar').length) {
		$('div.offence-bar').each(function(index) {
		    var maxcapacity = $('#ctl00_MainContentRegion_OffenceType1_hfMaxCount').val(); 
            var capacity = Math.round($(this).text().replace(/\,/,""));
            capacity = (capacity / maxcapacity) * 150;
            // where 300000 is the maximum in the table and 360 is the maximum width of the bar (in pixels)
            // the bar is then created as padding-left 180px, and width of 180px making the total 360px
            // bar value / 750 (the maximum bar value) * the maximum width (200px)
            $(this).width(capacity);
            $(this).css('padding-left', capacity);
          });

	}
	if ($('div.offence-bar-details').length) {
		$('div.offence-bar-details').each(function(index) {
		    var maxcapacity = 5000; 
            var capacity = Math.round($(this).text().replace(/\,/,""));
            capacity = (capacity / maxcapacity) * 180;
            // where 300000 is the maximum in the table and 360 is the maximum width of the bar (in pixels)
            // the bar is then created as padding-left 180px, and width of 180px making the total 360px
            // bar value / 750 (the maximum bar value) * the maximum width (200px)
            $(this).width(capacity);
            $(this).css('padding-left', capacity);
          });

	}
	if ($('div.licence-bar').length) {
		$('div.licence-bar').each(function(index) {
		    var maxcapacity = $('#ctl00_MainContentRegion_LicenceType1_hfMaxCount').val(); 
            var capacity = Math.round($(this).text().replace(/\,/,""));
            capacity = (capacity / maxcapacity) * 225;
            // where 500000 is the maximum in the table and 450 is the maximum width of the bar (in pixels)
            // here we are allocating 225 pixels for padding-left
            // bar value / 750 (the maximum bar value) * the maximum width (200px)
            $(this).width(capacity);
            $(this).css('padding-left', capacity);
         });
	}	

	if ($('#content-body #selectYear span.question img').length) {
		$("#content-body #selectYear span.question img").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [12,72],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}
	if ($.browser.msie && $.browser.version=="8.0" && $('.countytoolTip').length ) {
		
		$("#content-body .countytoolTip").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [39,59],
			events: {
				def: 'click, mouseleave'
			}		
		});
		$("#content-body .cattoolTip").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [39,270],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}
	else 
	{
		$("#content-body .countytoolTip").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [39,169],
			events: {
				def: 'click, mouseleave'
			}		
		});
		$("#content-body .cattoolTip").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [39,380],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}	
	
	if ($('#content-body th span.question img').length) {
			$("#content-body th span.question img").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [147,553],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}
	
	if ($('#content-body td span.question img.view1').length) {
			$("#content-body td span.question img.view1").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [869,72],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}
	
	if ($('#content-body td span.question img.view2').length) {
			$("#content-body td span.question img.view2").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [819,97],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}
	

	// +ICH 2011 10 03 - Adding tooltips for the Prosecution Search form
	if ($('#content-body span.question img.keywordTip').length) {
			$("#content-body span.question img.keywordTip").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [280,470],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}

	if ($('#content-body span.question img.countyTip').length) {
			$("#content-body span.question img.countyTip").tooltip({ 
			effect: 'slide',
			relative: true,
			position: 'bottom center',
			offset: [330,465],
			events: {
				def: 'click, mouseleave'
			}		
		});
	}

});

function rolloverTabNav()
{
	$('#tab-nav li').hover(
		function()
		{
			$(this).addClass('js-selected');
			$(this).css('background-color', 'transparent');
		},
		function()
		{
			$(this).removeClass('js-selected');
		}
	);
		$('.tab-content').hide();
		$('.tab-content:first').show();
		$('#tab-nav a').click(
		function() {
		    $('#tab-nav li').removeClass('selected');
		    $(this).parent('li').addClass('selected');
		    $('.tab-content').hide();
		    idName = '#' + $(this).parent().attr('id') + '-content';
		    $(idName).show();
		    return false;
		}
	);	
}

function observeQuestions() 
{
	$('.selection-wrapper').hide();
	$('.first-question').addClass('selected');
	
	$('.first-question input').focus
	(
	 	function()
		{
			$(this).closest('.question').removeClass('selected');
			$(this).closest('.question').append(questionPointer);
			var id = $(this).attr('id');
			
			if(!$('.'+id).is(':visible'))
			{
				if($('.selection-wrapper:visible').length > 0)
				{
					$('.selection-wrapper:visible').slideUp('slow',
						function() {
							// A little bit of housekeeping
							$('.selection-wrapper .question').removeClass('selected');
	
							// Show the new question
							showQuestion(id);
						}
					);
				}
				else
				{
					// Show the new question
					showQuestion(id);
				}
			}
		}
	 );
	
	$('.selection-wrapper input').focus(function(){checkFocus($(this));});
	$('.selection-wrapper select').focus(function(){checkFocus($(this));});
	$('.selection-wrapper textarea').focus(function(){checkFocus($(this));});
}

function showQuestion(id)
{
	$('.'+id).find('.question:first').addClass('selected');
	$('.'+id).slideDown('slow');
}

function checkFocus(input)
{
	if(!$(input).closest('.question').hasClass('selected'))
	{
		$('.selection-wrapper .question').removeClass('selected');
		$(input).closest('.question').addClass('selected');
	}
}

function addSocialLinks()
{
	// Get URL & Title
	var current_url = window.location;
	var page_title = document.title;
	
	// Set up Social Links
	var url_facebook  = 'http://www.facebook.com/sharer.php?u='+current_url;
	var url_twitter   = 'http://twitter.com/home?status='+page_title+' '+current_url;
	var url_bebo      = 'http://www.bebo.com/c/share?Url='+current_url+'&amp;Title='+page_title;
	var url_delicious = 'http://delicious.com/save?url='+current_url+'&amp;title='+page_title;
	
	// Add the links to the panel
	$('#url_facebook').attr('href',url_facebook);
	$('#url_twitter').attr('href',url_twitter);
	$('#url_bebo').attr('href',url_bebo);
	$('#url_delicious').attr('href',url_delicious);
	
	// Display the panel
	$('#social-links')
		.addClass('clearfix')
		.css('display','block');
}

function observe_dikeyword()
{
	var default_val = 'Enter an optional keyword';
	$('#di_keyword').addClass('default').val(default_val);
	$('#di_keyword').focus(
		function() {
			$(this).removeClass('default');
			var text = $(this).val();
			if(text == default_val)
				$(this).val('');
		}
	);
	$('#di_keyword').blur(
		function() {
			var text = $(this).val();
			if(text == '') 
			{
				$(this).addClass('default');
				$(this).val(default_val);
			}
		}
	);
}

function setupMapUse()
{
	$('.map-menu h2').append('<span class="question"><img src="'+questionImg+'" alt="" /></span>');
	var popupContent = $('#how-to-use-map').html();
	$('#how-to-use-map').remove();
	
	$('.map-menu h2 span.question').hover(
		function() {
			$(this).find('img').attr('src',questionImgRollover);
			$(this).append('<div class="info-window-wrapper"><div class="info-window">'+popupContent+'</div></div>');
			$('.map-menu select').hide();
		},
		function() {
			$(this).find('img').attr('src',questionImg);
			$(this).find('.info-window-wrapper').remove();
			$('.map-menu select').show();
		}
	);
}

function setupMapUse2()
{
	$('.modulequestion h1').append('<span class="question"><img src="'+questionImg+'" alt="" /></span>');
	var popupContent = $('#how-to-use-map').html();
	$('#how-to-use-map').remove();
	
	$('.modulequestion h1 span.question').hover(
		function() {
			$(this).find('img').attr('src',questionImgRollover);
			$(this).append('<div class="info-window-wrapper"><div class="info-window">'+popupContent+'</div></div>');
			$('.modulequestion select').hide();
		},
		function() {
			$(this).find('img').attr('src',questionImg);
			$(this).find('.info-window-wrapper').remove();
			$('.modulequestion select').show();
		}
	);
}

function observeSearch()
{
	$('.gsc-input').hide();	
}

function showVideoWarning() 
{
	var height = $('.video-warning').height();
	var width  = $('.video-warning').width();
	
	$('.video-warning').append('<div class="overlay" style="width: '+width+'px; height: '+height+'px;"><div class="warning"><p>You must be over 18 to view this video</p><p><a href="#">Ok</a></p></div></div>');
	$('.overlay a').click(
		function() {
	        $('.overlay').remove();
	        return false; 
		}
	);
}


function showBcoveVideoWarning(height,width) {
//    var height = $('.video-warning').height();
//    var width = $('.video-warning').width();

    $('.video-warning').append('<div class="overlay" style="width: ' + width + 'px; height: ' + height + 'px;"><div class="warning"><p>You must be over 18 to view this video</p><p><a href="#">Ok</a></p></div></div>');
    $('.overlay a').click(
		function() {
            $('.overlay').remove();
            brightcove.createExperiences();
		    return false;
		}
	);
}

function setUpAudioPlayer() {
    var myPlayList = new Array();
    var playItem = 0;

    // Add all the radio ads to a playlist
    $('.radio-ads li').each(function() {
        title = $(this).find('a').text();
        mp3 = $(this).find('a').attr('href');
        myPlayList[myPlayList.length] = { name: title, mp3: mp3 };
    });
    $('.radio-ads .module').html(jPlayer);

    // Local copy of jQuery selectors, for performance.
    var jpPlayTime = $("#jplayer_play_time");
    var jpTotalTime = $("#jplayer_total_time");
    var jpStatus = $("#demo_status"); // For displaying information about jPlayer's status in the demo page

    $("#jquery_jplayer").jPlayer({
        ready: function() {
            displayPlayList();
            playListInit(false); // Parameter is a boolean for autoplay.
            //demoInstanceInfo(this.element, $("#demo_info")); // This displays information about jPlayer's configuration in the demo page
        },
        oggSupport: false,
        swfPath: '/Templates/RSA/js/'
    })
	.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
	    jpPlayTime.text($.jPlayer.convertTime(playedTime));
	    jpTotalTime.text($.jPlayer.convertTime(totalTime));

	    demoStatusInfo(this.element, jpStatus); // This displays information about jPlayer's status in the demo page

	})
	.jPlayer("onSoundComplete", function() {
	    playListNext();
	});

    $("#jplayer_previous").click(function() {
        playListPrev();
        return false;
    });

    $("#jplayer_next").click(function() {
        playListNext();
        return false;
    });

    function displayPlayList() {
        for (i = 0; i < myPlayList.length; i++) {
            $("#jplayer_playlist ul").append("<li id='jplayer_playlist_item_" + i + "'>" + myPlayList[i].name + "</li>");
            $("#jplayer_playlist_item_" + i).data("index", i).click(function() {
                var index = $(this).data("index");
                if (playItem != index) {
                    playListChange(index);
                } else {
                    $("#jquery_jplayer").jPlayer("play");
                }
            });
        }
    }

    function playListInit(autoplay) {
        if (autoplay) {
            playListChange(playItem);
        } else {
            playListConfig(playItem);
        }
    }

    function playListConfig(index) {
        $("#jplayer_playlist_item_" + playItem).removeClass("jplayer_playlist_current");
        $("#jplayer_playlist_item_" + index).addClass("jplayer_playlist_current");
        playItem = index;
        $("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3);
    }

    function playListChange(index) {
        playListConfig(index);
        $("#jquery_jplayer").jPlayer("play");
    }

    function playListNext() {
        var index = (playItem + 1 < myPlayList.length) ? playItem + 1 : 0;
        playListChange(index);
    }

    function playListPrev() {
        var index = (playItem - 1 >= 0) ? playItem - 1 : myPlayList.length - 1;
        playListChange(index);
    }
}

/*
===========================================
  Log virtual page view
=========================================== 
*/

function pgView(url)
{
	if (typeof pageTracker != 'undefined') {
		pageTracker._link(url);
		return true;
	}
	else if (typeof urchinTracker != 'undefined') {
		__utmLinker(url);
		return true;
	}
	return false;
}
/*
===========================================
  Clearform
=========================================== 
*/
function clearForm() {
  // iterate over all of the inputs for the form
  // element that was passed in
	$('form :input').each(function() {
 var type = this.type;
 var tag = this.tagName.toLowerCase(); // normalize case
 // it's ok to reset the value attr of text inputs,
 // password inputs, and textareas
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = "";
 // checkboxes and radios need to have their checked state cleared
 // but should *not* have their 'value' changed
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 // select elements need to have their 'selectedIndex' property set to -1
 // (this works for both single and multiple select elements)
 else if (tag == 'select')
   this.selectedIndex = 0;
  });
  
  //Clear validation styles
  ClearValidatorCallouts();
  HideValidators();
  
  //Initialise any values
  setInitials();
};

function setInitials() {
    
    if ($('#ctl00_MainContentRegion_ComplaintsForm1_contactEmail').length > 0) {
        $('#ctl00_MainContentRegion_ComplaintsForm1_contactEmail').click();
    }
    
    if ($('#ctl00_MainContentRegion_FeedbackForm1_contactEmail').length > 0) {
        $('#ctl00_MainContentRegion_FeedbackForm1_contactEmail').click();
    }
}

/*
===========================================
  Custom Validation
=========================================== 
*/
function ValidateDriverNumber(source, args)
{

    var ddl = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_complaintType');
    var text = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_driverNumber')
    
    if(ddl.selectedIndex == 1) {
      if(text.value.trim() == "")
         args.IsValid = false;
      else
         args.IsValid = true;
   }
}

function ValidateRegistration(source, args)
{

    var ddl = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_complaintType');
    var text = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_carReg')
    
    if(ddl.selectedIndex == 2) {
      if(text.value.trim() == "")
         args.IsValid = false;
      else
         args.IsValid = true;
   }
}

function ValidateWebsite(source, args)
{

    var ddl = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_complaintType');
    var text = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_webPage')
    
    if(ddl.selectedIndex == 6) {
      if(text.value.trim() == "")
         args.IsValid = false;
      else
         args.IsValid = true;
   }
}

function ValidateComplaintsEmail(source, args)
{
    var text = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_email')
    
    if ($("input[name='ctl00$MainContentRegion$ComplaintsForm1$communicMethod']:checked").val() == 'email')
    {
        if(text.value.trim() == "")
            args.IsValid = false;
        else
            args.IsValid = true;
    }
}

function ValidateComplaintsAddress(source, args)
{
    var text = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_add1')
    
    if ($("input[name='ctl00$MainContentRegion$ComplaintsForm1$communicMethod']:checked").val() == 'post')
    {
        if(text.value.trim() == "")
            args.IsValid = false;
        else
            args.IsValid = true;
    }
}

function ValidateFeedbackEmail(source, args)
{

    var text = document.getElementById('ctl00_MainContentRegion_FeedbackForm1_email')
    
    if ($("input[name='ctl00$MainContentRegion$FeedbackForm1$communicMethod']:checked").val() == 'email')
    {
        if(text.value.trim() == "")
            args.IsValid = false;
        else
            args.IsValid = true;
    }
}

function ValidateFeedbackAddress(source, args)
{
    var text = document.getElementById('ctl00_MainContentRegion_FeedbackForm1_add1')
    
    if ($("input[name='ctl00$MainContentRegion$FeedbackForm1$communicMethod']:checked").val() == 'post')
    {
        if(text.value.trim() == "")
            args.IsValid = false;
        else
            args.IsValid = true;
    }
}

function showdetails(showHideDiv, switchTextDiv)
{
    var ele = document.getElementById(showHideDiv);
    var text = document.getElementById(switchTextDiv);
     
    if (ele.style.display == 'block')
    {
        ele.style.display = 'none';
        text.innerHTML = '<img src="/Templates/RSA/Images/plus.gif" alt="open" />';
    }
    else
    {
        ele.style.display = 'block';
        text.innerHTML = '<img src="/Templates/RSA/Images/minus.gif" alt="close" />';
    }
}


function ValidateCaptcha(source, args)
{

    var ddl = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_complaintType');
    var text = document.getElementById('ctl00_MainContentRegion_ComplaintsForm1_driverNumber')
    
    if(ddl.selectedIndex == 1) {
      if(text.value.trim() == "")
         args.IsValid = false;
      else
         args.IsValid = true;
   }
}

function showorhidediv(div)
{
    var ele = document.getElementById(div);
     
    if (ele.style.display == 'block')
    {
        ele.style.display = 'none';
    }
    else
    {
        ele.style.display = 'block';
    }
}
