// Avoid FOUC 
var elements = document.getElementsByTagName("html");
elements[0].className += " JSEnabled"


    function delayOAS()
    {
        var positions = OAS_listpos.split(',');

        var count = positions.length;

        for (var i = 0; i < count; i++)
        {
            var from = document.getElementById('OAS_d_'+positions[i]);
            var to   = document.getElementById('OAS_'+positions[i]);
            if (to !== null && from !== null)
            {
                if (checkFrom(from))
                {
                    to.appendChild(from);
                    from.style.visibility = "visible";
                }
                else
                {
                    $(to).remove();
                    $(from).remove();
                }
            }
        }
    }

    function checkFrom(from)
    {
        var c = $(from).find('img').attr('src');
        if (typeof(c) != "undefined" && c.indexOf('empty.gif') !== -1)
            return false;
        return true;
        
    }

    // load a panel from ajax
    // panelName is the internal name,
    // id is the name of the dom object to replace
    // params and values should be a matched array of paramaters and their values
    function loadPanels(panelName, id, params, values)
    {
        // get a url
        var url = '/resources/ph/'+panelName+'/?id='+id;

        // if we have some params, we can add them to the url
        if (params.length > 0)
        {
            for(i=0;i<params.length;i++)
            {
                url = url + '&'+params[i];
                url = url + '='+encodeURI(values[i]);
            }
        }

        // create a new Ajax Request
        // if it fails, we do not care
        
        $.ajax(
            {
                type: 'GET',
                url: url,
                success: success
            }
        );
    }
    function loadBallotPanel(url)
    {
        $.ajax(
            {
                type: 'GET',
                url: url,
                success: success
            }
        );
    }

    // we have a success, so we split the
    // string.  Could use xml here, but it seems over the top
    //
    function success(response)
    {
        // get the string
        var string = response;

        // split it into the id and the html
        var strings = string.split('|||');

        var id = strings[0];
        var html = strings[1];

        // set the id to the html
        $('#'+id).html(html);

        // check to see if we need tabs running
        // for most read and events live travel
        if (id.indexOf('MostReadAndCommented') > 0)
        {
            $(".commentsRead").tabs();
        }
        else if (id.indexOf('EventsLiveTravelPanel') > 0)
        {
            if ($('#li-first').html() == '1')
            {
                $(".whatsTravel").tabs({selected: 1});
            }
            else
            {
                $(".whatsTravel").tabs();
            }
        }
    }

function write_html(msg,id)
{
    $('#'+id).html(msg);
}
function showPic(whichpic) 
{
    var source = whichpic.getAttribute('id');
    var mainPic = parent.document.getElementById('picsNtxt');
    mainPic.setAttribute('class',source);
}

function showTxt(whichtxt) 
{
    var source = whichtxt.getAttribute('class');
    var mainTxt = parent.document.getElementById('para');
    mainTxt.setAttribute('class',source);
}

function revertTxt(prevtxt) 
{
    var source = prevtxt.getAttribute('id');
    var thetxt = parent.document.getElementById('para');
    thetxt.setAttribute('class',source);
}

function popUp(strURL, strWidth, strHeight, otherOptions) 
{
    var strOptions="";
    strOptions="'width="+strWidth+",height="+strHeight+","+otherOptions+"'";
    window.open(strURL, 'newWin2', strOptions);
}


function panelSwitcher(switchto,divIdOne,divIdTwo,divIdThree,firstLink,secondLink,thirdLink)
{
    // switchto MUST be one of (first|second), referring to itself(link)
    // switcher links MUST have IDs (link_one|link_two)
    var firstPanel  = document.getElementById(divIdOne);
    var secondPanel = document.getElementById(divIdTwo);
    var thirdPanel = document.getElementById(divIdThree);
    var firstLink   = document.getElementById(firstLink);
    var secondLink  = document.getElementById(secondLink);
    var thirdLink  = document.getElementById(thirdLink);
        
        
    switch(switchto)
    {
        case 'third':
            firstPanel.style.visibility     = 'hidden';
            firstPanel.style.display        = 'none';
            secondPanel.style.visibility    = 'hidden';
            secondPanel.style.display       = 'none';
            thirdPanel.style.visibility     = 'visible';
            thirdPanel.style.display        = 'block';
            firstLink.className             = 'off';
            secondLink.className            = 'off';
            thirdLink.className             = 'active_on';
            break;
        case 'second':
            firstPanel.style.visibility     = 'hidden';
            firstPanel.style.display        = 'none';
            secondPanel.style.visibility    = 'visible';
            secondPanel.style.display       = 'block';
            thirdPanel.style.visibility     = 'hidden';
            thirdPanel.style.display        = 'none';
            firstLink.className             = 'off';
            secondLink.className            = 'active_on';
            thirdLink.className             = 'off';
            break;
        case 'first':
            firstPanel.style.visibility     = 'visible';
            firstPanel.style.display        = 'block';
            secondPanel.style.visibility    = 'hidden';
            secondPanel.style.display       = 'none';
            thirdPanel.style.visibility     = 'hidden';
            thirdPanel.style.display        = 'none';
            firstLink.className             = 'active_on';
            secondLink.className            = 'off';
            thirdLink.className             = 'off';
            break;
    }
}

function panelSwitcher2(switchto,ids)
{
    // @param switchto - is an integer
    // @param ids      - is an array of ids
    // @param links    - is an array of links
    
    for (var a=0; a<ids.length; a++)
    {
       if (switchto==a)
       {
           // this is the one that we want to switch on
           var panel = document.getElementById(ids[a]);
           panel.style.visibility       = 'visible';
           panel.style.display          = 'block';
       }
       else
       {
           // hide the others
           var panel = document.getElementById(ids[a]);
           panel.style.visibility       = 'hidden';
           panel.style.display          = 'none';
       }
    }
}


