//**********************************************************************************//
Functions.changeGalleryNormalImage = function(imageName, mediaID){
  imgSrc   = "/media/gallery/normal/" + imageName;
  linkTemp = "index.php?_room=media&_spAction=zoomImage&media_id=" + mediaID;
  linkSrc  = "javascript:UtilWindow.openWindow(linkTemp,'1010','800')";
  document.getElementById("galleryImage").src = imgSrc;
  document.getElementById("largeImage").href  = linkSrc;
}

//**********************************************************************************//
Functions.popUp = function(windowURL,windowName,windowWidth,windowHeight) {

   window.name = 'parentWnd';
   newWindow = window.open(windowURL,windowName,'width='+windowWidth+',height='+windowHeight+',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
}

//**********************************************************************************//
closeNyroModal = function() {
   parent.$.nyroModalRemove();
}

$(function(){
   $('.categoryFilter').each(function() {
      if ($(this).find('ul').css('display') == 'block'){
         $(this).find('a').addClass('arrowDown');
      }
   });

   $('.categoryFilter h1 a').click(function(e) {
       e.preventDefault();
       mainDiv = $(this).parent().parent();
       $(mainDiv).find('ul').slideToggle('fast', function() {
       });

       $(this).toggleClass('arrowDown');
   });
})

Enquiry = new Object();
//=====================================================//
Enquiry.submitEnquiry = function(){
   
   validate = Validate.validateEnquiry('enquiry',1)

   if (validate == false) return;
   
   var enquiryFormDIV  = document.getElementById("enquiryBox");

   var enquiryFormObj  = document.getElementById("frmEnquiry");


   var url = "/index.php?_spAction=enquirySubmit" + "&_room=content" + "&showHTML=0";

   var formContent = UtilAjax.getFormValues(enquiryFormObj);

   XMLHTTP.xmlHttpObj  = XMLHTTP.getXMLHTTPObject(function () {Enquiry.submitEnquiryHandler();});
   XMLHTTP.xmlHttpObj.open("POST", url, true);
   XMLHTTP.xmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
   XMLHTTP.xmlHttpObj.send(formContent);
}

//=====================================================//
Enquiry.submitEnquiryHandler = function(){
   var enquiryFormDIV = document.getElementById("enquiryBox");
   
   if (XMLHTTP.xmlHttpObj.readyState==4 || XMLHTTP.xmlHttpObj.readyState=="complete") {
         var formContent = 'xyz=1';
         XMLHTTP.xmlHttpObj = XMLHTTP.getXMLHTTPObject(function () {Enquiry.submitEnquiryHandler2();});
         XMLHTTP.xmlHttpObj.open("POST", url, true);
         XMLHTTP.xmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
         XMLHTTP.xmlHttpObj.send(formContent);

    } else {
        enquiryFormDIV.innerHTML = responseText;
    }
}

//=====================================================//
Enquiry.submitEnquiryHandler2 = function(){
   if (XMLHTTP.xmlHttpObj.readyState==4 || XMLHTTP.xmlHttpObj.readyState=="complete") {
      
      var dateObj = new Date();
      var responseText = UtilString.trimAll(XMLHTTP.xmlHttpObj.responseText, 1) + "?x=" + dateObj.getTime();
   }
}

//=====================================================//
$(function() {
    var settings = {
         width: '500'
        ,height: '420'
        ,titleFromIframe: false
    }
    $.nyroModalSettings(settings);
})
