function changeCss(myclass,element,value) {
	var CSSRules
	if (document.all) {
		CSSRules = 'rules'
	} else if (document.getElementById) {
		CSSRules = 'cssRules'
	}
	for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
		classText = document.styleSheets[0][CSSRules][i].selectorText.toLowerCase();
		if(classText.charAt(0) == '*'){
			classText = classText.substring(1);
		}
		if (classText == myclass.toLowerCase()) {
			document.styleSheets[0][CSSRules][i].style[element] = value
		}
	}
}              

function isSafari(){
	detect = navigator.userAgent.toLowerCase();
	if(detect.indexOf('safari') < 0){
		return false;
	}else{
		return true;
	}
}

function safariChangeCssLink(myclass,element,value,visitedColor,hoverColor) {
	CSSRules = 'cssRules';
	classString = 'class~="' + myclass.toLowerCase() + '"';
	//alert(document.styleSheets[0][CSSRules][71].selectorText+'\n'+document.styleSheets[0][CSSRules][72].selectorText+'\n'+document.styleSheets[0][CSSRules][73].selectorText)
	for (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) {
		classText = document.styleSheets[0][CSSRules][i].selectorText.toLowerCase();
		if(classText.indexOf(classString) >= 0){
			 break;
		}
	}
	document.styleSheets[0][CSSRules][i].style[element] = value;
	document.styleSheets[0][CSSRules][i+1].style[element] = visitedColor;
	document.styleSheets[0][CSSRules][i+2].style[element] = hoverColor;
}


function onLoadFunction(){
	if(bgc == 0){
		changeCss('.photoHeader','color','#000000');
		changeCss('.photoDesc','color','#000000');
		
		if(!isSafari()){
			changeCss('a.albumFontLink','color','#000000'); 
			changeCss('a.albumFontLink:visited','color','#000000');
			changeCss('a.albumFontLink:hover','color','#C0C0C0');
			
			changeCss('a.albumButtonLink','color','#000000');
			changeCss('a.albumButtonLink:visited','color','#000000');
			changeCss('a.albumButtonLink:hover','color','#C0C0C0');
		}else{
			safariChangeCssLink('albumFontLink','color','#000000','#000000','#C0C0C0');
			safariChangeCssLink('albumButtonLink','color','#000000','#000000','#C0C0C0');
		}
	}
}  

function openSite(theSite){
	window.open(theSite, '', "height="+window.screen.availHeight+", width="+window.screen.availWidth+", top=0, left=0, toolbar=yes, status=yes, scrollbars=yes, location=yes, menubar=yes, directories=yes, resizable=yes");		
}

function downloadFile(ePid){
	location.href = "downloadFile.php?ePid=" + ePid;
}

function playFile(ePid,wWidth,wHeight){
	theURL = "media.php?ePid=" + ePid;
	window.open(theURL, '', "left="+(window.screen.availWidth-wWidth-50)+",top="+(window.screen.availHeight-wHeight-50)+", width="+wWidth+", height="+wHeight+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
}