var imageRotationTime = 8000;
var numberslide = new Array();


//var serverPath='/wp-content/themes/revolution_magazine-30/revolution_magazine-30/';
var serverPath='http://www.whatshaute.com/wp-content/themes/revolution_magazine-30/revolution_magazine-30/';

numberslide[0] = [serverPath+"scroll/house-of-versace-book-main.jpg","http://whatshaute.com/index.php/2010/02/win-it-one-of-5-copies-of-house-of-versace-the-untold-story-of-genius-murder-and-survival/","House of Versace","Enter to win the book by Deborah Ball!"];
numberslide[1] = [serverPath+"scroll/fall-2010-fashion-week.jpg","http://whatshaute.com/index.php/tag/new-york-fashion-week/","New York Fashion Week","Reviews of the Fall 2010 collections and bye to Bryant Park"];
numberslide[2] = [serverPath+"scroll/jean-paul-gaultier-main.jpg", "http://whatshaute.com/index.php/2010/02/jean-paul-gaultier-rocks-the-house-with-designer-collaborations-collection-at-target/","Jean Paul Gaultier + Target","Preview the collaboration before it hits stores on March 7!"];
numberslide[3] = [serverPath+"scroll/sample-sales-main.jpg", "http://whatshaute.com/index.php/category/shopping/sales-events/","Exclusive online sample sales","Click to sign up and shop!"];
numberslide[4] = [serverPath+"scroll/twitter-main.jpg","http://twitter.com/whatshaute","What's Haute is on Twitter!","Are you following us?"];

var mylinktarget = "";
var mylinkcolor = "black";
var mylinkcolorSelected = "#f5506e";
var imageHeight=240;
var imageWidth=365;

var imgborderwidth = 2;

/////END END END///////////////

var preloadit = new Array()

for (i = 0; i < numberslide.length; i++)
    {	
    preloadit[i] = new Image()
    preloadit[i].src = numberslide[i][0];
    }

var currentindex = ""

function changeslides(which)
    {		
    var imghtml = ""
    currentindex = (which == "initial") ? 0 : parseInt(which)
    var mode = (which == "initial") ? "initial" : ""
    var which = (mode == "initial") ? numberslide[0] : numberslide[which];

	setTitleSubject(which);

    if (which[1] != "")
        imghtml = '<a target="_blank" href="' + which[1] + '" target="' + mylinktarget + '">'

    imghtml += '<img title="'+which[2]+'" style="border-color:#f5506e;" src="' + which[0] + '"  height="' + imageHeight + '" width="' + imageWidth + '"border="' + imgborderwidth + '">'

    if (which[1] != "")
        imghtml += '</a>'

    if (mode == "initial")
        document.write('<div >' + imghtml + '</div>')

    else
        {
        document.getElementById("imagecontainer").innerHTML = imghtml;
        changecolors();
        }
    }

function createnumbers()
    {
    document.write('<a title="'+numberslide[0][2]+'" style="font: bold 16px Arial;text-decoration: none;" href="javascript:changeslides(0)" style="color:'
                       + mylinkcolorSelected + '">1</a> ');
    for (i = 1; i < numberslide.length; i++){	
        document.write('<a title="'+numberslide[i][2]+'" style="font: bold 16px Arial;text-decoration: none; color:black;" href="javascript:changeslides(\'' + i
                           + '\')">' + eval(i + 1) + '</a> ');
		}
    }

function changecolors()
    {
    var numberobj = document.getElementById("numberDiv")
    numberlinks = numberobj.getElementsByTagName("A");

    for (i = 0; i <= currentindex; i++){		
		 numberlinks[i].style.color = mylinkcolorSelected;		     
		if (currentindex > i){			
			numberlinks[i].style.color = mylinkcolor;			
			}
			if (currentindex+1 < i){			
			numberlinks[i].style.color = mylinkcolor;			
			}			
		}	

    for (i = currentindex + 1; i < numberslide.length; i++){	
		 numberlinks[i].style.color = mylinkcolor;		
		}
       
    }

function goforward(continueInc)
    {
		
    if (!continueInc)
        {
        stopIncCounter();
        startIncCounter();
        }

    if (currentindex < numberslide.length - 1)
        {
        changeslides(currentindex + 1);
        }

    else
        {
        changeslides(0);
        }
    }

function goback(continueInc)
    {
    if (!continueInc)
        {
        stopIncCounter();
        startIncCounter();
        }

    if (currentindex != 0)
        {
        changeslides(currentindex - 1);
        }

    else
        {
        changeslides(numberslide.length - 1);
        }
    }

function stopIncCounter()
    {
    clearIncCounter();
    }

function startIncCounter()
    {
    clearIncCounter();
    incrementImages = setInterval("goforward(true)", imageRotationTime);
    }

function clearIncCounter()
    {
    clearInterval(incrementImages);
    }

var incC = 0;

function pauseCounter()
    {
    incC++;

    if (incC == 1)
        {
        stopIncCounter();
        }

    else
        {
        startIncCounter();
        incC = 0
        }
    }

var incrementImages;
incrementImages = setInterval("goforward(true)", imageRotationTime);

 if (window.attachEvent){
        window.attachEvent("onresize", function(){try{var subTit = document.getElementById("titleSubject");subTit.innerHTML = subTit.innerHTML;}catch(e){}});    		
        }		
		

function setTitleSubject(titleItem){
var titleSubString='';		
	titleSubString += '<div id="titleSubject" style="opacity:0.70;filter:alpha(opacity=70); background-color: black; width:365px; height:45px; top:-47px; left:2px; position:absolute; z-index:1" >';    
	titleSubString += '</div>';
	titleSubString += '<div style="width:365px; height:45px; top:-40px; left:2px; position:absolute; z-index:1" > ';
	titleSubString += '<span style="color:#FFFFFF; margin:5px 7px 10px 10px; font-size:20px; font-weight:bold; font-style:italic;">'+titleItem[2]+'</span>';
	titleSubString += '<br />';
  	titleSubString += '<span style=" font-size:12px; font-weight:bold; font-style: normal;"><a id="subTitle" href="'+titleItem[1]+'">'+titleItem[3]+'</a></span>';
	titleSubString += '</div>';	
	
	if(document.getElementById("titleSubjectHolder")!= null){		
		var subHolder = document.getElementById("titleSubjectHolder");subHolder.innerHTML = titleSubString;
		}
		else
		{		
	setTimeout(function(){var subHolder = document.getElementById("titleSubjectHolder");subHolder.innerHTML = titleSubString;},250);
	}
	}
			

