var videoList = {
    container: "videoList",
    items: [],
    videos: null,
    first: null,
    header: null
}

videoList.init = function(vids){
    this.videos = vids;
    for(var sProp in vids){
        this.items.push(sProp);                
    }
    this.first = this.items[0];
    this.header = this.items[1];
    this.changeVideo(this.items[0],this.first,this.header);
}

videoList.changeVideo = function(vid,first,header){
    
    var ofr = document.createDocumentFragment();
    var pContainer = document.getElementById(this.container);
    for(var sProp in this.videos){
    	if(sProp == this.first){
    		var oLi = document.createElement("li");  
    		oLi.setAttribute('class', 'first'); 
    		oLi.setAttribute('className', 'first');		
    	}
    	
    	else if(sProp == this.header){
    		var oLi = document.createElement("li");  
    		oLi.setAttribute('class', 'header'); 
    		oLi.setAttribute('className', 'header');		
    	}
    	
    	else {
    		var oLi = document.createElement("li");
    	}
    	
       if(vid != sProp){
       		if (sProp != this.header) {
            var oA = document.createElement("a");
            oA.href = "javascript:videoList.changeVideo('" + sProp + "',this.first,this.header);";
            oA.appendChild(document.createTextNode(this.videos[sProp]));
            oLi.appendChild(oA);
       		}
       		else {
       		oLi.appendChild(document.createTextNode(this.videos[sProp]));	
       		}
       }
       
       else{
            oLi.appendChild(document.createTextNode(this.videos[sProp]));
            oLi.setAttribute('class', 'active');
            oLi.setAttribute('className', 'active');	
        }
        ofr.appendChild(oLi);
    }

    while(pContainer.hasChildNodes())
        pContainer.removeChild(pContainer.firstChild);

    pContainer.appendChild(ofr);
    
	var flashvars = {
		source: "../videos/" + vid + ".flv",
		color: "E40E62",
		mlc: "/nokia+events/ovi_event/"
	}
	swfobject.embedSWF("swf/flvplayer.swf", "videoPlayer", "480", "360", "9.0.0", "swf/expressInstall.swf", flashvars);
}
