﻿
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openModalWindow(passedDiv, passedBgDiv, centerVertically) {
    
	var div = $(passedDiv);        
	var bgDiv = $(passedBgDiv);        
	var docDim = Element.getDimensions(document.body);        
	//get the size of the window and calculate where the box should be placed        
	var wDim = getBrowserWindowSize();        
	var dDim = Element.getDimensions(div);
	
	if(centerVertically == 'true' ){ 
	       
	    div.style.top = ((wDim.height - dDim.height*2) / 2) + 'px';
	} 
	else {
	div.style.top = 80 + 'px';
	}       
	
	div.style.left = ((wDim.width - dDim.width) / 2) + 'px';        
	if (docDim.height > wDim.height) {            
		wDim.height = docDim.height;        
	}        
	bgDiv.style.width = wDim.width + 'px';
	bgDiv.style.height = '2000px';        
	//bgDiv.style.height = wDim.height + 'px';        
	Element.show(div);        
	Element.show(bgDiv);
}

function closeModalWindow(div, bgDiv) {    
	//Element.hide('ctl00_ContentPlaceHolder_ContentRenderer_Edit');    
	//Element.hide('modalBackgroundDiv');
	Element.hide(div);    
	Element.hide(bgDiv);	
}

function getBrowserWindowSize() {    
	var winW = 630, winH = 460;    
	if (parseInt(navigator.appVersion)>3) {        
		if (navigator.appName=="Netscape") {            
		winW = window.innerWidth;            
		winH = window.innerHeight;        
		}        
	if (navigator.appName.indexOf("Microsoft")!=-1) {            
		winW = document.body.offsetWidth;            
		winH = document.body.offsetHeight;        
	}  
	if (navigator.appVersion.indexOf("MSIE 7")!=-1) {            
		winW = screen.width;            
		winH =screen.height;        
	}

	}    
	var rval = {        
	width: winW,        
	height: winH    
};    

return rval;
}



var $j = jQuery.noConflict();

$j(document).ready(function() {

    $j(".slidesNavigation a:first").addClass("active");
    var contentwidth = $j("#slidesContainer").width();
    var totalcontent = $j(".slideContent").size();
    //alert(contentwidth);
    var allcontentwidth = contentwidth * totalcontent;
    $j(".slidsHolder").css({ 'width': allcontentwidth });

    rotate = function() {
        var slideid = $jactive.attr("rel") - 1;
        var slidedistance = slideid * contentwidth;
        $j(".slidesNavigation a").removeClass('active');
        $jactive.addClass('active');
        $j(".slidsHolder").animate({ left: -slidedistance }, 500);
    };

    rotation = function() {
        play = setInterval(function() {
        $jactive = $j('.slidesNavigation a.active').next();
        if ($jactive.length === 0) {
            $jactive = $j('.slidesNavigation a:first');
            }
            rotate();
            //Timer speed 5 sec
        }, 5000);
    };

    rotation();

    $j(".slidesNavigation a").click(function() {
    $jactive = $j(this);
        clearInterval(play);
        rotate();
        rotation();
        return false;
    });
		
		
		//$j("div.scrollable").scrollable({ items: '#thumbs' });
		
});



