﻿





/* quote positioning */
// styling
document.writeln('\
				<style type="text/css">\
					/* hide js influenced elements, via JS so as not to hide from noscript browsers */\
							#nat-recon .relatedContent .testimonial      { visibility: hidden; }\
				</style>\
			');
// doing
var matchQuotes = function() {
    $('[quotematch]').each(function() {
        var posObj = $(this);
        var quoteName = posObj.attr('quotematch');
        var matchHeight = posObj.position().top;
        $('[quote=' + quoteName + ']').each(function() {
            $(this).css({
                position: 'absolute',
                visibility: 'visible',
                top: matchHeight + 'px'
            });
        });
    });
}


/* lightbox setup */
// styling
document.writeln('\
				<style type="text/css">\
					html #modal div#modalBG  { background: white; background-image: url(\'global/img/chrome-bg-modal.gif\'); background-repeat: repeat; }\
				</style>\
			');
// doing
var setLightbox = function() {
    var rootMarkup = '\
					<div id="modalPlate">\
						<img id="killModal" src="global/img/chrome-btn-modalKill.gif" />\
						<div id="modalScroller">\
							<img src="<!--img-->" id="modalImgShow" />\
						</div>\
					</div>\
				';
    $('a.lightBox').click(function() {
        var thisMarkup = rootMarkup.split('<!--img-->').join(this.href);
        modal.enter(thisMarkup);
        $('#modal').applyCssQuadBg();
        $('#modalImgShow')[0].onload = function() {
            var scrollBarWidth = 16; //win
            if (
							$('html').hasClass('webkit') ||
							(
								$('html').hasClass('gecko') &&
								$('html').hasClass('mac')
							)
						) {
                scrollBarWidth = 15; //safari + firefox mac
            }
            $('#modalScroller').css({ width: $('#modalImgShow')[0].offsetWidth + scrollBarWidth + 'px' });
            //						$('#modal div#modalBG').css({height: '1000px'});
        }
        $('#killModal').click(modal.exit);
        return false;
    });
}


/* hero flash area setup */
/*
var setHero = function() {
    // set some editable vars
    var swfReq = 9;                               // <----- Minimum Flash Plugin Requirement.
    var swfDoc = './home.html';                   // <----- HTML document where the flash site is hosted.
    var swfMov = './global/media/recon_home_with_isp.swf'        // <----- Path to the swf movie.
    var homeSwfDiv = $('#nat-recon #headerContent');  // <----- JQUERY: element that will house the flash.
    // if flash is there, show it.
    var swfRev = swfobject.getFlashPlayerVersion();
    if (swfRev.major >= swfReq) {
        homeSwfDiv.html('');
        swfobject.embedSWF(swfMov, homeSwfDiv.attr('id'), '972', '320', '9');
    } else { }
}
*/

/* flash videos */
var setVids = function() {
    $('.inlineVid').each(function() {
        var swfReq = 9;
        var width = 385;
        var height = 325;
        var element = $(this);
        var swfUrl = element.attr('href');
        // if flash is there, show it.
        var swfRev = swfobject.getFlashPlayerVersion();
        if (swfRev.major >= swfReq) {
            element.html('\
						<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">\
							<param name="movie"             value="' + swfUrl + '" />\
							<param name="allowScriptAccess" value="sameDomain" />\
							<param name="swliveconnect"     value="true" />\
							<param name="quality"           value="high" />\
							<param name="wmode"             value="transparent" />\
							<embed\
								src                ="' + swfUrl + '" \
								allowScriptAccess  ="sameDomain" \
								swliveconnect      ="true" \
								width              ="' + width + '" \
								height             ="' + height + '" \
								type               ="application/x-shockwave-flash" \
								wmode              ="transparent"\
							/>\
						</object>\
					');

            element.click(function() { return false; })

        } else {
            element.attr('href', 'http://www.adobe.com/go/EN_US-H-GET-FLASH');
        }
    });
}


/* fix for title */
var fixLocation = function() {
    if (typeof (ActiveXObject) != 'undefined') {
        setInterval(function() {
            document.title = 'Natrelle®';
        }, 20);
    }
}


/* overall init */
$(document).ready(function() {
    setInterval(matchQuotes, 500);
    setLightbox();
   // setHero();
    setVids();
    fixLocation();
});




