//Js for the project pages
//Pre loads all the pages

var bNew = true
// The images are loaded from JS to enable the scaling of the images
// Because you have to pass the width and height to the image to get the right image, which you only know in JS,
// Not in ASP.NET

// Dynamically (from asp.net) written array of image ids for this project

var lastLink = 0 //Store the id of the previous selected link.

ProjectTypeId = new Array();
ProjectTypeName = new Array ();

//createProjectLinks();
createProjectMenu();
showProject(0);

//Add hover class to projectmenu
jQuery('#ProjectMenu li').hover( 
function() { jQuery(this).addClass('sfhover'); },
function() { jQuery(this).removeClass('sfhover'); }
);


function createProjectMenu(){

var sLinks = '<ul>{links}</ul>'
var sLink = '<li id="Link{nr}"><a href="#" class="Item{title}" title="{title}" onclick="showProject({nr});return false"></a></li>'
var sBuild = ''

// Get all divs that are a direct Child of #ProjectContent
	jQuery('#ProjectContent > div').each(function(item){
		ProjectTypeId[item]= jQuery(this).attr('id')
		ProjectTypeName[item] = jQuery(this).attr('title')
		// Add title for current selection
		var thisLink = sLink.replace(/{title}/ig, jQuery(this).attr('title'))
		
		sBuild += thisLink.replace(/{nr}/ig, item)
		
		
	});
	sBuild += jQuery("#slideshowlink").html();
	//sBuild = sLinks.replace(/{links}/ig, sBuild)
	jQuery('#ProjectMenu').html(sBuild)
}


function showProject(id){
	
	// Reset previous link
	jQuery('#Link' + lastLink).removeClass("Active");
	lastLink = id
	
	// Set active link
	jQuery('#Link' + id).addClass("Active");
	
    for (i in ProjectTypeId){
        if (i == id){
			
            document.getElementById(ProjectTypeId[i]).className = ""
            jQuery('#ProjectMenuTitle').html(ProjectTypeName[i]);
        }
        else{
			if (ProjectTypeId[i] != ""){
				document.getElementById(ProjectTypeId[i]).className = "Hidden"
				}
        }
    }
	
	if (bNew != true){
	 reSetScroll("#ProjectContent");
	}
	bNew = false	
	
}