var prompt_start        = 'Enter the text to be formatted';
var text_enter_url      = 'Enter the complete URL for the hyperlink';
var image_enter_url     = 'Enter the complete URL to the image';
var text_enter_url_name = 'Enter the title of the webpage';
var text_enter_email    = 'Enter the email address';
var error_no_url        = 'You must enter a URL';
var error_no_image      = 'You must enter a URL for the image';
var error_no_title      = 'You must enter a title';
var error_no_subject    = 'You must enter a subject';
var error_no_comments   = 'You must enter your comments';
var help_bold           = 'Inserts Bold Text';
var help_italic         = 'Inserts Italic Text';
var help_under          = 'Inserts Underlined Text';
var help_url            = 'Inserts Hyperlink';
var help_email          = 'Inserts Email Address';
var help_quote          = 'Inserts Quoted Text';
var help_image          = 'Inserts an image';
var help_break          = 'Inserts a break tag, everything above the tag will be shown on the main page, and a link to more added';

  function helpmsg(msg)
  {
    msg=eval( "help_" + msg );
    write_html(msg,'help');
  }

function do_tag(thetag) 
{
    doInsert("[" + thetag + "]","[/" + thetag + "]",thetag);
}
  
function tag_break() 
{
    doInsert("[break]","",'');
}

function tag_url()
{
    var FoundErrors = '';
    var enterURL   = prompt(text_enter_url, "http://");
    var enterTITLE = prompt(text_enter_url_name, "My Website");

    if (!enterURL) {
      FoundErrors += " " + error_no_url;
    }
    if (!enterTITLE) {
      FoundErrors += " " + error_no_title;
    }
    if (FoundErrors) {
      alert("Error!"+FoundErrors);
      return;
    }
    doInsert("[URL="+enterURL+"]","[/URL]",enterTITLE);
  }
function tag_email()
{
    var emailAddress = prompt(text_enter_email, "");
    if (!emailAddress) 
    {
        alert(error_no_email);
        return;
    }
    doInsert("[EMAIL]",'[/EMAIL]',emailAddress);
}

function tag_image()
{
    var imageAddress = prompt(image_enter_url, "");
    if (!imageAddress) 
    {
        alert(error_no_image);
        return;
    }
    doInsert("[IMG]",'[/IMG]',imageAddress);
}

// Determine browser type and stuff.
// Borrowed from http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var myAgent   = navigator.userAgent.toLowerCase();
var myVersion = parseInt(navigator.appVersion);

var is_ie   = ((myAgent.indexOf("msie") != -1)  && (myAgent.indexOf("opera") == -1));
var is_nav  = ((myAgent.indexOf('mozilla')!=-1) && (myAgent.indexOf('spoofer')==-1)
                && (myAgent.indexOf('compatible') == -1) && (myAgent.indexOf('opera')==-1)
                && (myAgent.indexOf('webtv') ==-1)       && (myAgent.indexOf('hotjava')==-1));

var is_win   =  ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));
var is_mac    = (myAgent.indexOf("mac")!=-1);
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1));
var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
if (clientPC.indexOf('opera') != -1) {
    var is_opera = true;
    var is_opera_preseven = (window.opera && !document.childNodes);
       var is_opera_seven = (window.opera && document.childNodes);
}
function doInsert(tagOpen, tagClose, sampleText) 
{
    var txtarea = document.getElementById('c_comment');
    tagClose+=' ';
    // IE
    if (document.selection  && !is_gecko) 
    {
        var theSelection = document.selection.createRange().text;
        if (!theSelection)
            theSelection=sampleText;
        txtarea.focus();
        if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
            theSelection = theSelection.substring(0, theSelection.length - 1);
            document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
        } 
        else 
        {
            document.selection.createRange().text = tagOpen + theSelection + tagClose;
        }
    // Mozilla
    } 
    else if(txtarea.selectionStart || txtarea.selectionStart == '0') 
    {
        var replaced = false;
        var startPos = txtarea.selectionStart;
        var endPos = txtarea.selectionEnd;
        if (endPos-startPos)
            replaced = true;
        var scrollTop = txtarea.scrollTop;
        var myText = (txtarea.value).substring(startPos, endPos);
        if (!myText)
            myText=sampleText;
        if (myText.charAt(myText.length - 1) == " ") 
        { // exclude ending space char, if any
            subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
        } 
        else 
        {
            subst = tagOpen + myText + tagClose;
        }
        txtarea.value = txtarea.value.substring(0, startPos) + subst +  txtarea.value.substring(endPos, txtarea.value.length);
        txtarea.focus();
        //set new selection
        if (replaced) 
        {
            var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
            txtarea.selectionStart = cPos;
            txtarea.selectionEnd = cPos;
        } 
        else 
        {
            txtarea.selectionStart = startPos+tagOpen.length;
            txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
        }
        txtarea.scrollTop = scrollTop;

    }
    // reposition cursor if possible
    if (txtarea.createTextRange)
        txtarea.caretPos = document.selection.createRange().duplicate();
}

function quote_post(pvId,elId,name)
{
    var contents=document.getElementById(elId).innerHTML;
    var preview=document.getElementById(pvId).innerHTML;
    var display_contents="<p>Quote:</p><blockquote><p><b>"+name+"</b> wrote:<br />"+preview+"</p></blockquote><a href='javascript:remove_quote();'>Remove quote</a>";
    var quote_contents="[quote][p][bold]"+name+"[/bold] wrote:\n"+contents+"[/p][/quote]";
    var element=document.getElementById('c_quote')
    element.value=quote_contents;
    var destination=document.getElementById('c_quotepreview');
    destination.innerHTML=display_contents;
    document.getElementById('comments').focus();
}

