//
// @author [Cassette]
// @copyright [2010] 
// Software on this site is copyright 2010
// Cassette Pty Ltd.
// All Rights Reserved. Copying, Editing or
// Distributing this software is strictly
// forbidden without permission from
// Cassette Pty Ltd.
// for more information please contact
// Cassette www.cassette.cc 
//

var nav = "home";
var anim = false;
var fl_current_item = "unit1";
var g_current_item = "image1";

function SendEmail()
{
   var loadUrl = "../pages/ajax-mail.php";
    $("#msg").html("");
   $.post(loadUrl, {
                comments: $("#c").val(),
                name: $("#n").val(),
                 phone: $("#p").val(),
                email: $("#e").val(),
                hu: ''
             }
             , function(responseText){
                            $("#msg").html(responseText);
             });
}

function  ActivateMenuItem(item)
 {
      nav = item;
      $("#" + item).css('z-index', '6');
      $("#" + item).addClass('menu-item-active');
 }

function ShowGallery(id)
{
    if (anim == false && id != g_current_item)
        {
            $("#" + g_current_item).children('img').attr("src",  $("#" + g_current_item).children('img').attr("src").replace("on.jpg", "off.jpg"));
            $("#" + id).children('img').attr("src",  $("#" + id).children('img').attr("src").replace("roll.jpg", "on.jpg"));
            anim = true;
              $("#gallery-image, #shadow-right, #shadow-left").fadeOut('fast', function(){
               $("#gallery-image").children('img').attr('src',   '../images/gallery/gallery_' + id + '.jpg');
                  }).fadeIn('slow', function(){
                      anim = false;
                      g_current_item = id;
                  });
    }
}

function InitContactForm()
{var active_color='#000';var inactive_color='#999';$("input.default-value").css("color",inactive_color);var default_values=new Array();$("input, textarea").focus(function(){if(!default_values[this.id]){default_values[this.id]=this.value;}
if(this.value==default_values[this.id]){this.value='';this.style.color=active_color;}
$(this).blur(function(){if(this.value==''){this.style.color=inactive_color;this.value=default_values[this.id];}});});}


function ShowFloorplan(id, dest, path)
{

    if (anim == false && id != fl_current_item)
        {
          anim = true;
          $('#' + fl_current_item).removeClass('green-bold');
            $('#' + id).addClass('green-bold');
              $("#" + dest + ", #floorplan-text").fadeOut('fast', function(){
                   $("#" + dest).children('img').attr('src', path  + 'floorplan_' + id + '.jpg');
                      $("#floorplan-text").html( $('#' + id).html());
                  }).fadeIn('slow', function(){
                      anim = false;
                      fl_current_item = id;
                      
                  });
    }
    
}

$(document).ready(function(){
        $('#submit').click(function()
    {
        SendEmail();
      }
    );
    $('.floorplan').click(function()
    {
        ShowFloorplan($(this).attr('id'), 'floorplan-display', '../images/floorplans/');
        
      }
    );

    $('.gallery_thumb').click(function()
    {
        ShowGallery($(this).attr('id'));
      }
    );
      $(".gallery_thumb").hover(
        function(){
           var  id = $(this).attr('id');
            if (id  != g_current_item)
                {
                    $(this).children('img').attr("src",  $(this).children('img').attr("src").replace("off.jpg", "roll.jpg"));
                   //$(this).children('img').attr('src', '../images/gallery/thumbnail/gallery_' + id + '_on.jpg') ;
                }
        }
        , function(){
           var  id = $(this).attr('id');
            if (id  != g_current_item)
                {
                    $(this).children('img').attr("src",  $(this).children('img').attr("src").replace("roll.jpg", "off.jpg"));
                }
        });


      $(".menu-item").hover(
        function(){
            if (nav  != ($(this).attr('id')))
                {
                    $(this).css('z-index', '6');
                    $(this).addClass('menu-item-active');
                }
        }
        , function(){
              if (nav  != $(this).attr('id'))
                {
                    $(this).css('z-index',$(this).attr('rel'));
                    $(this).removeClass('menu-item-active');
                }
        });
        $("#pdf_dl").hover(
        function(){
            $(this).attr('src', '../images/gui/floorplan_pdf_button.jpg');
        }
        , function(){
            $(this).attr('src', '../images/gui/floorplan_pdf_button_rollover.jpg');
        });
       $('body').pngFix( );
       InitContactForm();
}); 
