/*
 * custom scripts for www.stroik.com
 *
 * Date: 2009-09-25 (Fri, 25 September 2009)
 * Revision: 35
 */

/* Custom functions
------------------------------------------------- */
function findPosX(obj) {var curleft = 0;if(obj.offsetParent) {while(1) {curleft += obj.offsetLeft;if(!obj.offsetParent) {break;}obj = obj.offsetParent;}}else if(obj.x) {curleft += obj.x;}return curleft;}

function popup(url,w,h,type) {var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; var popupProps = 'width='+w+',height='+h+',left='+winl+',top='+wint; switch(type) {case 1: popupProps += 'resizable=yes,status=1,menubar=1,toolbar=1,scrollbars=1,location=1,directories=1'; break; case 2: popupProps += 'resizable=yes,toolbar=1,scrollbars=1,location=1'; break; case 3: popupProps += 'scrollbars=1'; break; default: popupProps += '';} window.open(url,'popup',popupProps);}

function setLogo() {if(!document.getElementById) return; var masthead = document.getElementById('masthead'); var wrap = document.getElementById('wrap'); var wrapX = findPosX(wrap); var logo = document.getElementById('logo'); var nav = document.getElementById('nav'); if(masthead.className=='home') {logo.style.position='absolute'; logo.style.paddingLeft = 85 + wrapX + 'px'; logo.style.paddingRight = '46px'; logo.style.backgroundPosition = (wrapX + 119) + 'px ' + '16px'; nav.style.marginLeft = 485 + wrapX + 'px'; window.onresize = function() {var wrapX = findPosX(wrap);logo.style.paddingLeft = 85 + wrapX + 'px';logo.style.backgroundPosition = (wrapX + 119) + 'px ' + '16px';nav.style.marginLeft = 485 + wrapX + 'px';}} else {logo.style.position='absolute'; logo.style.paddingLeft = wrapX + 'px'; logo.style.paddingRight = '46px'; logo.style.backgroundPosition = (wrapX + 34) + 'px ' + '16px'; window.onresize = function() {var wrapX = findPosX(wrap);logo.style.paddingLeft = wrapX + 'px';logo.style.backgroundPosition = (wrapX + 34) + 'px ' + '16px';}}}

function prepareCopy() {if($('#detail p').length>0) {var leadP = $('#lead p');var lastP = leadP.length - 1;if(leadP[lastP]) {leadP[lastP].innerHTML = leadP[lastP].innerHTML + ' <a class="more" id="more" href="#" onclick="$(this).hide(); $(\'#detail\').slideDown(1000); $(\'#less\').show(); return false;">View more</a><a class="less" id="less" href="#" onclick="$(this).hide(); $(\'#detail\').slideUp(1000); $(\'#more\').show(); return false;" style="display: none;">View less</a>';}}}

function showTab(tab) {tab.blur();$('ul.tabs li').removeClass("active");tab.parent().addClass("active");$('div.detail').hide();$(tab.attr("href")).show();}

function prepareTabs() {$('ul.tabs li a').each(function() {if($(this).parent().hasClass("rss")) {if($(this).parent().attr("id")=='n-05') {$(this).click(function() {showTab($(this)); $('#slider_02').easySlider({auto: true,speed: 800,pause: 5000,prevId: 'prev02',nextId:'next02'}); $(this).unbind("click"); $(this).click(function() {showTab($(this)); return false;}); return false;});} if($(this).parent().attr("id")=='n-06') {$(this).click(function() {showTab($(this)); $('#slider_03').easySlider({auto: true,speed: 800,pause: 5000,prevId: 'prev02',nextId:'next02'}); $(this).unbind("click"); $(this).click(function() {showTab($(this)); return false;}); return false;});}} else if($(this).parent().attr("id")!=='n-send') {$(this).click(function() {showTab($(this)); return false;});} else {$(this).click(function() {$('#send').submit();return false;});}});}

function showSection() {var sections = new Array(); sections[0] = 'ecclesiastical'; sections[1] = 'civic'; sections[2] = 'commercial'; sections[3] = 'educational'; sections[4] = 'residential'; var n = 0 /*Math.floor(Math.random()*5) */; $('#'+sections[n]).slideDown(1000); $('#title0'+n+'a').hide(); $('#title0'+n+'b').show(); $('#feature0'+n).slideDown(1000);}
/* -------------------------------------------------
                             end custom functions */

/* UI Candy
------------------------------------------------- */
$(document).ready(function(){$('a[rel="external"]').attr('target','_blank');$('a[rel="close"]').click(function() {window.close();});prepareTabs();prepareCopy();});
/* -------------------------------------------------
                                     end UI Candy */
