//<![CDATA[

// general toolbox of functions

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return( {width:myWidth, height:myHeight} );
}

function getPreloadImage(ImageFilename)
{
	var ImagePreload = new Image();
	ImagePreload.src = ImageFilename;
}



function get_FavouritesClear()
{
    $("#FavouritesArea").html("<img src=\"/get_images/misc/loading.gif\" />");
    $.get("/get_ajax/handlefavourites.php", {action: "clear", memberref: 0},
        function (data)
        {
            $("#FavouritesArea").html(data.Html);
        }
        , "json");
}

function get_FavouritesAdd(MemberRef, LoadingElement)
{
    OldHtml = $("#" + LoadingElement).html();
    $("#" + LoadingElement).html("<img src=\"/get_images/misc/loading.gif\" />");
    $("#" + LoadingElement).addClass("AddFavouriteClicked");
    $("#FavouritesArea").html("<img src=\"/get_images/misc/loading.gif\" />");
    $.get("/get_ajax/handlefavourites.php", {action: "add", memberref: MemberRef, extradata:OldHtml},
        function (data)
        {
            $("#FavouritesArea").html(data.Html);
            $(".AddFavouriteClicked").html(data.ExtraData).removeClass("AddFavouriteClicked");
            get_Alert(data.CompanyName + " added to favourites");
        }
        , "json");
}

function get_FavouritesDelete(MemberRef)
{
    $("#FavouritesArea").html("<img src=\"/get_images/misc/loading.gif\" />");
    $.get("/get_ajax/handlefavourites.php", {action: "delete", memberref: MemberRef},
        function (data)
        {
            $("#FavouritesArea").html(data.Html);
        }
        , "json");
}

function get_FavouritesRefresh()
{
    $("#FavouritesArea").html("<img src=\"/get_images/misc/loading.gif\" />");
    $.get("/get_ajax/handlefavourites.php", {action: "refresh", memberref: 0},
        function (data)
        {
            $("#FavouritesArea").html(data.Html);
        }
        , "json");
}

function get_Alert(Message)
{
    $("#get_AlertMessage").html(Message);
    $("#get_AlertLink").click();
}


//]]>

