function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
  {window.onload = func;} 
  else 
  {
  	window.onload = function() {if (oldonload) { oldonload(); }
      func();
    }
  }
}


// function addLoadEvent(func){
// 	try{ 
//     	if(window.attachEvent){window.attachEvent("onload",func);} 
//         if(window.addEventListener){window.addEventListener("load",func,false);} 
//         return this; 
//     }catch(e){} 
// }

function getObj(name){
  if (document.getElementById) {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }else if (document.all) {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }else if (document.layers){
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
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 display(){
var x = new getObj('next'); x.style.display = (x.style.display == 'block') ? 'none' :'block';}
function disappear(){
var x = new getObj('first'); x.style.display = (x.style.display == 'none') ? 'block' :'none';}

function collectionsReveal(id,txt,sku){
	var div = document.getElementById(id);
	div.innerHTML="<div class=coll_img_container><div class=sku>"+sku+"</div><img src="+ txt +" width=200 height=431  /></div><img src=./images/collections_frame.gif width=312 height=546 id=collections_frame\ />"
}
function pressReveal(id,txt,sku){
	var div = document.getElementById(id);
	//div.innerHTML="<div class=coll_img_container><img src="+ txt +" width=195  /><div class=sku>"+sku+"</div></div>"
	div.innerHTML="<div id=\"large_press\"><img  src="+ txt +" style=\"float:left;display:inline;margin:30px 0px 0px 40px;height:458px;width:269px;\" /><div class=sku>"+sku+"</div></div>"
}
function showit(id,txt){
	var div = document.getElementById(id);
	div.innerHTML=txt
}
function hideit(){
	var div = document.getElementById(id);
	div.innerHTML=""
}
function windowPop(nameoffile,name,width,height){	window.open(nameoffile,name,'top=100,screeny=100,width='+width+',height='+height+',buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no');
}
//image swapping function:
function hiLite(imgDocID, imgObjName, comment) {
if (browserVer == 1) {
document.images[imgDocID].src = eval(imgObjName + ".src");
window.status = comment; return true;
}}

function launchMain(){  
window.open(
	'main.php?page=presskit',
	'performance',
	'top=100,left=50,width=800,height=600,buttons=no,scrollbars=no,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no'
); return false;
}


// global popup opener
function windowOpener(url, name, args) {
if (typeof(popupWin) != "object"){
	popupWin = window.open(url,name,args);
	} else {
	if (!popupWin.closed){
		popupWin.location.href = url;
	} else {
		popupWin = window.open(url, name,args);
	}
	}
		popupWin.focus();
}

// splash randomimage function
function LoadHPImage(){
	//alert('LoadHPImage evoked');
	var image = 5;
	var randomnumber = Math.random() ;
	var rand1 = Math.round( (image-1) * randomnumber) + 1 ;
	
	var div_holder = document.getElementById("splashRandomImage");
		if (div_holder){
			the_image = new Array;
			
			the_image[1] =  './images/splash_2010_1.jpg';
			the_image[2] =  './images/splash_2010_2.jpg';
			the_image[3] =  './images/splash_2010_3.jpg';
			the_image[4] =  './images/splash_2010_4.jpg';
			the_image[5] =  './images/splash_2010_5.jpg';
	var image_of_the_day = the_image[rand1];
	
		hp_image = document.createElement("img");
		hp_image.src=image_of_the_day;
		hp_image.id="thephoto";
		div_holder.onclick =function(){}
		div_holder.appendChild(hp_image);
	}
}




//change the opacity of an object
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+";)";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
	
}
function initImage() {
	imageId = 'thephoto';
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,0);
}
function initPhotoImage() {
	imageId = 'cardtray';
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,90);
}
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 5;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
	}
 }

function initRolloverImage(number) {
imageId = new Array;
	
	//image = document.getElementById(number);
	image = document.getElementById(number);
	setOpacity(image, 10);
	image.style.visibility = "visible";
	fadeIn(number,70);
} 
 
 
if(document.getElementById('splashRandomImageBg')) {
	addLoadEvent(LoadHPImage);  
}