
////generic function to replace text and pics on page 
var TextBlocks_about = new Array("ICEVISION","ICEHISTORY");
var picSrcDefault; //default picture for page. set in html document with onload event

function swopObj(textobj,theARRAY,picFlag,picObj,picSrcFLAG,picSrc){
	
	//remove all textobject and display passed textobejct
	
	
	
	for(i=0;i<theARRAY.length;i++){
		document.getElementById(theARRAY[i]).style.display="none";
		document.getElementById(textobj).style.display="block";
	}//for(i=0;i<theARRAY.length;i++){
	//if picflag passed as true then remove pic, else display it.
	
	if(picObj){
		if(picFlag){
		
		picObj.src = picSrcDefault;
		picObj.style.display='block';
		
		}//if(picFlag){
		else {
			picObj.style.display='none';
			if(picSrcFLAG){
			picObj.src = picSrc;
			picObj.style.display='block';
				}//else {
			
			}//else {
	
	}//if(pic){

}//function changeText(obj,theARRAY)

///////////////////////////////////////////////////////////
///the following  function is utilised to hide and show the 'more' and 'hide' (on projectlst.html) links plus the 
////appropiate div tags containing the relating text. scrollid is the Internal link that the 
///div overflow scrolls to.

function hide_show(flag,atag1,atag2,divtag,scrolltoid){
	
	atag1 = document.getElementById(atag1);
	atag2 = document.getElementById(atag2);
	divtag = document.getElementById(divtag);
	//if flag true: hide atag1 and show atag2,divtag
	if(flag){
		atag1.style.display = 'none';
		atag2.style.display = 'block';
		divtag.style.display = 'block';
		}//if(flag)
		else{
		//flag is false: show atag1 and hide atag2,divtag
		atag1.style.display = 'block';
		atag2.style.display = 'none';
		divtag.style.display = 'none';
			
			}//else
			
	//scrolls to id specified
	location.href = scrolltoid

}//function hide_show(flag,atag1,atag2,divtag){



//////////////////////////////////////////////////////////////////////////////////////
////code below for animation of growing divtag and shrinking div tag
/////////////////////////////////////////////

///set up vars
minwidth = 10;
minheight = 10;
maxwidth = 528;
maxheight = 321;
widthIncr = 20;
heightIncr = 20;
speed = 1;
timer = null;
obj = null;
textObj=null;
anchpos=null;//internal anchor link
shadow = null;

//calls animation to start
function grow(divId,textId,anch){
	obj = document.getElementById(divId);
	textObj = document.getElementById(textId);
	menu1 = document.getElementById('COPY_PROJ_div');
	menu2 = document.getElementById('INT_LINKS_div');
	shadow = document.getElementById('WHITEBLOCK_SHADOW_projectlist_div');
	
	obj.style.display = 'block';
	textObj.style.display = 'block';
	menu1.style.display = 'none';
	menu2.style.display = 'none';
	anchpos = anch;
	
	timer = setInterval("growWidth()",speed);	
}//function grow(divId)


//calls animation to start
function shrink(){
	timer = setInterval("shrinkHeight()",speed);
}//function shrink(){


///animation for growth of width of div
function growWidth(div){
	//set variables 
	var width = parseInt(obj.style.width);
	
	if(width < maxwidth){
		width += widthIncr;
		obj.style.width = width.toString() + 'px';
		return;
		}//if(width < maxwidth){
		else
		{
		obj.style.width = maxwidth.toString() + 'px';
		clearInterval(timer);
		timer = setInterval("growHeight()",speed);
		return;
	    }//else
}//function growWidth(obj)

function growHeight(){
	var height = parseInt(obj.style.height);
	
	if(height < maxheight){
		 height += heightIncr;
		 obj.style.height = height.toString() + 'px';
		 return;
		}else{
		 obj.style.height = maxheight.toString() + 'px';
		 //obj.style.overflow = 'auto'; deleted for ie
		 shadow.style.display = 'block';
		 clearInterval(timer);
		 return;
		}//else
	
	}//function growHeight(
	
////reduce height animation of divtag	
function shrinkHeight(){
	var height = parseInt(obj.style.height);
	shadow.style.display = 'none';
	//obj.style.overflow = 'hidden'; deleted for ie
	if(height > minheight){
		 height -= heightIncr;
		 obj.style.height = height.toString() + 'px';
		 return;
		}else{
		 obj.style.height = minheight.toString() + 'px';
		 clearInterval(timer);
		 timer = setInterval("shrinkwidth()",speed);
		 return;
		}//else
	
	}//shrinkHeight()
	
//reduce width animation of divtag	
function shrinkwidth(){
	//set variables 
	var width = parseInt(obj.style.width);
	
	if(width > minwidth){
		width -= widthIncr;
		obj.style.width = width.toString() + 'px';
		return;
		}
		else
		{
		obj.style.width = minwidth.toString() + 'px';
		clearInterval(timer);
		obj.style.display='none';
		textObj.style.display='none';
		menu1.style.display = 'block';
		menu2.style.display = 'block';
		location.href = anchpos;
		return;
	    }
}//function growWidth(obj)