function remove_quote()
{
    document.getElementById('c_quote').value='';
    document.getElementById('c_quotepreview').innerHTML='';
    document.getElementById('comments').blur();
}

function toggleById(elId)
{
    $('#'+elid).toggle();
}

function rotateTextIn(elId, sources, linkobj, startlinktxt, endlinktxt)
{
   // First element is the Id of the destination tag, sources is the id of the parent tag containing all the <div> tags acting as sources that 
   // will rotate one by one. Comparison is done by string so be careful on what you put there...
   // Usage:
   // <div id="comment_1">Text 1</quote>
   // <a href="javascript:rotateTextIn('comment_1','comment_1_sources',this,'More &#187;','&#188; Less');">More &#187;</a>
   // NOTE: More link will appear only on indexes < totalnumberofindexes. Otherwise it will change to Less
   // <span id="comment_1_sources" style="display:none; height:0px;">
   //   <span row="set">Text 1</span>
   //   <span row="set">Text 2</span>
   //   <span row="set">Text 3</span>
   //   <span row="set">... so on....</span>
   // </span>
   // Special Note: IE likes to add a space character if the innerHTML works with other HTML tags within itself...
   // So we need to escape everything, and remove %20 to actually compare stuff properly... FF and Opera do not have that issue

   var obj=document.getElementById(elId);
   var sources=document.getElementById(sources).getElementsByTagName("span");

   var all_texts = new Array();
   var cur_text = obj.innerHTML.replace(/<.*?>|\s|\W|\n|\r|\t/g,"");
   var cur_index = 0;
   // read all the texts and check which one we already have
   for (a=0; a<sources.length; a++)
   {
       if (sources[a].getAttribute('row')=='set')
       {
           var thissource=sources[a].innerHTML.replace(/<.*?>|\s|\W|\n|\r|\t/g,"");
           all_texts[all_texts.length]=sources[a].innerHTML;
           if (cur_text==thissource)
           {
              cur_index=all_texts.length-1;
           }
       }
   }
   var howmany=all_texts.length-1;
   var current= cur_index;

   if (howmany > 0)
   {
      // set the text
      if (howmany > cur_index)
      {
         // index in the middle
         obj.innerHTML = all_texts[cur_index+1];
         current++;
      }
      if (howmany == cur_index)
      {
         // index at the end, so jump to the begining
         obj.innerHTML = all_texts[0];
         current=0;
      }

      // set the link text
      if (howmany > current)
      {
         linkobj.innerHTML=startlinktxt;
      }
      else
      {
         linkobj.innerHTML=endlinktxt;
      }
   }
   // if we do not have any sources, do not do anything
}

// flash functions
function sendEvent(swf,typ,prm) 
{ 
    thisMovie(swf).sendEvent(typ,prm); 
};

function getUpdate(typ,pr1,pr2,swf) {};

function thisMovie(swf) 
{
   var obj = document.getElementById(swf);
   return obj;
};

function loadFile(swf,obj) 
{ 
    thisMovie(swf).loadFile(obj); 
};

function showVid(playlist,thumbnail)
{
    var pObj = {file: playlist, image: thumbnail, width: 313, height: 263, repeat: 'true', shuffle: 'false', showstop: 'false'};
    loadFile('pic1',pObj);
    
};

function showSoundslide(soundslide,thumbnail)
{
    var pObj = {file: soundslide, image: thumbnail, width: 313, height: 263, repeat: 'true', shuffle: 'false', showstop: 'false'};
    loadFile('pic1',pObj);
    
};

function createplayer(theFile, go)
{
    var s = new SWFObject("/resources/flash/flashplayer_as3_sm.swf/","pic1","313","268","9");
    so.addParam("allowfullscreen","true");
    so.addVariable("file",theFile);
    so.addVariable("width","313");
    so.addVariable("height","268");
    so.addVariable("shuffle","false");
    so.addVariable("repeat","always");
    so.addVariable("thumbsinplaylist","true");
    if (go) { so.addVariable("autostart","false"); }
    so.write("flashPlayer");
}

function playMp3(mp3file,id)
{
    //var thumbnail = '';
    //var pObj = {file: mp3file, image: thumbnail, width:140, height: 20, repeat: 'false', autostart: 'true'};
    //loadFile('mp3',pObj);
    //player.sendEvent("PLAY");
    //setTimeout("thisMovie('mp3player').sendEvent('playitem', 0)", 3000);
    thisMovie(id).sendEvent('playpause','true');
}

// Classified search form validation
function validate_search(aField)
{
    var eField = aField.LOCATION;
    if(!eField)
        return true;
    if(eField.value == '' || eField.value == 'Town, County or Postcode')
    {
        alert("You must fill in the Location field!");
        eField.focus();
        eField.value = '';
        return false;
    }
    return true;
}

function redirect(obj)
{
    var url = obj.options[obj.selectedIndex].value; 
    if (url !== '')
    {
        window.location = url;
    }
}

function createGMTDate()
{
   var tdate = new Date();
   var today = new Date(tdate.toGMTString());
   var w = today.getDay();
   var m = today.getMonth();
   var y = today.getFullYear();
   var d = today.getDate();
   var day = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
   var month = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

   // get a textural representation of the month
   m = month[m];
   w = day[w];

   // format a date string
   var newDate = w + ', ' + d + ' ' + m + ' ' + y;

   // write it to the correct id
   $('#time').html(newDate);
}

