﻿$(function() {
    firstImg = findActive('#sliderImgContainer IMG.active', 'right').$active; 
    firstDiv = findActive('#sliderTextContainer DIV.active', 'right').$active; 
    setInterval( "slideSwitch('right')", 30000);
    setInterval("certificateSwitch()", 3000);
    initFancyBox();
	activeTabId = 1;
	initCorners();
	certificateAutomaticSwitch = true;
	// initialize scrollable with mousewheel support
	$(".scrollable").scrollable({ vertical: true, mousewheel: true });	
	disableSelection(document.body);	    	
	initEnquiry();
	setSelectedMenuItem();
	Sys.WebForms.PageRequestManager.getInstance().add_endRequest(updatePanelEndRequest);
});



function slideSwitch(direction) {    
    element = findActive('#sliderImgContainer IMG.active', direction);
    if (element.$next.length == 0){
        //repeat it in loop
        element.$next = firstImg;
    }    
    changeSlide(element.$active, element.$next);
    element = findActive('#sliderTextContainer DIV.active', direction);
    if (element.$next.length == 0){
        //repeat it in loop
        element.$next = firstDiv;
    }    
    changeSlide(element.$active, element.$next);    
}

function findActive(expression, direction){
    var $active = $(expression);
    var $next;
    if (direction  == 'right'){
        $next = $active.next();
    }else{
        $next = $active.prev();
    }
    
    return new SlideElement($active,$next);
    
}

function certificateSwitch(){
        jQuery('.certImgScrollTop')[0].click();        
}

