$(document).ready(function()
{
    content_height();
    Cufon.replace('h1.title, h3, h2');
    
    Cufon.replace(' #main-nav li a, #lang-nav li a, #top-nav li a', {
	   hover: true
        });

    $("#logo img").ifixpng();
    $("#page .page-bottom").ifixpng();
    $("a.nav").ifixpng();
    $("#main-nav li a").ifixpng();
    $(".slide .desc").ifixpng();
    $("#slide_nav li").ifixpng();
    $("#external-menu").ifixpng();    

    $("input.submit").click(function(){
       content_height(); 
    })
    
    // Hr Form
    
    $("a.add-new").live('click',function(){
         
      var remove = $('.remove-me').html();      
      var source = $(this).parent().parent().parent().parent().find('tr.source').html();      
      var count = $(this).parent().parent().parent().children().size();      

      $(this).parent().parent().parent().append('<tr class="dom-obj">' + source + '</tr>');
      $(this).parent().parent().parent().parent().find('tr.dom-obj').find('td.add-new').html(remove)
      
            
      return false;  
    });
    
    $("a.remove").live('click',function(){
                  
      var source = $(this).parent().parent().remove();       
      return false;  
    });    

})
$(window).resize(function() {
  content_height();
});

function content_height()
{
        var height = $(window).height();
        var footer = $("#footer").height();
        var header = $("#header").height();
        var content = $("#content").height();
        
        var total = (footer+header);
        var result = (height-total);
            
            if (content < result)
            {
              $("#content").height(result-25)
              
            }   
}

function getPageHeight(type)
    {

         var viewportwidth;
         var viewportheight;
         
         // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
         
         if (typeof window.innerWidth != 'undefined')
         {
              viewportwidth = window.innerWidth,
              viewportheight = window.innerHeight
         }
         
        // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
        
         else if (typeof document.documentElement != 'undefined'
             && typeof document.documentElement.clientWidth !=
             'undefined' && document.documentElement.clientWidth != 0)
         {
               viewportwidth = document.documentElement.clientWidth,
               viewportheight = document.documentElement.clientHeight
         }
         
         // older versions of IE
         
         else
         {
               viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
               viewportheight = document.getElementsByTagName('body')[0].clientHeight
         }
        //document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
        
        if (type == "w")
            {
              return  viewportwidth;
            }
        if (type == "h")
            {
               return viewportheight; 
            }            
        
    }