function startFeaturedJobsScroller()
{
	var featured_jobs_scroller = document.getElementById('scrolling_featured_jobs');
	
	/* Count all the li tags within and do not initiate the scroller if the number is smaller than 6 jobs */
	var count = $('#scrolling_featured_jobs li').length;
	
	if ((featured_jobs_scroller != null) && (count > 6))
    {
    	var scrolling_featured_jobs = new Scroller(featured_jobs_scroller, 'up', 100);
   	    scrolling_featured_jobs.run();
    }
}
            
// jQuery Auto start functions
$(document).ready(function()
{
    // Initialize Autocompleters
	$("#Site-search").autocomplete("/search/autoSiteSearch/jQuery/", { minChars: 3, cacheLength: 20 });
    $("#LocationjQuery").autocomplete("/resources/location-auto-complete/", { minChars: 3, cacheLength: 20, width: '250px' });
    // $("#LocationjQuery").autocomplete("/homes/completionlistjQuery/", { minChars: 3, cacheLength: 20, width: '250px', delay: 100 });

    // start job scroller
    var tt = setTimeout("startFeaturedJobsScroller()", 3000);

	// Generic search field clearing on focus
		$.fn.clearform = function() {
			return this.focus(function() {
				if( $(this).val().indexOf("e.g.") > -1 ) { // previously if( this.value == this.defaultValue ) {
					this.value = "";
				}
			}); /*.blur(function() { //reinstates default value on blur
				if( !this.value.length ) {
					this.value = this.defaultValue;
				}
			}); */
		};
	// Clear form inputs for user account pages
	$("#userAccount input:text").clearform();
	
	// Search results 'relevant sections' toggle
	if ($('.searchRelSecListMore').length > 0) 
	{
		// $('.searchRelSecListMore').hide();
		// $('.searchRelSecList').append('<li class="searchRelShowHide">Show more sections</li>');
		$('.searchRelShowHide').toggle(
			function() {
				$('.searchRelSecListMore').slideToggle();
				$(this).text('Show fewer sections');
			},
			function() {
				$('.searchRelSecListMore').slideToggle();
				$(this).text('Show more sections');
			}
        );
	}
	
	// Share links on article pages (excluding families)
    $('.articleShareBox').addClass('popBox');
    var shareBoxHtml = $('.articleShareBox').removeAttr('id').wrap('<div></div>').parent().html();
	$('.articleShareBox').parent().remove();
	$('.articleUtilShare a').removeAttr('href').click(
        function() {
            var checkBoxExists = $(this).next('div').html();
			if (!checkBoxExists) {
				$(this).parent().append(shareBoxHtml).find('div').toggle();
				toggleShare();
			} else {
				$(this).next('div').toggle();
				toggleShare();
			}
		}
	);
	// ShareBox hide
	function toggleShare() { 
        $('.articleShareBox span').click(function() {
            $(this).parent().hide();
		});
	};

    /* Share links on family pages - why do we need to have this separated?
    $('.shareBox').addClass('popBox');
    var shareBoxHtmlFamily = $('.shareBox').removeAttr('id').wrap('<div></div>').parent().html();
    $('.shareBox').parent().remove();
    $('.noticeUtilShare a').removeAttr('href').click(
        function() {
            var checkBoxExists = $(this).next('div').html();
            if (!checkBoxExists) {
                $(this).parent().append(shareBoxHtmlFamily);
                toggleFamiliesShare();
            } else {
                $(this).next('div').show();
                toggleFamiliesShare();
            }
        }
    );
    
    // ShareBox hide
    function toggleFamiliesShare() { 
        $('.shareBox span').click(function() {
            $(this).parent().hide();
        });
    };
	*/

    // JOB SECTOR TOGGLE
    $("#myJobsSearch .sectorToggle").show();
    $("#myJobsSearch .sectorToggle").click(function() {
         if (!$(this).is(".allSelected")) {
             $(this).next().children().children("input").attr("checked", "checked");
             $(this).addClass("allSelected").html("Deselect all &#187;");
         } else {
             $(this).next().children().children("input").removeAttr("checked");
             $(this).removeClass("allSelected").html("Select all &#187;");
         }
    });
    	
	// Families (old NetMums) pages - FaceBox initialize
	if ($('a[rel*=facebox]').length > 0)
	{
	   $('a[rel*=facebox]').facebox();
    }

    // HOMES/JOB SEARCH FUNCTIONS
    $("#myHomesSearch .searchOptions .sale").click(function() {
        $(this).addClass("on");
        $("#myHomesSearch .searchOptions .rent").removeClass("on");
        $("#myHomesSearch #homeSale").css({"display":"block"});
        $("#myHomesSearch #homeRent").css({"display":"none"});
    });
    
    $(".searchOptions .rent").click(function() {
        $(this).addClass("on");
        $("#myHomesSearch .searchOptions .sale").removeClass("on");
        $("#myHomesSearch #homeRent").css({"display":"block"});
        $("#myHomesSearch #homeSale").css({"display":"none"});
    });

    $("#_eventId_continue").click(function()
    {
        if($("#terms:checked").length == 1)
        {
            $("#cvUploadStep1").submit();
        }
        else
        {
            $("#unticked").removeClass('none');
        }
    });   


    $('#salaryFrequencyId').change(function(){
        var baseSalary = 0;
        var diffSalary = 0;
        
        if($(this).val() == 1)
        {
            baseSalary = 5;
            diffSalary = 1;
        }
        if($(this).val() == 2)
        {
            baseSalary = 25;
            diffSalary = 5;
        }
        if($(this).val() == 3)
        {
            baseSalary = 50;
            diffSalary = 50;
        }
        if($(this).val() == 4)
        {
            baseSalary = 250;
            diffSalary = 250;
        }
        if($(this).val() == 5)
        {
            baseSalary = 5000;
            diffSalary = 5000;
        }
        if(baseSalary > 0)
        {
            var htmlReplacement = '<option value="">Please select a salary</option>';
            for(var i = 0; i < 20; i++)
            {
                var salary = baseSalary + (i*diffSalary);
                formatted = ''+salary;
                if(salary > 999)
                {
                    var under = salary % 1000;
                    var over  = Math.floor(salary/1000);
                    under = ''+under;
                    while(under.length < 3)
                    {
                        under = '0'+under;
                    }
                     
                    formatted = over+','+under;
                }
                htmlReplacement = htmlReplacement+'<option value="'+salary+'">&pound;'+formatted+'</option>';
                if(i > 4)
                {
                    i++;
                }
            }
            $('#desiredSalaryMinimum, #desiredSalaryMaximum').html(htmlReplacement);
        }
    });
	
	// 'Send your news' form highlight current field
	if ($(".sendYourNewsForm").length > 0 ) focusHighlight();
	function focusHighlight() {
		$("input[type=text],input[type=file],textarea,select").focus(function() {
			$(this).parent().addClass("formFocus");
		});
		$("input[type=text],input[type=file],textarea,select").blur(function() {
			$(this).parent().removeClass("formFocus");
		});
		
		$("input[type=radio]").focus(function() {
			$(this).parent().parent().addClass("formFocus");
		});
		$("input[type=radio]").blur(function() {
			$(this).parent().parent().removeClass("formFocus");
		});
	}
	
	// 'Send your news' image increment
	if ($('.sendYourNewsForm').length > 0) {
		$('.sendYourNewsPhotos ul li:gt(1)').hide();
		$('.sendYourNewsPhotos').append('<p class="sendYourNewsAdd"><a href="#sendYourNews">Add another photo</a></p>');
		
		$('.sendYourNewsAdd a').click(function() { 
			$('.sendYourNewsPhotos ul li:not(:visible):lt(2)').slideDown();
			if ($('.sendYourNewsPhotos ul li:not(:visible)').length == 0) $('.sendYourNewsAdd').fadeOut('slow', function() { $(this).remove(); });
			return false;
		});
	}
	
	// 'Send your news' validation
	if ($('.sendYourNewsForm').length > 0) {
		if ($('.validateError').length == 0) $('.sendYourNewsForm').prepend('<div class="validateError" style="display: none;"><h4>Sorry, it appears some details are missing or incorrect.</h4><ul></ul></div>');
	
		$('.sendYourNewsForm').validate({
			ignoreTitle: true,
			errorContainer: ".validateError",
			errorLabelContainer: ".validateError ul",
			wrapper: "li",
			errorClass: "fieldInvalid",
			highlight: function(element, errorClass) {
				$(element).addClass(errorClass);
				$(element.form).find("label[for=" + element.id + "]").parent()
						.addClass(errorClass);
			},
			unhighlight: function(element, errorClass) {
				$(element).removeClass(errorClass);
				$(element.form).find("label[for=" + element.id + "]").parent()
						.removeClass(errorClass);
			},
			
			rules: {
				name: {
					required: true,
					minlength: 2
				},
				email: {
					required: true,
					email: true
				},
				telephone: {
					required: true,
					phoneUK: true
				},
				headline: {
					required: true,
					minlength: 5
				},
				body: {
					required: true,
					minlength: 20
				},
				image1: {
					required: false,
					accept: "png|gif|jpg|jpeg"
				},
				caption1: {
					required: function(element) {
						return $("#image1").val().length > 0;
					},
					minlength: 2
				},
				image2: {
					required: false,
					accept: "png|gif|jpg|jpeg"
				},
				caption2: {
					required: function(element) {
						return $("#image2").val().length > 0;
					},
					minlength: 2
				},
				image3: {
					required: false,
					accept: "png|gif|jpg|jpeg"
				},
				caption3: {
					required: function(element) {
						return $("#image3").val().length > 0;
					},
					minlength: 2
				},
				image4: {
					required: false,
					accept: "png|gif|jpg|jpeg"
				},
				caption4: {
					required: function(element) {
						return $("#image4").val().length > 0;
					},
					minlength: 2
				},
				recaptcha_response_field: {
					required: true
				}

			},
			
			messages: {
				name: {
					required: "Please specify your <strong>name</strong>",
					minlength: jQuery.format("Your <strong>name</strong> should have at least {0} characters")
				},
				email: {
					required: "Please specify your <strong>email address</strong>",
					email: "Your <strong>email address</strong> must be in the format name@domain.com"
				},
				telephone: {
					required: "Please specify a <strong>telephone</strong> or mobile number",
					phoneUK: "Please enter a valid UK <strong>telephone</strong> number"
				},
				headline: {
					required: "Please specify a <strong>title or headline</strong> for your story",
					minlength: jQuery.format("Please enter a meaningful <strong>title or headline</strong> for your story")
				},
				body: {
					required: "Don't forget to include your <strong>story</strong>",
					minlength: jQuery.format("Your <strong>story</strong> should probably be a little longer")
				},
				image1: {
					accept: "Your <strong>photo 1</strong> should be in jpg, gif or png format"
				},
				caption1: {
					required: "Please specify a <strong>caption</strong> for photo 1",
					minlength: jQuery.format("The <strong>caption</strong> for photo 1 should have at least {0} characters")
				},
				image2: {
					accept: "Your <strong>photo 2</strong> should be in jpg, gif or png format"
				},
				caption2: {
					required: "Please specify a <strong>caption</strong> for photo 2",
					minlength: jQuery.format("The <strong>caption</strong> for photo 2 should have at least {0} characters")
				},
				image3: {
					accept: "Your <strong>photo 3</strong> should be in jpg, gif or png format"
				},
				caption3: {
					required: "Please specify a <strong>caption</strong> for photo 3",
					minlength: jQuery.format("The <strong>caption</strong> for photo 3 should have at least {0} characters")
				},
				image4: {
					accept: "Your <strong>photo 4</strong> should be in jpg, gif or png format"
				},
				caption4: {
					required: "Please specify a <strong>caption</strong> for photo 4",
					minlength: jQuery.format("The <strong>caption</strong> for photo 4 should have at least {0} characters")
				},
				recaptcha_response_field: {
					required: "Please enter the security words"
				}
			}

		});
	
	}

}); //END jQuery 


