var count=1;
var Projects= new Array();

$( function(){
	//slider
        $.ajax({
		type: "GET",
		url: "http://evansofts.com/data/slider.data.php?silentkey=R87GPI786G5",
		dataType: "xml",
		success: function (xml){
                    $(xml).find("project").each(function(intIndex)
                    {
                        project=new Object();
                        project.image=$(this).find("image").text();
                        project.title=$(this).find("title").text();
                        project.description=$(this).find("description").text();
                        project.more=$(this).find("more").text();
                        project.contribute=$(this).find("contribute").text();
                        project.download=$(this).find("download").text();
                        Projects [intIndex]=project;
                    });                    
                    setInterval(Slide,5000) ;
                }
        });
	//video list
	$('ul#video-list a').click(function(){
		videosrc=$(this).attr('href');
		embedElem='<embed style="z-index:-1000" src="'+videosrc+'" type="application/x-shockwave-flash" width="480" height="267" allowscriptaccess="always" allowfullscreen="true"></embed>';
		$('div#player').html(embedElem);
		return false;
	});
});


function Slide() {
    //get element from the page
    imageElem=$("div#featured-screenshot img");
    titleElem=$("div#description h3");
    descriptElem=$("div#description p");
    moreElem=$("a#projectmore");
    contriElem=$("a#contribute");
    downloadElem=$("a#download");
    //set current project
    CProject = Projects[count];
    //animation and change properties in the background

    imageElem.fadeTo(650, 0.1, function(){
        imageElem.attr("src", CProject.image);
    });
    titleElem.fadeOut(450, function(){
        titleElem.text(CProject.title);
    })
    descriptElem.fadeOut(450,function(){
        descriptElem.text(CProject.description);
    }) ;
    moreElem.fadeOut(450,function(){
        moreElem.attr("href",CProject.more );
    }) ;

    // changing  withou animation
     contriElem.attr("href",CProject.contribute);
     downloadElem.attr("href", CProject.download);
    //restore state by animating
     imageElem.fadeTo(550, 1);
     titleElem.fadeIn(300)
     descriptElem.fadeIn(300);
     moreElem.fadeIn(300);
						
   count++ ;
   if(count>=Projects.length) {count=0}    
}


