// JavaScript Document
var scrollerwidth;
var scrollerheight;
var pausebetweenimages;
var ie;
var dom;
// The data format is MANDIRID:number_of_images:image_height:file_extension
var mandirImagesInfo = [
						
						'adl001:4:186:jpg','adl002:4:176:jpg','adl003:5:186:jpg','adl004:2:186:jpg','adl005:6:186:jpg','adl006:3:186:jpg','adl007:4:186:jpg',
						'bng001:4:185:gif',
                        
						'ctr001:2:185:gif','ctr002:3:185:gif','ctr003:5:186:jpg','ctr005:4:186:jpg','ctr006:4:186:jpg','ctr007:5:186:jpg','ctr008:3:186:jpg','ctr009:4:185:gif','ctr010:6:185:gif','ctr011:5:185:gif',
						
						'chn002:',
                        
						'gnt001:2:185:gif','gnt002:2:186:jpg','gnt003:2:185:gif','gnt004:2:185:gif','gnt005:3:185:gif','gnt006:2:185:gif','gnt007:2:185:gif','gnt008:1:185:gif','gnt009:1:185:gif','gnt010:2:185:gif','gnt011:1:186:jpg','gnt012:3:186:jpg','gnt013:2:186:jpg','gnt014:2:185:gif','gnt015:3:185:gif','gnt016:4:186:jpg','gnt017:5:186:jpg','gnt018:3:186:jpg','gnt019:6:185:gif','gnt056:4:185:gif','gnt057:6:185:gif','gnt058:2:186:jpg',
                        
						'hyd001:4:201:jpg','hyd002:5:176:jpg','hyd003:4:201:jpg','hyd004:4:185:gif','hyd005:4:201:jpg','hyd006:5:185:gif','hyd007:7:185:gif','hyd008:5:185:gif','hyd009:3:185:gif','hyd010:5:185:gif','hyd011:4:185:gif','hyd012:3:185:gif','hyd013:4:185:gif','hyd014:4:201:jpg','hyd015:4:186:jpg','hyd016:5:186:jpg','hyd017:4:185:gif','hyd018:4:185:gif','hyd019:3:185:gif','hyd020:5:185:gif','hyd021:2:186:jpg','hyd022:2:185:gif','hyd023:1:185:gif','hyd024:3:186:jpg','hyd026:4:186:jpg','hyd027:5:186:jpg','hyd028:3:186:jpg','hyd029:5:185:gif','hyd030:3:185:jpg','hyd031:7:185:gif','hyd032:4:186:jpg','hyd033:6:185:gif','hyd034:3:185:gif','hyd036:7:185:gif',
                        
						'khm001:7:186:jpg','khm002:6:186:jpg','khm003:6:186:jpg','khm004:6:186:jpg',
                        
						'ksr002:5:185:gif','ksr004:5:185:gif','ksr005:3:176:jpg','ksr006:3:176:jpg','ksr007:2:176:jpg','ksr008:2:176:jpg','ksr009:1:176:jpg','ksr010:1:176:jpg','ksr011:2:176:jpg','ksr012:2:176:jpg','ksr013:3:176:jpg','ksr014:2:176:jpg','ksr015:2:176:jpg','ksr016:2:176:jpg','ksr017:3:176:jpg','ksr018:2:176:jpg','ksr019:1:185:gif','ksr020:1:185:gif',
                        
						'nlr002:6:185:gif','nlr003:4:185:gif','nlr006:11:185:gif',
                        
						'nzbd001:6:176:jpg','nzbd002:2:185:gif','nzbd004:4:185:gif',
                        
						'pksm001:3:176:jpg','pksm003:3:176:jpg','pksm004:8:185:gif','pksm005:4:176:jpg','pksm006:4:176:jpg','pksm007:2:185:gif','pksm008:5:175:jpg','pksm010:3:176:gif','pksm012:3:176:jpg','pksm013:5:176:jpg','pksm014:2:185:gif', 	'pksm015:6:185:gif','pksm016:5:185:gif','pksm017:9:185:gif','pksm018:6:185:gif','pksm019:8:185:gif','pksm020:2:185:gif','pksm021:5:185:gif','pksm022:4:185:gif','pksm023:7:176:jpg','pksm024:4:176:jpg','pksm025:3:185:gif','pksm027:3:185:gif','pksm028:3:185:gif','pksm030:6:185:gif','pksm031:5:185:gif','pksm034:2:185:gif','pksm036:4:185:gif','pksm038:4:185:gif','pksm039:3:185:gif','pksm033:2:176:jpg','pksm035:3:176:jpg','pksm037:3:176:jpg',
                 
				 'shpr001:2:185:gif',
				 
				 'usa001:1:185:jpg','usa002:4:185:jpg','usa003:3:185:jpg','usa004:3:185:jpg','usa005:1:185:jpg','usa006:3:185:jpg','usa007:2:185:jpg',
						
				'wrgl001:1:185:gif'
						];
var mndrId;