/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept == "undefined") var deconcept = new Object();
if(typeof deconcept.util == "undefined") deconcept.util = new Object();
if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) {
    if (!document.getElementById) { return; }
    this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
    this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
    this.params = new Object();
    this.variables = new Object();
    this.attributes = new Array();
    if(swf) { this.setAttribute('swf', swf); }
    if(id) { this.setAttribute('id', id); }
    if(w) { this.setAttribute('width', w); }
    if(h) { this.setAttribute('height', h); }
    if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
    this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
    if (!window.opera && document.all && this.installedVer.major > 7) {
        // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
        deconcept.SWFObject.doPrepUnload = true;
    }
    if(c) { this.addParam('bgcolor', c); }
    var q = quality ? quality : 'high';
    this.addParam('quality', q);
    this.setAttribute('useExpressInstall', false);
    this.setAttribute('doExpressInstall', false);
    var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
    this.setAttribute('xiRedirectUrl', xir);
    this.setAttribute('redirectUrl', '');
    if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
}
deconcept.SWFObject.prototype = {
    useExpressInstall: function(path) {
        this.xiSWFPath = !path ? "expressinstall.swf" : path;
        this.setAttribute('useExpressInstall', true);
    },
    setAttribute: function(name, value){
        this.attributes[name] = value;
    },
    getAttribute: function(name){
        return this.attributes[name];
    },
    addParam: function(name, value){
        this.params[name] = value;
    },
    getParams: function(){
        return this.params;
    },
    addVariable: function(name, value){
        this.variables[name] = value;
    },
    getVariable: function(name){
        return this.variables[name];
    },
    getVariables: function(){
        return this.variables;
    },
    getVariablePairs: function(){
        var variablePairs = new Array();
        var key;
        var variables = this.getVariables();
        for(key in variables){
            variablePairs[variablePairs.length] = key +"="+ variables[key];
        }
        return variablePairs;
    },
    getSWFHTML: function() {
        var swfNode = "";
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "PlugIn");
                this.setAttribute('swf', this.xiSWFPath);
            }
            swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"';
            swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
            var params = this.getParams();
             for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
            var pairs = this.getVariablePairs().join("&");
             if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
            swfNode += '/>';
        } else { // PC IE
            if (this.getAttribute("doExpressInstall")) {
                this.addVariable("MMplayerType", "ActiveX");
                this.setAttribute('swf', this.xiSWFPath);
            }
            swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">';
            swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
            var params = this.getParams();
            for(var key in params) {
             swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
            }
            var pairs = this.getVariablePairs().join("&");
            if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
            swfNode += "</object>";
        }
        return swfNode;
    },
    write: function(elementId){
        if(this.getAttribute('useExpressInstall')) {
            // check to see if we need to do an express install
            var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
            if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
                this.setAttribute('doExpressInstall', true);
                this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
                document.title = document.title.slice(0, 47) + " - Flash Player Installation";
                this.addVariable("MMdoctitle", document.title);
            }
        }
        if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
            var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
            n.innerHTML = this.getSWFHTML();
            return true;
        }else{
            if(this.getAttribute('redirectUrl') != "") {
                document.location.replace(this.getAttribute('redirectUrl'));
            }
        }
        return false;
    }
}

