﻿// JScript File

//<![CDATA[
 
var a=grid.rows.length-1;
var btnImgArr = new Array(a);
for(i=0;i<a;i++)
{
    btnImgArr[i] = 'Whatsnew'+i;
}  
var pause = false;
var initialcnt = 0;
var initialurl='';

var urlArray = new Array(a);
var imgArray = new Array(a);
var textArray = new Array(a);
var ArrLaunchedDate = new Array(a);
var strikePriceArray = new Array(a);
var ImgTitle=new Array(a);

var maxCounter = a-1;var previousBtnImg;var counter = 0;
var timer =3000; var timer1 ;
for (i=0;i<a;i++)
{
//    imgArray[i] ='http://<%=Session["DomainName"]%>/images/'+grid.rows[i+1].cells[5].innerHTML;
    imgArray[i] ='http://www.cbazaar.com/images/'+grid.rows[i+1].cells[4].innerHTML;
    textArray[i] ='<small>Product Code: '+grid.rows[i+1].cells[1].innerHTML+'<br/></small>';
    strikePriceArray[i] ='<small>Price: $'+Math.round(grid.rows[i+1].cells[4].innerHTML)+'<br/></small>';
    ArrLaunchedDate[i] ='<small>Launched on: '+grid.rows[i+1].cells[5].innerHTML+'</small>';
    urlArray[i] = 'http://'+strDomain+'/'+grid.rows[i+1].cells[11].innerHTML;
    ImgTitle[i]=grid.rows[i+1].cells[9].innerHTML+', '+grid.rows[i+1].cells[8].innerHTML+', '+grid.rows[i+1].cells[1].innerHTML+' - '+grid.rows[i+1].cells[2].innerHTML ;
}
var t=0;	
var j = 0;	
var p = a;	
var preLoad = new Array(); 
for (i = 0; i < p; i++)	
{
    preLoad[i] = new Image();preLoad[i].src = imgArray[i]; preLoad[i].title=ImgTitle[i]; preLoad[i].alt=ImgTitle[i];
}
function runSlideShow()
{  
    if (pause)
    {
        return;
    }  
    if (document.getElementById)
    { 
        if(counter > maxCounter)
            counter = 0;
        if(typeof(ChangeColor) == 'function')
        {
            ChangeColor(counter);
        }
        if (document.getElementById('WhatsnewImage')!=null)
        if (document.getElementById('WhatsnewPrdName')!=null)
        {
            if (initialcnt==0)
            {   
                initialurl =document.getElementById('WhatsnewPrdDetails').href;
                var firstpos=initialurl.lastIndexOf('?');
                initialurl=initialurl.substring(firstpos,initialurl.length);
            } 
        initialcnt = 1 ;
        }
    { 
        document.getElementById('WhatsnewPrdName').href  = urlArray[counter]+initialurl;
    }
    document.getElementById('WhatsnewImage').style.filter='blendTrans(duration=4)';
    if (document.getElementById('WhatsnewPrdName')!=null)
    { 
        document.getElementById('WhatsnewImage').style.filter='blendTrans(duration=crossFadeDuration)';
    }
    if (document.getElementById('WhatsnewPrdName')!=null)
    { 
        if(document.all)document.getElementById('WhatsnewImage').filters.blendTrans.Apply() ;
    }
    }
    if (document.getElementById('WhatsnewImage')!=null) 
    {
        document.getElementById('WhatsnewImage').src = preLoad[counter].src;
        document.getElementById('WhatsnewImage').title = preLoad[counter].title;
        document.getElementById('WhatsnewImage').alt = preLoad[counter].title;
    }
    if (document.getElementById('WhatsnewPrdName')!=null)
    { 
        document.getElementById('WhatsnewPrdName').innerHTML  = textArray[counter];
    }
    if (document.getElementById('WhatsnewPrdPrice')!=null)
    { 
        document.getElementById('WhatsnewPrdPrice').innerHTML  = ArrLaunchedDate[counter];
    }
    if (document.getElementById('WhatsnewPrdStrikePrice')!=null)
    { 
        document.getElementById('WhatsnewPrdStrikePrice').href  = urlArray[counter]+initialurl;
    }
    if (document.getElementById('WhatsnewPrdPrice')!=null)
    { 
        document.getElementById('WhatsnewPrdPrice').href  = urlArray[counter]+initialurl;
    }
    if (document.getElementById('WhatsnewPrdName')!=null)
    if (document.getElementById('WhatsnewPrdDetails')!=null)
    { 
        document.getElementById('WhatsnewPrdDetails').href  = urlArray[counter]+initialurl;
    }
    if (document.getElementById('WhatsnewPrdBuyBtn')!=null)
    { 
        document.getElementById('WhatsnewPrdBuyBtn').href  = urlArray[counter]+initialurl;
    }
    if (document.all)
    {
        if (document.getElementById('WhatsnewImage')!=null)
        {
            document.getElementById('WhatsnewImage').filters.blendTrans.Play();
        }
    } 
    t = setTimeout('runSlideShow()',timer);
    if (pause==false)counter++;
    }
    t = setTimeout('runSlideShow()', timer);
    
    
