//This loads main style sheet
//seperated by name attribute as to not interfere with other/print style sheets

function GoSearch()
{
document.location = "/en/members/search/?Query="+$("#q").val();
}

function RemoveH1()
{
$("#formdata h1").css("display","none");
}


function SetCurrentStyle()
{
        if($.cookie("FontSize")) {
         $("link[id=FontSize]").attr("href","/includes/css/"+$.cookie("FontSize"));
        }
 
}

function SetBackgroundImage()
{
   if($("#RightSide img").length) //if there is a banner available
   {
        var imagepath = $("#RightSide img").attr("src"); //get the image path
        $("#RightSide").css("background-image","url("+imagepath+")");  //add the background image, do background-position etc in css file.
        //$("#RightSide img").css("display","none"); //remove the banne image
              
   }
   
   
   if($("#contentBanner img").length) //if there is a banner available
   {
           var imagepath = $("#contentBanner img").attr("src");
           
           if($("#HeaderRight").length)
           {
                $("#HeaderRight").css("background-image","url("+imagepath+")");  //add the background image, do background-position etc in css file.
           }
   }
   else
   {
     $("#PageTitle").attr("id","PageTitle2");
     //$("#PageTitle").removeClass("PageTitle").addClass("PageTitle2");
     $("h1.heading").removeClass("heading").addClass("heading3");
     $("#HeaderRight").css("height","40px");
   }

}

function SetH1Style()
{

    var count = 0;
    
    if($("h1.heading").length)
    {
    count = $("h1.heading").text().length;

    }
    if($("h1.heading3").length)
    {
    count = $("h1.heading3").text().length;

    }
    
   // $("h1.heading").text().length;

    if(count > 34)
    {
        $("h1.heading").removeClass("heading").addClass("heading2");
        $("h1.heading3").removeClass("heading3").addClass("heading4");
      
       
       
       if(count>53)
       {
        $("h1.heading2").css("font-size","1.4em");
       }
    }
}


function CheckUsefulLinks()
{
    if($(".side_banners .greyBox").length == 0)
    {
        $("#UsefulText").css("display","none");
    }

}

function CheckIE6MinWidth()
{

      if(screen.availWidth < 1024)
      {
        $("#pageContainer").css("width","1024px");
  
      }
            

}

function SetFont(size)
{

    $("#content").removeClass(); //remove all classes
    $("#content").addClass(size);
    $.cookie("FontSize",size, {expires: 365, path: '/'});
}
 
 //sets style sheet, remember to add /includes/css/ etc
 $(document).ready(function() {

     $("a.fontSize").click(function() {
     $("link[id=FontSize]").attr("href","/includes/css/"+$(this).attr('rel'));
     $.cookie("FontSize",$(this).attr('rel'), {expires: 365, path: '/'});
     return false;
     });
     
     SetCurrentStyle();
     SetBackgroundImage();
     SetH1Style();
     CheckUsefulLinks();
     CheckIE6MinWidth();
 }); 
 
 
 
 function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function DisplayLetter()
{
    var letter = getParameterByName('index');
    
    if(letter == "")
    {
         $("#ResultLetter").text("Please click on the desired letter above");
    }
    else
    {
        $("#ResultLetter").text(letter);
    }
    

}