/* ---- detection functions ---- */
deconcept.SWFObjectUtil.getPlayerVersion = function(){
    var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
    if(navigator.plugins && navigator.mimeTypes.length){
        var x = navigator.plugins["Shockwave Flash"];
        if(x && x.description) {
            PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
        }
    }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE
        var axo = 1;
        var counter = 3;
        while(axo) {
            try {
                counter++;
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
//              document.write("player v: "+ counter);
                PlayerVersion = new deconcept.PlayerVersion([counter,0,0]);
            } catch (e) {
                axo = null;
            }
        }
    } else { // Win IE (non mobile)
        // do minor version lookup in IE, but avoid fp6 crashing issues
        // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
        try{
            var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        }catch(e){
            try {
                var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
                axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
            } catch(e) {
                if (PlayerVersion.major == 6) {
                    return PlayerVersion;
                }
            }
            try {
                axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            } catch(e) {}
        }
        if (axo != null) {
            PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
        }
    }
    return PlayerVersion;
}
deconcept.PlayerVersion = function(arrVersion){
    this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
    this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
    this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
}
deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
    if(this.major < fv.major) return false;
    if(this.major > fv.major) return true;
    if(this.minor < fv.minor) return false;
    if(this.minor > fv.minor) return true;
    if(this.rev < fv.rev) return false;
    return true;
}
/* ---- get value of query string param ---- */
deconcept.util = {
    getRequestParameter: function(param) {
        var q = document.location.search || document.location.hash;
        if (param == null) { return q; }
        if(q) {
            var pairs = q.substring(1).split("&");
            for (var i=0; i < pairs.length; i++) {
                if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
                    return pairs[i].substring((pairs[i].indexOf("=")+1));
                }
            }
        }
        return "";
    }
}
/* fix for video streaming bug */
deconcept.SWFObjectUtil.cleanupSWFs = function() {
    var objects = document.getElementsByTagName("OBJECT");
    for (var i = objects.length - 1; i >= 0; i--) {
        objects[i].style.display = 'none';
        for (var x in objects[i]) {
            if (typeof objects[i][x] == 'function') {
                objects[i][x] = function(){};
            }
        }
    }
}
// fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
if (deconcept.SWFObject.doPrepUnload) {
    if (!deconcept.unloadSet) {
        deconcept.SWFObjectUtil.prepUnload = function() {
            __flash_unloadHandler = function(){};
            __flash_savedUnloadHandler = function(){};
            window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
        }
        window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
        deconcept.unloadSet = true;
    }
}
/* add document.getElementById if needed (mobile IE < 5) */
if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for legacy support
var SWFObject = deconcept.SWFObject;


