$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");

//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;

//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});

//Paging  and Slider Function
rotate = function(){
    var triggerID = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

    $(".paging a").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

    //Slider Animation
    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500 );

}; 

//Rotation  and Timing Event
rotateSwitch = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.paging a.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.paging a:first'); //go back to first
        }
        rotate(); //Trigger the paging and slider function
    }, 7000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitch(); //Run function on launch

//On Hover
$(".image_reel a").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitch(); //Resume rotation timer
});

//On Click
$(".paging a").click(function() {
    $active = $(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotate(); //Trigger rotation immediately
    rotateSwitch(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
});

});


i=0;
img_a=new Array();       
img_a[0]=new Image();
img_a[1]=new Image();
img_a[2]=new Image();

img_a[0].src="img/Center_Pic1_3secA.jpg";
img_a[1].src="img/Center_Pic2_4sec.gif";
img_a[2].src="img/Center_Pic3_4sec.jpg";

url_a = new Array();
url_a[0]="http://www.ou-link.ru/ou/";
url_a[1]="http://www.ou-link.ru/prog/";
url_a[2]="http://www.ou-link.ru/prog/mba.htm";



/* function img_b()          
{
document.images["dod"].src=img_a[i].src;

i++;
if(i>2) i=0;
setTimeout("img_b()", 4500);
} 

function openWin() {
  myWin= open(url_a[i]);
} */




var tID;
var tID2;
var tID3;
var tID4;
var tID5;
 
	function show_div(arg1) {
	if (document.getElementById(arg1).style.display  == "none")
		document.getElementById(arg1).style.display  = "block";
	}
	
	function hide_div(arg2) {
	if (document.getElementById(arg2).style.display  == "block")
		document.getElementById(arg2).style.display = 'none';
	}
	
		function extra_div(arg1) { 
        return; /*
		document.getElementById('marq1').scrollAmount=0;
	if (arg1=="cln") {
		tID=setTimeout("document.getElementById('showextra').style.display='none'",900);
		document.getElementById('marq1').scrollAmount=1;
		}
		else { 
			if (tID != undefined) {
				clearTimeout(tID);
				document.getElementById('showextra').style.display='none';
			}
			if (document.getElementById('showextra').style.display  == "none") {
			document.getElementById('showextra').style.display  = "block";
			document.getElementById('rc_mini_text').innerHTML="Здесь будет мини-профайл по РЦ <br><br>"+arg1.innerHTML+"<br><br>РЦ смогут редактировать его, по желанию, сами из раздела сайта администраторов РЦ";
			}
		} */
	}
	
	function setScrollSpeed(speed,direct) {
		if (tID2 != undefined) clearTimeout(tID2);
		if (tID3 != undefined) clearTimeout(tID3);
		if (tID4 != undefined) clearTimeout(tID4);
	document.getElementById('marq1').scrollAmount=speed;
	document.getElementById('marq1').direction=direct;
	if (speed==0)	{
		tID2=setTimeout("document.getElementById('marq1').scrollAmount=1",5000);
		tID3=setTimeout("document.getElementById('marq1').direction='up'",4990);
		}
	if (speed>1)	{
		tID4=setTimeout("document.getElementById('marq1').scrollAmount=1",5000);
		}	
		
	}
	
	function winopen(winname) {
		// if (tID5 != undefined) clearTimeout(tID5);
		document.getElementById('rclistdiv').style.display  = "block";
		document.getElementById('rclistframe').src  = "rc/"+winname+".htm";
		// tID5=setTimeout("document.getElementById('rclistdiv').style.display='none'",12000);
	};
	