function changeImage()
{
    if(counter > maxCounter)
        counter = 0;
    if(typeof(ChangeColor) == 'function')
    {
        ChangeColor(counter)
    };
    if (document.getElementById('WhatsnewImage')!=null)
    if (document.getElementById('WhatsnewPrdName')!=null)
    {
        if (initialcnt==0)
        {   
            initialurl =document.getElementById('WhatsnewPrdDetails').href;
            var firstpos=initialurl.lastIndexOf('?');
            initialurl=initialurl.substring(firstpos,initialurl.length);
        } 
        initialcnt = 1 ;
    }
    {
        document.getElementById('WhatsnewImage').src  = imgArray[counter] ;
        document.getElementById('WhatsnewImage').title  = ImgTitle[counter] ;
    }
    if (document.getElementById('WhatsnewPrdName')!=null)
    { 
        document.getElementById('WhatsnewPrdName').innerHTML  = textArray[counter];
    }
    if (document.getElementById('WhatsnewPrdPrice')!=null)
    { 
        document.getElementById('WhatsnewPrdPrice').innerHTML  = ArrLaunchedDate[counter];
    }
    if (document.getElementById('WhatsnewPrdStrikePrice')!=null)
    { 
        document.getElementById('WhatsnewPrdStrikePrice').href  = urlArray[counter];
    }
    if (document.getElementById('WhatsnewPrdPrice')!=null)
    {   
        document.getElementById('WhatsnewPrdPrice').href  = urlArray[counter]+initialurl;
    }
    if (document.getElementById('WhatsnewPrdName')!=null)
    {   
        document.getElementById('WhatsnewPrdName').href  = urlArray[counter]+initialurl;
    }
    if (document.getElementById('WhatsnewPrdDetails')!=null)
    { 
        document.getElementById('WhatsnewPrdDetails').href  = urlArray[counter]+initialurl;
    }
    if (document.getElementById('WhatsnewPrdBuyBtn')!=null)
    {   
        document.getElementById('WhatsnewPrdBuyBtn').href  = urlArray[counter]+initialurl;
    } 
    if (pause==false) 
        timer1 = window.setTimeout('changeImage()', timer);
    if (pause==false)
        counter++;
}
          
    function ChangeColor(index)
    {
	    for(i=0;i < btnImgArr.length; i++)
	    {
	        if (document.getElementById(btnImgArr[i])!=null)
		    {
		        if(i==index)
		        {
			        var val = document.getElementById(btnImgArr[i]);
                    val.className = 'GalleryItemSelected';
		        }
		        else
		        {
			        var val = document.getElementById(btnImgArr[i]);
                    val.className = 'GalleryItemUnSelected';
		        }
		    }
	    }

    }
//]]>
