var sValue1 = 1;
var sValue2 = 5;

window.addEvent('domready', function(){
	
	//slider for advanced search
	if($$('.sliderTarget')[0]){
		var coreMarkup = $$('.sliderTarget')[0];
		//remove core markup via CSS
		coreMarkup.addClass('sliderRemove');
		//
		var sliderHTML = new Element('li', {
			html: '<div id="sliderWrap"><div id="twoBar" class="bar"><div id="handle1" class="handle"></div><div id="handle2" class="handle"></div></div><div id="log2"></div></div>'
		}).inject(coreMarkup, 'after');
		//
		
		var phaseCount = $$('#ddlPhaseTo option').length;
		var slideImgPath = '/_common/img/slider/back' + phaseCount + '.gif';
		var slideBarElem = $('twoBar');
		slideBarElem.setStyle('background-image', 'url(' + slideImgPath + ')');
		
		new Slider('twoBar', '#handle1, #handle2', {
			snap: true,
			range: [1, phaseCount],
			wheel: true,
			steps: phaseCount - 1,
			onChange: function(value, index){
				//$('log2').set('text', 'handle: '+ index +' step: '+value);
				if(index == 0){
					sValue1 = value
				}
				if(index == 1){
					sValue2 = value
				}
				
				$('log2').set('html', '<em>Stages:</em> '+($$('#ddlPhaseTo option')[sValue1 - 1].text)+' <em>to</em> '+($$('#ddlPhaseFrom option')[sValue2 - 1].text));
				//$$('.sliderValue')[index].set('selectedIndex', value-1);
				$$('.sliderValue')[index].options[value-1].selected = true;
			}
		}).set([0, 90]);
	}
	
	//external links
	$$('a[rel=external]').set('target', '_blank');
	
    // Instantiate tooltips
    doTips();
	
	//Site Show
	setTimeout('$(document.body).setStyle("visibility","visible");', 200);

	var yes = $('Latest1');
	if(yes)
	{
	assetCTO('Latest');
	assetCTO('Featured');
	}

});
		
//sIFR
var futura = {
  src: '/_common/swf/FuturaMedium.swf'
};

// You probably want to switch this on, but read <http://wiki.novemberborn.net/sifr3/DetectingCSSLoad> first.
// sIFR.useStyleCheck = true;
sIFR.activate(futura);

sIFR.replace(futura, {
  selector: 'h1'
  ,css: [
    '.sIFR-root { color:#92B21F; }'
  ]
});

// Tips functions

function doTips()
{
	//tooltips
	$$('.tooltip').setStyle('display','block');
	var myTips = new Tips('.tooltip');
}

function assetCTO(id) 
{
    for (var i = 1; i < 4; i++) 
    {
        var s = id + i;
        var highlight = $(s).getSize();
        //alert('height' + s + ': ' + highlight.y);
        if (highlight.y < 61) 
        {
            $(id + i).setStyle('height', 61);
        }
    }

}