var slideimages=new Array();
function startscroll(mandirId, delayTime){
    loadImages(mandirId);
        setTimeout("\""+startscroll_1(mandirId,delayTime)+"\"",howManyImages(mandirId)*delayTime);
}
function startscroll_1(mandirId, delayTime)
{
    setMandirId(mandirId);
    setImagesForScrolling(mandirId,delayTime);
    setMetaData();
    checkSlides();
    writingLayer();
    if (ie||dom){
        first2_obj=ie? first2 : document.getElementById("first2");
        second2_obj=ie? second2 : document.getElementById("second2")
        move3(first2_obj)
        second2_obj.style.top=scrollerheight
        second2_obj.style.visibility='visible'
    }
    else if (document.layers){
        document.main.visibility='show'
        move1(document.main.document.first)
        document.main.document.second.top=parseInt(scrollerheight)+5
        document.main.document.second.visibility='show'
    }
}

function setMandirId(mandirId){
    mndrId = mandirId;
}

function setImagesForScrolling(mandirId,delayTime){
    var mandirIds;
    setImageProperties();
    setDelayForImages(delayTime);
    for(var i=0;i<mandirImagesInfo.length;i++){
        mandirIds = mandirImagesInfo[i].split(':');
        if(mandirId==mandirIds[0]){
            for(var j=1;j<=mandirIds[1];j++){
                slideimages[j-1]='<img src="/images/saimandirs/'+mandirId+'_'+j+'.'+mandirIds[3]+'" border="0">';
            }
            break;
        }
    }
}

function loadImages(mandirId){
for(var i=0;i<mandirImagesInfo.length;i++){
        mandirIds = mandirImagesInfo[i].split(':');
        if(mandirId==mandirIds[0]){
            for(var j=1;j<=mandirIds[1];j++){
                document.write('<img src="images/saimandirs/'+mandirId+'_'+j+'.'+mandirIds[3]+'" border="0" style="display:none">');
            }
            break;
        }
    }
}

function setImageProperties(){
    scrollerwidth='225px';
    scrollerheight=getImagesHeight(mndrId)+'px';
}

function getImagesHeight(mandirId){
    var mandirIds;
    for(var i=0;i<mandirImagesInfo.length;i++){
        mandirIds = mandirImagesInfo[i].split(':');
        if(mandirId==mandirIds[0]){
            return mandirIds[2];
            break;
        }
    }
}

function howManyImages(mandirId){
    var mandirIds;
    for(var i=0;i<mandirImagesInfo.length;i++){
        mandirIds = mandirImagesInfo[i].split(':');
        if(mandirId==mandirIds[0]){
            return mandirIds[1];
            break;
        }
    }
}

function setDelayForImages(delay){
    pausebetweenimages=delay;
}

function setMetaData(){
    ie=document.all;
    dom=document.getElementById;
}

function checkSlides(){
    if (slideimages.length>2)
    i=2
    else
    i=0
}

function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",pausebetweenimages)
setTimeout("move2(document.main.document.second)",pausebetweenimages)
return
}
if (tlayer.top>=tlayer.document.height*-1){
tlayer.top-=5
setTimeout("move1(tlayer)",50)
}
else{
tlayer.top=parseInt(scrollerheight)
tlayer.document.write(slideimages[i])
tlayer.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
}

function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",pausebetweenimages)
setTimeout("move1(document.main.document.first)",pausebetweenimages)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
tlayer2.top-=5
setTimeout("move2(tlayer2)",50)
}
else{
tlayer2.top=parseInt(scrollerheight)
tlayer2.document.write(slideimages[i])
tlayer2.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
}

function move3(whichdiv){
tdiv=eval(whichdiv);
if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=1){
tdiv.style.top=0+"px"
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(second2_obj)",pausebetweenimages)
return
}
if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-1){
tdiv.style.top=parseInt(tdiv.style.top)-1+"px"
setTimeout("move3(tdiv)",15)
}
else{
tdiv.style.top=scrollerheight
tdiv.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}

function move4(whichdiv){
tdiv2=eval(whichdiv)
if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=1){
tdiv2.style.top=0+"px"
setTimeout("move4(tdiv2)",pausebetweenimages)
setTimeout("move3(first2_obj)",pausebetweenimages)
return
}
if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
tdiv2.style.top=parseInt(tdiv2.style.top)-1+"px"
setTimeout("move4(second2_obj)",15)
}
else{
tdiv2.style.top=scrollerheight
tdiv2.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}

function writingLayer(){
    document.write('<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; visibility=hide><layer id="first" left=0 top=1 width=&{scrollerwidth};>')
    if (document.layers)
    document.write(slideimages[0]);
    document.write('</layer><layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>');
    if (document.layers)
    document.write(slideimages[dyndetermine=(slideimages.length==1)? 0 : 1]);
    document.write('</layer></ilayer>');
    if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;">')
    document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
    document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:1px;">')
    document.write(slideimages[0])
    document.writeln('</div>')
    document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px;visibility:hidden">')
    document.write(slideimages[dyndetermine=(slideimages.length==1)? 0 : 1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
    }
}
