// JavaScript Document




var initialised; // variable is set to true when all on the page has been initialised. All the necessary javascript has been executed. Othe code can start working only after this variable is initialised to true.

// keeps the name (as a string) of the currently active cathegory link.
var which_cat_active="all";

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImgRestoreGallery(whichLayer) { //v3.0
var style = document.getElementById(whichLayer).style;
if(style.display == "none" || style.display == ""){
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
 }
} 

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}



function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 




//function to change bck image for a particular element with id atribute value set to _id_  using  the new immage in _url_ 
//it looks in css and the element must have the background using the css style information like: background-image:url(imagini/crenguta_omuletianimati1.gif);
//this function it will usually be used in the attributes onMouseOver and onMouseOut onMouseClick etc
function changeBgImage(id,url)
{	
	
	if (document.getElementById)
	{
		// this is the way the standards work (Firefox)
		var style = document.getElementById(id).style;
		
		style.backgroundImage = 'url("' + url + '")';
	
	}
	else if (document.all)
	{
		// this is the way old msIE versions work
		var style = document.all[id].style;
		
		style.backgroundImage = 'url("' + url + '")';
	
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style = document.layers[id].style;
		style.backgroundImage = 'url("' + url + '")'; 
	
	}


}


function changeBorderColor(id,color)
{	
	
	if (document.getElementById)
	{
		// this is the way the standards work (Firefox)
		var style = document.getElementById(id).style;
		
		style.borderTopColor = color;
		style.borderBottomColor = color;
		
	
	}
	else if (document.all)
	{
		// this is the way old msIE versions work
		var style = document.all[id].style;
		
		style.borderTopColor = color;
		style.borderBottomColor = color;
	
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style = document.layers[id].style;
		style.borderTopColor = color;
		style.borderBottomColor = color; 
	
	}


}


function changeFontColor(id,fontColor)
{	

	if (document.getElementById)
	{
		// this is the way the standards work (Firefox)
		var style = document.getElementById(id).style;
		
		style.color = fontColor;
		
	
	}
	else if (document.all)
	{
		// this is the way old msIE versions work
		var style = document.all[id].style;
		
		style.borderTopColor = color;
		style.borderBottomColor = color;
	
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style = document.layers[id].style;
		style.borderTopColor = color;
		style.borderBottomColor = color; 
	
	}
	

}

// this function is used only in the sub-menu with the cathegories
function changeFontColorCat(id,fontColor)
{	
// the first if tests to see if we are on another cathegory than the active one
	if(which_cat_active.indexOf(id) < 0){
	if (document.getElementById)
	{
		// this is the way the standards work (Firefox)
		var style = document.getElementById(id).style;
		
		style.color = fontColor;
		
	
	}
	else if (document.all)
	{
		// this is the way old msIE versions work
		var style = document.all[id].style;
		
		style.borderTopColor = color;
		style.borderBottomColor = color;
	
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style = document.layers[id].style;
		style.borderTopColor = color;
		style.borderBottomColor = color; 
	
	}
	}

}

function showCatPort(cathegory) // all IDs from portofolio must start with "port_" then followed by the name of the cathegory
{

if(which_cat_active.indexOf(cathegory) < 0)
{
	var divuri = document.getElementsByTagName("div");
var i; //an index
var myid; //an id name

// check first if we set visible "all" or only one cathegory
var allBool;
if(cathegory.indexOf("all")<0)
{
allBool = 0;
}else {
allBool = 1;
}

for(i=0; i < divuri.length; i++)
{
myid = divuri[i].id;
if(myid){
if(myid.indexOf("port") == 0)
{
if(allBool)
{
divuri[i].style.display = "block";
}else if(myid.indexOf(cathegory) < 0)
{
divuri[i].style.display = "none";
}else if(myid.indexOf(cathegory) >= 0)
{
divuri[i].style.display = "block";
}
}
}
}

// now we change the look of the cathegory menu to reflect the fact that we changed it

var imguri = document.getElementsByTagName("img");
for(i=0; i < imguri.length; i++)
{
	myid = imguri[i].id;
if(myid){
	if(myid.indexOf("img") >= 0){
	if(myid.indexOf(which_cat_active) >= 0){
		imguri[i].src = "images/arrow_submenu_inactive.gif";
	} else if(myid.indexOf(cathegory) >= 0){
		imguri[i].src = "images/arrow_submenu_active.gif";
	}
	}
}
}
changeFontColor(which_cat_active,"#ffffff");
changeFontColor(cathegory,"#ffffff");
which_cat_active = cathegory;
	
}

} 

   