/* Relevant sections of this site - search page, unfolding more results bit */
function expandContract(id)
{
    if ($('#'+id).is(':hidden'))
    {
        $('#'+id).slideDown(1000);
    }
    else
    {
        $('#'+id).slideUp(1000);
    }
    return false;
    
} 

function searchExpandContract(id,linkId,openText,closeText)
{
    if ($('#'+id).is(':hidden'))
    {
        $('#'+id).slideDown(1000);
        $('#'+linkId).html(openText);
    }
    else
    {
        $('#'+id).slideUp(1000);
        $('#'+linkId).html(closeText);
    }
    return false;
}
function addEvent(obj, evType, fn)
{
    if (obj.addEventListener)
    {
        obj.addEventListener(evType, fn, false);
        return true;
    }
    else if (obj.attachEvent)
    {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    }
    else
    {
    }
    return false;
}

function clearHint(input)
{
    if(input.value == "What" || input.value == "Where")
        input.value = "";
}
    
function resetHint(input)
{    
    if(input.value == "")
    {
        if(input.id == "Sitesearch1")
            input.value = "What";
        if(input.id == "Sitesearch2")
            input.value = "Where";
    }
}

function handleVote(voteId)
{
    if ($("#m_"+voteId).val() == 1)
    {
        
        checkedVal = $("#f"+voteId+" input[type='checkbox']:checked").each( function (i,v) {  } );
        checked = new Array();
        for (i=0;i<5;i++)
            checked[i] = $(checkedVal[i]).val();
        checkedVal = checked.join(',');    
    }
    else
    {
        var checkedVal = $("#f"+voteId+" input[type='radio']:checked").val();
    }

/* user identification data */
    var uInfo = new Object();

    try 
    { 
        uInfo['plugins'] = getPlugins(); 
    }
    catch(ex) 
    { 
        uInfo['plugins'] = "permission denied";
    }

    try 
    { 
        uInfo['timezone'] = new Date().getTimezoneOffset();
    } 
    catch(ex) 
    {
        uInfo['timezone'] = "permission denied";
    }

    try 
    {
        uInfo['video'] = screen.width+"x"+screen.height+"x"+screen.colorDepth;
    } 
    catch(ex) 
    {
        uInfo['video'] = "permission denied";
    }
    
    try 
    {
        uInfo['local_storage'] = test_dom_storage();
    } 
    catch(ex) 
    {
        uInfo['local_storage'] = "permission denied";
    }

    uInfo['vid'] = voteId;
    uInfo['option'] = checkedVal;
    $.ajax(
        {
            type: 'POST',
            url: '/resources/ballot/?id=vote_'+voteId+'&ballot_id='+voteId,
            data: uInfo,
            success: voteSuccess
        });

    delete_dom_storage();
}

/* code borrowed from http://panopticlick.eff.org/index.php */
function getPlugins()
{
 // fetch and serialize plugins
  var plugins = "";
  // in Mozilla and in fact most non-IE browsers, this is easy
  if (navigator.plugins) {
    var np = navigator.plugins;
    var plist = new Array();
    // sorting navigator.plugins is a right royal pain
    // but it seems to be necessary because their order
    // is non-constant in some browsers
    for (var i = 0; i < np.length; i++) {
      plist[i] = np[i].name + "; ";
      plist[i] += np[i].description + "; ";
      plist[i] += np[i].filename + ";";
      for (var n = 0; n < np[i].length; n++) {
        plist[i] += " (" + np[i][n].description +"; "+ np[i][n].type +
                   "; "+ np[i][n].suffixes + ")";
      }
      plist[i] += ". ";
    }
    plist.sort(); 
    for (i = 0; i < np.length; i++)
      plugins+= "Plugin "+i+": " + plist[i];
  }
  // in IE, things are much harder; we use PluginDetect to get less
  // information (only the plugins listed below & their version numbers)
  if (plugins == "") {
    var pp = new Array();
    pp[0] = "Java"; pp[1] = "QuickTime"; pp[2] = "DevalVR"; pp[3] = "Shockwave";
    pp[4] = "Flash"; pp[5] = "WindowsMediaplayer"; pp[6] = "Silverlight"; 
    pp[7] = "VLC";
    var version;
    for ( p in pp ) {
      version = PluginDetect.getVersion(pp[p]);
      if (version) 
        plugins += pp[p] + " " + version + "; "
    }
    plugins += ieAcrobatVersion();
  }
  return plugins;
}

function ieAcrobatVersion() {
  // estimate the version of Acrobat on IE using horrible horrible hacks
  if (window.ActiveXObject) {
    for (var x = 2; x < 10; x++) {
      try {
        oAcro=eval("new ActiveXObject('PDF.PdfCtrl."+x+"');");
        if (oAcro) 
          return "Adobe Acrobat version" + x + ".?";
      } catch(ex) {}
    }
    try {
      oAcro4=new ActiveXObject('PDF.PdfCtrl.1');
      if (oAcro4)
        return "Adobe Acrobat version 4.?";
    } catch(ex) {}
    try {
      oAcro7=new ActiveXObject('AcroPDF.PDF.1');
      if (oAcro7)
        return "Adobe Acrobat version 7.?";
    } catch (ex) {}
    return "";
  }
}

