$(document).ready(function(){
  $.sifr({path: "include/sIFR/res/", save: true});  
  $("h6:not(div.pressreleases>h6)").sifr({font: "ScriptMT"});
  $("h5:not(div.pressreleases>h5)").sifr({font: "ScriptMT"});
  $(document).pngFix(); 
  $("#divTopImageSwitcher").cycle({delay:3000, speed:1000});

  var currentUserID = $("#uguid").html();
  if (currentUserID.length > 10){
    $("#divRegAggBar").show();
  }
});

function eggLogout(){
  if(confirm('Är du säker att du vill logga ut?')){
    $.get("/logout/", function(data){
      document.location='http://egg.agriprim.com/egg/logout.aspx';
    });
  }
}

function open_EGG_Old(uguid){
  window.name='SvenskaAgg';
  var eggWindow = window.open('http://egg.agriprim.com/egg/default.aspx?userGUID='+uguid,'EGG','status=yes,scrollbars=yes,resizable=yes,width=900,height=650');
}

function open_Compo(){
  if(1!=1||arguments.length>0){
    //document.location = '/?p=20092&m=3526';
    var compoWindow = window.open('/compo/2011/johanna/','compoWin','status=yes,scrollbars=no,resizable=no,width=880,height=558');
  } else {
    document.location = '/?p=19849';
    
  }
}

function goto_Compo(){
  if(1!=1||arguments.length>0){
    document.location = '/?p=20289';
  } else {
    document.location = '/?p=19849&m=3660';
  }
}

function fullScreen(theURL) {
  window.open(theURL, '', 'fullscreen=yes, scrollbars=auto');
}

function doHide(objID){
  $(objID).hide("fast");
}

function doHideFFSearch(){
  $("#txtFjaderfa").val("");
  $("#divSearchView").hide("fast");
}

function doSearchFjaderfa(tBox){
  var inval = tBox.value;
  var ffUrl = "http://www.svenskaagg.se/?p=19871&what="+escape(inval);
  if(inval.length > 3){
    $("#searchFjaderfaResult").load(ffUrl, function(response, status, xhr) {
      if (status == "error") {
        var msg = "Tyvärr kunde inga artiklar hämtas p.g.a. ett tekniskt fel.<br /><br />URL: "+ffUrl + "<br />";
        $("#divSearchView").html(msg + xhr.status + " " + xhr.statusText);
      } else {
        $("#divSearchView").show("slow");
      }
    });
  } else {
    $("#divSearchView").hide("fast");
  }
}

function doSearchFjaderfaStatic(tBox){
  var inval = $(tBox).val();
  var ffUrl = "http://www.svenskaagg.se/?p=19871&what="+escape(inval);
  if(inval.length > 2){
    $("#divFjaderfaResult").load(ffUrl, function(response, status, xhr) {
      if (status == "error") {
        var msg = "Tyvärr kunde inga artiklar hämtas p.g.a. ett tekniskt fel.<br /><br />URL: "+ffUrl + "<br />";
        $("#divFjaderfaResult").html(msg + xhr.status + " " + xhr.statusText);
      } else {
        $("#divFjaderfaResult").show("slow");
      }
    });
  } else {
    $("#divFjaderfaResult").html("Du måste ange minst tre tecken för att söka");
  }
}
