﻿// JScript File
var IsMainPage=true;

var randomImgSlider={
        imgCount:4,
        cookieName:"singalovskyIMG",
        files:new Array(this.imgCount), // Array to hold filenames
        init:function(){
						this.files[0] ="/img/Templates/schoolThemeOut/slider/randomImg_1.jpg";
						this.files[1] ="/img/Templates/schoolThemeOut/slider/randomImg_2.jpg";
						this.files[2] ="/img/Templates/schoolThemeOut/slider/randomImg_3.jpg";
						this.files[3] ="/img/Templates/schoolThemeOut/slider/randomImg_4.jpg";
						/*this.files[4] ="/img/Templates/schoolThemeOut/slider/randomImg_5.jpg";*/
                       },
	    pickRandom:function (range){
				    if (Math.random) 
				     return Math.round(Math.random() * (range-1));
				    else {var now = new Date(); return (now.getTime() / 1000) % range;} 
				    },
	    setCookie:function (c_name,value,expiredays)
				    {
				      var exdate=new Date();
				      exdate.setDate(exdate.getDate()+expiredays);
				      document.cookie=c_name + "=" + value + ((expiredays==null) ? ";" : ";expires=" + exdate.toGMTString());
				    },
	    getCookie:function (c_name)
				    {
				      if (document.cookie && document.cookie.length>0)
				      {
					    c_start=document.cookie.indexOf(c_name + "=");
					    if (c_start!=-1)
					    { 
					      c_start=c_start + c_name.length+1;
					      c_end=document.cookie.indexOf(";",c_start);
					      if (c_end==-1) {
						    c_end=document.cookie.length;
					      }
					      return unescape(document.cookie.substring(c_start,c_end));
					    } 
				      }
				      return -1;
				    },
	    pickImg:function()
			    {
			      var cookie = this.getCookie(this.cookieName);
			      if (cookie != -1) {
				    this.setCookie(this.cookieName,parseInt(cookie)+1,1);
				    return (parseInt(cookie)+1) % this.imgCount;
			      }
			      else {
				    var randomImg = this.pickRandom(this.imgCount);
				    this.setCookie(this.cookieName,randomImg,1);
				    return randomImg;
			      }
			    },
	    choice:function()// Write out an IMG tag, using a randomly-chosen image name. 
			    {	
				    return this.pickImg();
			    }

};
randomImgSlider.init();



if (typeof(addEventSimple)=="function") addEventSimple(window,'load',cbb.init);



