// JavaScript Document $(document).ready(function(){ setSubNav(); resizeDiv(); if($('#currentPage').val()== 4){ initialize_imageScroll(); } if($('#currentPage').val()== 1){ startBanner(); } $('.more').click(function(){ toggle(this); }); $('.quoteRequest').colorbox({width:"771px", height:"560px", iframe:true, scrolling: true}); // for Drop Down Menu $('.navBtn3').hover(function(){$('#subNavContainer').removeClass('displayNone')}, function(){ $('#subNavContainer').hover(function(){},function(){$('#subNavContainer').addClass('displayNone')}); }); $('.navMain, .navSelected').hover( function(){ if($(this).hasClass('navBtn3')){ }else{ $('#subNavContainer').addClass('displayNone'); } }, function(){}); $('.navBtn4').hover(function(){$('#subNavContainer2').removeClass('displayNone')}, function(){ $('#subNavContainer2').hover(function(){},function(){$('#subNavContainer2').addClass('displayNone')}); }); $('.navMain, .navSelected').hover( function(){ if($(this).hasClass('navBtn4')){ }else{ $('#subNavContainer2').addClass('displayNone'); } }, function(){}); $(window).resize(function() { placeSunNav(); }); }); /* Create SubNav Dropdown */ function setSubNav(){ var htmlStr = ''; $('#mainContainer').append(htmlStr); var htmlStr = ''; $('#mainContainer').append(htmlStr); placeSunNav(); } function placeSunNav(){ var pos = $('.navBtn3').position(); $('#subNavContainer').css({'position':'absolute','top':(pos.top+43)+'px','left':pos.left+'px'}); var pos = $('.navBtn4').position(); $('#subNavContainer2').css({'position':'absolute','top':(pos.top+43)+'px','left':pos.left+'px'}); } function resizeDiv(){ var h = $('#contentContainer').height(); $('#rightSmallContainer').height(h-2); $('#leftLargeContainer').height(h-2); $('#leftSmallContainer').height(h-2); $('#rightLargeContainer').height(h-32); //console.log($('#leftSmallContainer').height()); //console.log($('#rightLargeContainer').height()); //console.log(h); var tH = $('#interfaceTop').height(); var tB = $('#interfaceBottom').height(); var rB = $('#rightSmallContainer').height(); if((tH+tB)< rB){ var diff = rB - (tH+tB); //console.log(tB); //console.log(diff); $('#interfaceBottom').height(tB+diff - 70-2); } } /* * Begins the Banner Rotation if #bannerBox * * */ function startBanner(){ //Start Banner Cycler $('#rotatingBanner').cycle({ speed: 1000, startingSlide: 0, timeout: 5000 }); } /* * Begins the Banner Rotation if #bannerBox * * */ function toggle(obj){ var parentObj = $(obj).parent().parent(); var bigObj = parentObj.find('div.big'); var smallObj = parentObj.find('div.small'); var text = $(obj).text(); if($(bigObj).css('display') == 'none'){ hideMe(smallObj); showMe(bigObj); text = text.replace('View', 'Hide'); $(obj).text(text); }else{ hideMe(bigObj); showMe(smallObj); text = text.replace('Hide', 'View'); $(obj).text(text); } } function showMe(obj){ $(obj).css({opacity:1}); $( obj ).show( 'blind','',700, function(){$( obj ).removeClass('displayNone'); }); } function hideMe(obj){ $(obj ).animate({opacity:0.5}, 100, function(){ $( obj ).hide( 'blind','',100, function(){$(obj).css({display:'none'})}); }); } /* Validates and sends contact form info POST via Ajax */ function sendContactFrm(){ var name = $('input[name=name_contact]'); var email = $('input[name=email_contact]'); var comm = $('textarea[name=comments_contact]'); var error =false; //first Name if (name.val()=='') { name.addClass('highlight'); error = true; } else name.removeClass('highlight'); //email if (email.val()=='') { email.addClass('highlight'); error = true; } else if(validateEmail(email.val())== -1) { email.addClass('highlight'); error = true; } else email.removeClass('highlight'); //comments if (comm.val()=='') { comm.addClass('highlight'); error = true; } else comm.removeClass('highlight'); if(error == false){ $.ajax({ type: "POST", url: "include/processForm.php", dataType: "html", data:'name_contact='+name.val()+'&email_contact='+email.val()+'&comments_contact='+comm.val(), success: function(r) { if(r == 'success'){ name.val(''); email.val(''); comm.val(''); $('#msg').text('Thank you, your message has been sent.'); setTimeout("$('#msg').text('')", 3000); } } }); }else{ //alert('Sorry we experienced an error'); } } /* * EMAIL Varify * recieves NOTHING, uses preset varible */ function validateEmail(fieldVAL) { var regEx = new RegExp(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/); if ( !regEx.test(fieldVAL) ){ return -1; }else{ return 1; } } function getInternetExplorerVersion() { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat(RegExp.$1); } return rv; } function checkVersion() { var msg = 2; var ver = getInternetExplorerVersion(); if (ver > -1) { if (ver == 9.0){ msg = 9; }else if(ver == 8.0){ msg = 8; }else if(ver == 7.0){ msg = 7; }else{ msg = 6; } } //alert(msg); return msg; } /* images.... */ var imagesArray1=new Array(); var imagesArray2=new Array(); var imgCount=0; var imagewidthsTotal=0; var galleryRoot = location.protocol + '//' + location.host+'/_service/dev1/BMD_construction/images/gallery/'; /* INITIALIZE PHOTOS */ function initialize_imageScroll() { // console.log('in'); $.ajax({ type: "GET", url: "res_images.xml", dataType: "xml", success: function(xml) { $(xml).find('item').each(function(){ var images=new Array(); images.push($(this).find('main').text()); images.push($(this).find('zoom').text()); images.push($(this).find('thumb').text()); images.push(parseInt($(this).find('width').text())); images.push(parseInt($(this).find('height').text())); imagesArray1.push(images); }); setImages(1); } }); $.ajax({ type: "GET", url: "com_images.xml", dataType: "xml", success: function(xml) { $(xml).find('item').each(function(){ var images=new Array(); images.push($(this).find('main').text()); images.push($(this).find('zoom').text()); images.push($(this).find('thumb').text()); images.push(parseInt($(this).find('width').text())); images.push(parseInt($(this).find('height').text())); imagesArray2.push(images); }); } }); } function setImages(a){ $('#loading').removeClass('displayNone'); $('#innerMediaContainer').html(''); if(a == 1){ var imagesArray = imagesArray1; $('#galTitle').text('Residential'); $('#resBtn').addClass('btnSelected'); $('#comBtn').removeClass('btnSelected'); }else{ var imagesArray = imagesArray2; $('#galTitle').text('Commercial / Industrial'); $('#resBtn').removeClass('btnSelected'); $('#comBtn').addClass('btnSelected'); } var totalNumberImgs = imagesArray.length; //create new image object var cat = new Image(); var catThumb = new Image(); //give Image src attribute the image file name cat.src = galleryRoot+imagesArray[imgCount][0]; catThumb.src = galleryRoot+imagesArray[imgCount][2]; imagewidthsTotal+=imagesArray[imgCount][3]+4; //if the counter represents the last image in the current gallery enter here: 3 in this case because we are only using 4 images if(imgCount == (totalNumberImgs-1)){ //When the image has been loaded the following function is exicuted cat.onload = function() { //Removes the LOADING message hard coded into the html page $('#loading').addClass('displayNone'); //set the background images and thumbnail src images for the current gallery //create a new div element $('#innerMediaContainer').css({'width':(imagewidthsTotal)+'px'}); var str =''; $('#innerMediaContainer').append(str); setListeners(); showImage(0, a); $('.mediaImg').click(function(){ showImage($(this).attr('imgIndex'), $(this).attr('arrayType')) }); } }else{ //when current image is finished loading increments the img index and //calls the loading function again for the next image in the gallery imgCount++; //cat.onload = setImages; $(cat).load(function() { setImages(a) }); } } function setListeners(){ $('#innerMediaContainer').jCarouselLite({ btnNext: ".myArrowRight", btnPrev: ".myArrowLeft", visible: 5, scroll: 3, circular: false, mouseWheel: true }); //to initialize the the first loading Previous arrow to hidden $('.myArrowLeft').addClass('disabled'); $('.myArrowRight').removeClass('disabled'); //reset counters for next time imgCount=0; imagewidthsTotal=0; } function showImage(index, a){ if(a == 1){ var imagesArray = imagesArray1; }else{ var imagesArray = imagesArray2; } //main Image var href = galleryRoot+imagesArray[index][0]; var zoom = galleryRoot+imagesArray[index][1]; $('#mainImg').attr('src',href); $('#zoomBtn').attr('imgIndex',index); $('#zoomBtn').attr('arrayType',a); } function showZoom(index, a){ if(a == 1){ var imagesArray = imagesArray1; }else{ var imagesArray = imagesArray2; } //main Image var href = galleryRoot+imagesArray[index][0]; var zoom = galleryRoot+imagesArray[index][1]; $.colorbox({href:zoom}); }