//////////////////////////////////////////////////////////
/////proload object
///BEGIN

//ids for page templates -  same for each page on site
var ImagesIds = new Array("LOGO_img","LOGO_img2")//logo id to be on end

//all images in site
var ImagesAll = new Array("px/logo_services.jpg","px/logo_project.jpg","px/logo_partner.jpg","px/logo_contact.jpg","px/logo_aboutus.jpg","px/logo_home.jpg","px/logo.jpg")


///arg1 = array of images for page
///arg2 = array of ids for page template
///arg3 = array of all images to be preloaded
function Preload(nImages,nIds,allImgs){
	
	
	var aimages = new Array();
	var obj = Preload.prototype;
	obj.imgsLoaded = 0;
	
	///internal//////////////////////////////////begin function for fading
	obj.rate = 0.1;
	obj.objOp = 1.0;
	obj.timer = null;
	//Image.prototype.flag = true;
	obj.imageFlag = true;
	
	function fader(){
		
		//var obj = Preload.prototype;
		iObj = document.getElementById(ImagesIds[ImagesIds.length-1])///make sure id in array is last
		
		if(obj.imageFlag){
			if(obj.objOp>0.0){
				obj.objOp -= obj.rate   
			}else {
				obj.imageFlag = false;
				clearInterval(obj.timer);
				setTimeout("Preload.prototype.fadeCaller()",4000)
			}//if(objOp>0.0)
		}//if(iObj.flag)
		else{
			if(obj.objOp<1.0){
					obj.objOp += obj.rate   
				}else {
					obj.imageFlag = true;
					clearInterval(obj.timer);
					setTimeout("Preload.prototype.fadeCaller()",4000)
				}//if(objOp>0.0)
		}
		
		iObj.style.opacity = obj.objOp.toString(); ///note: error in parsing opacity moz
	    
		//ie compatibility
		var ieOP = new Object();
		ieOP.opacity = obj.objOp*100;
		ieOP.opacity = Math.floor(ieOP.opacity);
		if(ieOP.opacity>0){
			iObj.style.filter = "alpha(opacity=" + ieOP.opacity+ ")"; 
		}else{
			iObj.style.filter = "alpha(opacity=0)"; 
		}
		
	}//function fader()
	obj.fader = fader;
	
	function fadeCaller(){
		obj.timer = setInterval("Preload.prototype.fader()",100)
	}//function fadeCaller(
	obj.fadeCaller=fadeCaller ;
	
	//////////////////////////////////////////////////end fading
	
	
	function swopImages(){
		for(i=0;i<nIds.length;i++){
			document.getElementById(nIds[i]).src = nImages[i];
		}//for(i=0;i<nIds.length;i++)	
		
		////dhtml: change, move, show etc HTML elements and their style properties
		with(document){
			//getElementById('CECOSULTING_div').style.display='none';
			//getElementById('I_img').style.display='none';
			//getElementById('CK_div').style.top='138px';
			//getElementById('CK_div').style.left='435px';
			//getElementById('STAGE').style.borderWidth ='0px';
			getElementById(ImagesIds[ImagesIds.length-1]).style.display = 'block';
			//getElementById('LINK1').href='index.php?pics=1';
			//getElementById('LINK2').href='about.php?pics=1';
			//getElementById('LINK3').href='services.php?pics=1';
			//getElementById('LINK4').href='projectlist.php?pics=1';
			//getElementById('LINK5').href='contactus.php?pics=1';
			//getElementById('LINK6').href='partners.php?pics=1';
		}
	}//function swopImages(){
	obj.swopImages = swopImages;
	
	function turnLogo(){
		
		var obj = Preload.prototype;
		obj.fadeCaller();
	}//function turnLogo
	obj.turnLogo = turnLogo;
	
	function imgCounter(){
		var obj=Preload.prototype;
		obj.imgsLoaded += 1;
		
		if(obj.imgsLoaded == allImgs.length){
			with(document){
				//getElementById('START_IMGS').style.display='block';
				getElementById('LINK1').href='index.php?pics=0';
				getElementById('LINK2').href='about.php?pics=0';
				getElementById('LINK3').href='services.php?pics=0';
				getElementById('LINK4').href='projectlist.php?pics=0';
				getElementById('LINK5').href='contactus.php?pics=0';
				getElementById('LINK6').href='partners.php?pics=0';
				
			}
			obj.swopImages();
			obj.turnLogo();
			return;
		}//if(imgLoaded == nImages.length)
		else {
		return;
		}
	}//function imgCounter()
	this.imgCounter = imgCounter; //was originally this
	
	function startImage(){
		//put images into cache from images array
		for(i=0;i<allImgs.length;i++){
			aimages[i] = new Image;
			aimages[i].onload = imgCounter; ///this line comes before 'aimages[i].src = nImages[i];' else it doesn't work in explorer
			aimages[i].src = allImgs[i];
			//aimages[i].onerror = alert(aimages[i].src);
		}//for(i=0;i<nImages.length;i++)
	
	}//function startImage()
	this.startImage = startImage;
	

}//function Preload(ImagesHome,ImagesIds,allImgs)


//////////////////////////////////////////////////////////
/////proload object
///end