function switchClass(myElement, className1,className2){

if (myElement.className == className1){
 myElement.className = className2;
 }else{
 myElement.className = className1;
 }
}

function switchImage(myElement, src1,src2){

if (myElement.src.indexOf(src1)>-1){
 myElement.src = src2;
 }else{
 myElement.src = src1;
 }
}

function siteLayout(){

	this.minWidth = 1000;
	this.maxWidth = 1100;

}


siteLayout.prototype.ResizeSite = function(){

	if($('siteTable')) {
	
		var siteTable = document.getElementById("siteTable");
		siteTable.border =0;
		
		
		//table siteTable moet 100% breed zijn, maar mag niet breder worden dan maxWidth en niet smaller dan minWidth
		if (document.body.clientWidth < this.minWidth){
			siteTable.style.width = this.minWidth+'px';
			}
		if (document.body.clientWidth > this.minWidth && document.body.clientWidth < this.maxWidth){
			siteTable.style.width = '100%';
			}
		if (document.body.clientWidth > this.maxWidth){
			siteTable.style.width =  this.maxWidth+'px';
			}
			
		// vertraag de zichtbaarheid van het rechtermenu
		if($('siteRight')) {
			$('siteRight').setStyle({display:'block'});		
		}
	}
}

siteLayout.prototype.ResizeBackground = function(){
	var siteBackgroundImage =  document.getElementById("siteBackgroundImage");	
	var siteBackground = document.getElementById("siteBackground");	
	//div siteBackground mag niet kleiner worden dan minWidth
	if (document.body.clientWidth < this.minWidth){
		siteBackground.style.width = this.minWidth+'px';
		}else{
			siteBackground.style.width = '100%';
		}

	//het plaatje op ware grootte
	siteBackgroundImage.style.height = 'auto';
	siteBackgroundImage.style.width = 'auto';

	//eerst in de breedte schalen
	siteBackgroundImage.style.width = '100%';
	siteBackgroundImage.style.height = 'auto';

	//als de hoogte van het plaatje (sitebackgroundimage) kleiner is dan de hoogte, schalen we em in de hoogte.
	if(siteBackgroundImage.clientHeight < siteBackground.clientHeight){
	siteBackgroundImage.style.width = 'auto';
	siteBackgroundImage.style.height = '100%';
	}
}

siteLayout.prototype.Resize = function(){

this.ResizeSite();
this.ResizeBackground();

}

siteLayout = new siteLayout();

function resizeShizzle(){
	siteLayout.Resize();
}
window.onresize = resizeShizzle;


function switchClass(myElement, className1,className2){

if (myElement.className == className1){
	myElement.className = className2;
	}else{
	myElement.className = className1;
	}
}

// wis inputvelden default text
function clearDefault(el) {
	if (el.defaultValue==el.value) el.value = ""
}


// mailto:
function mailTo(nameVar, domainVar) {
 document.write('<a href=\"mailto:' + nameVar + '@' + domainVar + '\">');
 document.write(nameVar + '@' + domainVar + '</a>');
}



/*Dropdown*/
function DropDown(el){
	this.timer = null;
	this.dropDownElement = el;
	this.isOpened = false;
	this.timeoutString = "document.getElementById('"+el+"').style.display='none';";
}

DropDown.prototype.Open  = function(){
	//clearTimeout(this.timer);
	
	if(this.timer){
		clearTimeout(this.timer);
	}
	document.getElementById(this.dropDownElement).style.display='block';
	
	//var thisObj = this;
	//setTimeout(function(thisObj) { thisObj.Hide(); },10000,this);
}
DropDown.prototype.KeepOpened = function(){
	if(this.timer){
		clearTimeout(this.timer);
	}
}

DropDown.prototype.Close = function(){
	
	ts=this.timeoutString;
	this.timer = setTimeout(ts,1000);
}


WebsiteDropDown = new DropDown('vicreaWebsites');











/*SHOWREEL*/

// read variable from locationbar
function getURLVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
				   return pair[1];
		}
	}
	return "";
}

// Flash communicatie
function getId() {
	
	var showreelId = getURLVariable("id");
	
	if (showreelId == ""){
	showreelId = 1;
	}
	
	thisMovie("showreel").playIdInFlash(showreelId);
	showCasestudy(showreelId);
	return showreelId;
}
function showCasestudy(id) {
	// showcase
	for (var i=0;i<portfolioMax;i++) {
		var casestudyDiv = document.getElementById("id"+i);
		if (casestudyDiv) {
			document.getElementById("id"+i).style.display = 'none';
			if (i == id) document.getElementById("id"+id).style.display = 'block';
		}
	}
}
function setId(id) {
	//scroll to flash anchor
	location.href = '#flash';
	thisMovie("showreel").setShowreelInFlash(false);
	thisMovie("showreel").playIdInFlash(id);
	showCasestudy(id);
}
function checkShowreel() {
	var showreelBoolean = getURLVariable("showreel");
	if (showreelBoolean) thisMovie("showreel").setShowreelInFlash(showreelBoolean);
}

// Function that points to a specific flash movie
      function thisMovie(movieName) {
          if (navigator.appName.indexOf("Microsoft") != -1) {
              var movie = document.getElementById(movieName);
              return movie;
      }         
          else {
              return document[movieName]
          }
      }


/*
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    } else {
        return document[movieName]
    }
}
*/


/*einde SHOWREEL*/
