var slideOn = 0;
function slideShow()
{
        imgId = -1;
        slideOn = (slideOn == '0')?1:0;
        setTimeout('next()',1000); 
}
function previous()
{
        if(imgId>0)
                imgId--;
	else 
		slideOn = 0;
        if(imageArray[imgId][1] == '')
                Desc ="<br/><br/>";
        else
                Desc = imageArray[imgId][1];

        document.getElementById('imgsrc').src = imageArray[imgId][0];
		document.getElementById('imgsrc').alt = imageArray[imgId][4];
		document.getElementById('imgsrc').title = imageArray[imgId][4];
		if(imageArray[imgId][3]!='')
		{
		 document.getElementById('imgsrc').onclick=function(){window.location.href=imageArray[imgId][3];}
		 document.getElementById('imgsrc').style.cursor='pointer';
		}
		else{
		document.getElementById('imgsrc').style.cursor='';
		document.getElementById('imgsrc').onclick='';
		}  
        document.getElementById("DescContent").innerHTML = Desc;
        display();
}
function next()
{
        if(imgId<(maxNum-1))
                imgId++;
	else 
		slideOn = 0;
        if(imageArray[imgId][1] == '')
                Desc ="<br/><br/>";
        else
                Desc = imageArray[imgId][1];    
        document.getElementById('imgsrc').src = imageArray[imgId][0];
		document.getElementById('imgsrc').alt = imageArray[imgId][4];
		document.getElementById('imgsrc').title = imageArray[imgId][4];
		if(imageArray[imgId][3]!='')
		{
		 document.getElementById('imgsrc').onclick=function(){window.location.href=imageArray[imgId][3];}
		 document.getElementById('imgsrc').style.cursor='pointer';
		}
		else{
		document.getElementById('imgsrc').style.cursor='';
		document.getElementById('imgsrc').onclick='';
		}  
        document.getElementById("DescContent").innerHTML = Desc;
                display();
}
function display()
{

        if(imgId=='0')
        {
        document.getElementById("topnav").innerHTML="<span class='ssvLink' style='margin-left:5px;font-size:18px;color:"+fgcolor+";?>' id='next' name='next'><a onclick = 'javascript:slideOn=0;next();' style='cursor:pointer;display:inline;' href='#galname'>Next</a></span>";
        }
        if(imgId==(maxNum-1))
        {
			var link='';
         if(maxNum != 1) {
        link="<span class='ssvLink' style='margin-left:5px ;font-size:18px;color:"+fgcolor+";?>;display:inline;' id='previous' name='previous'><a onclick = 'javascript:slideOn=0;previous();' style='cursor:pointer;' href='#galname'>Previous</a></span><span id='separator' name='separator' class='style11' style='margin-left:5px; margin-right:5px;display:inline;'>|</span>";
				              document.getElementById("topnav").innerHTML="<span class='ssvLink' style='margin-left:5px ;font-size:18px;color:<?=$FgColor;?>;display:inline;' id='previous' name='previous'><a onclick = 'javascript:slideOn=0;previous();' style='cursor:pointer;' href='#galname'>Previous</a></span><span id='separator' name='separator' class='style11' style='margin-left:5px; margin-right:5px;display:inline;'>|</span>";

         }
        if(document.getElementById('show_postgallery_ad') && document.getElementById('show_postgallery_ad').value==1)
            document.getElementById("topnav").innerHTML=link+"<span class='ssvLink' style='margin-left:5px;font-size:18px;' id='more' name='more'><a href='javascript: showPostGalleryAd();' style='cursor:pointer;display:inline;color:"+fgcolor+";' href='#galname'>Next</a></span>";
        else
            document.getElementById("topnav").innerHTML=link+"<span class='ssvLink' style='margin-left:5px;font-size:18px;' id='more' name='more'><a href='"+moreurl+"' style='cursor:pointer;display:inline;color:"+fgcolor+";'>More</a></span>";
        }
        if ((imgId!=(maxNum-1))&& (imgId!='0'))
        {
                        document.getElementById("topnav").innerHTML="<span class='ssvLink' style='margin-left:5px ;font-size:18px;color:"+fgcolor+";display:inline;' id='previous' name='previous'><a onclick = 'javascript:slideOn=0;previous();' style='cursor:pointer;' href='#galname'>Previous</a></span><span id='separator' name='separator' class='style11' style='margin-left:5px; margin-right:5px;display:inline;'>|</span><span class='ssvLink' style='margin-left:5px;font-size:18px;color:"+fgcolor+";' id='next' name='next'><a onclick = 'javascript:slideOn=0;next();' style='cursor:pointer;display:inline;' href='#galname'>Next</a></span>";
        }
        document.getElementById("bottomnav").innerHTML=document.getElementById("topnav").innerHTML;
        imgReplace = document.getElementById('hidImgTrack').src.substring(0,document.getElementById('hidImgTrack').src.lastIndexOf('&')) + "&slide=" + imageArray[imgId][2];
        document.getElementById('hidImgTrack').src = imgReplace;
        var loc = window.location.href;
		var locArray = loc.split("-");
		var IdArray =  locArray[locArray.length-1].split(".");
		var newId = IdArray["0"];
        imgReplacew = "http://www.sify.com/finance/imagegallery/galleryDetail1.php?id="+newId +"&slide=" + imageArray[imgId][2];
        document.getElementById('hidImgTrackw').src = imgReplacew;

        var iframeArray = document.getElementsByTagName('iframe');
        for(i=0;i<iframeArray.length;i++)
        {
        var srcnew="";
                if((iframeArray[i].id != 'hidImgTrack') && (iframeArray[i].id != 'postcomments') && (iframeArray[i].id  != 'latest_comments') && (iframeArray[i].id != 'googleads') && (iframeArray[i].id != 'imgscroller'))
                {
                        srcnew = iframeArray[i].src;
			if(srcnew) {
                           iframeArray[i].src = srcnew;
                        }
                        srcnew="";
                }
        }
        if(slideOn == 1)
                setTimeout('next()',4000);
		if(imageArray[imgId][3]!='')
		{
		 document.getElementById('imgsrc').onclick=function(){window.location.href=imageArray[imgId][3];}
		 document.getElementById('imgsrc').style.cursor='pointer';
		}
		else{
		document.getElementById('imgsrc').style.cursor='';
		document.getElementById('imgsrc').onclick='';
		}  
}