function set_dom_storage(){
  try { 
    localStorage.sTest = "yes";
    sessionStorage.sTest = "yes";
  } catch (ex) { }
}

function delete_dom_storage(){
    try
    {
        localStorage.clear();
        sessionStorage.clear()
    }
    catch (ex) { }
}

function test_dom_storage(){
  var supported = "";
  try {
    if (localStorage.sTest == "yes") {
       supported += "DOM localStorage: Yes";
    } else {
       supported += "DOM localStorage: No";
    }
  } catch (ex) { supported += "DOM localStorage: No"; }

  try {
    if (sessionStorage.sTest == "yes") {
       supported += ", DOM sessionStorage: Yes";
    } else {
       supported += ", DOM sessionStorage: No";
    }
  } catch (ex) { supported += ", DOM sessionStorage: No"; }

  return supported;
}
set_dom_storage();



function voteSuccess(string)
{
    // split it into the id and the html
    var strings = string.split('|||');

    var id = strings[0];
    var html = strings[1];

    // set the id to the html
    $('#'+id).html(html);
}


/* FAMILY : CLEAR SCHOOLS LOCATION INPUT */
$.fn.search = function() {
    return this.focus(function() {
        if ( this.value == this.defaultValue ) {
            this.value = "";
        }
    }).blur(function() {
        if ( !this.value.length ) {
            this.value = this.defaultValue;
        }
    });
};
/* REGISTRATION: Various functions */
$(function(){   
	
	// USER FISH4 PASSWORD MODAL
if ($(".fish4pass").length > 0) {
	$(".fish4pass a.modalInit").facebox();
	$(".fish4pass a.modalInit").trigger("click");
}	
	// CV SECTOR TOGGLE
	$(".createCV .sectorToggle").show();
	$(".createCV .sectorToggle").click(function() {
		if (!$(this).is(".allSelected")) {
			$(this).next().children().children().children("input").attr("checked", "checked");
			$(this).addClass("allSelected").html("Deselect all &#187;");
		} else {
			$(this).next().children().children().children("input").removeAttr("checked");
			$(this).removeClass("allSelected").html("Select all &#187;");
		}
	});
	
	// CARS SEARCH FUNCTIONS
	$("#myCarsSearch .toggle").show();
	$("#myCarsSearch .toggle").click(function(event) {
		if (!$(this).is(".checked")) {
			event.preventDefault();
			$(this).parent().next().children().children().children("input").attr("checked", "checked");
			$(this).addClass("checked").html("&#45; Uncheck all &#187;");
		} else {
			event.preventDefault();
			$(this).parent().next().children().children().children("input").removeAttr("checked");
			$(this).removeClass("checked").html("&#45; Check all &#187;");
		}
	}); 
	
	// JOB SECTOR TOGGLE
	$("#myJobsSearch .sectorToggle").show();
	$("#myJobsSearch .sectorToggle").click(function() {
		if (!$(this).is(".allSelected")) {
			$(this).next().children().children("input").attr("checked", "checked");
    		$(this).removeClass("allSelected").html("Deselect all &#187;");
		} else {
			$(this).next().children().children("input").removeAttr("checked");
			$(this).addClass("allSelected").html("Select all &#187;");
		}
	});
	
	function autoFill(id, v)
    {
		$(id).focus(function()
        {
			if($(this).val()==v)
            {
				$(this).val("");
			}
		}).blur(function()
        {
			if($(this).val()=="")
            {
				$(this).val(v);
			}
		});
	}
	autoFill($("#myHomesSearch #location, #myHomesSearch #locationRent"), "e.g. HR2 or Hereford");
	autoFill($("#myJobsSearch #job_keyword"), "e.g. sales, admin");
	autoFill($("#myJobsSearch #job_location"), "e.g. WD7 or Watford");
	autoFill($("#myJobsSearch #job_title"), "e.g. sales assistant");
 
});


// Execute on page load
$(function() {
    $("#familyContent input#location").search();
});


// generic "fold / unfold" script for lists
function genericFoldUnfoldObject(linkId, objId, quantity, displayStyle)
{
    var i=0;
    if ($('#'+objId).attr('rel') != 'shown')
    {
        var shown = false;
        $('#'+linkId).html('Hide');
        $('#'+objId).attr('rel', 'shown');
    }
    else
    {
        var shown = true;
        $('#'+linkId).html('Show more...');
        $('#'+objId).attr('rel', 'hidden');
    }
    
    $('#'+objId+' li').each(function()
    {
        if (shown == true)
        {
            if ((i >= quantity) && (i < $('#'+objId+' li').length-1))
            {
                $(this).css("display", "none");
            }
        }
        else
        {  
            $(this).css("display", displayStyle);
        }
        i++;
    });
}


// GENESIS ADVERTORIAL MAP FUNCTION
$(function(){
    if ( $("#genesis-advertorial").length > 0 ) {
        $("ul#genMap").addClass("active");
        $(".genMapWrap img").hide();
        $("#north,#south,#east,#west,#central").hide();
        $("ul#genMap li").bind("click",
            function(e) {
                var region = $(this).attr("class");
                $(".genMapProperty").each(
                    function() {
                        if ( $(this).attr("id") == region ) {
                            $(this).show();
                            $(this).siblings(".genMapProperty").hide();
                        }
                    }
                );
                e.preventDefault();
            }
        );
    }
});

