﻿function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

function disableStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = true;
     }
   }
}

function element(id)
{
	return document.getElementById(id);
}

function changecss(theClass,element,value)
{
// By Shawn Olson, http://www.shawnolson.net/
//documentation for this script at http://www.shawnolson.net/a/503/
 var cssRules;
 if (document.all) {
  cssRules = 'rules';
 }
 else if (document.getElementById) {
  cssRules = 'cssRules';
 }
 for (var S = 0; S < document.styleSheets.length; S++){
  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
	document.styleSheets[S][cssRules][R].style[element] = value;
   }
  }
 }	
}
	
function swapPhoto(id)
{
	// get the height of the window
	var maxHeight;
	if (self.innerHeight) // all except Explorer
	{
		maxHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		maxHeight = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		maxHeight = document.body.clientHeight;
	}


	var bigBox = element('thisimage');
	if (element('image_' + id))
	{
		var image = element('image_' + id);

		var oldWidth = image.style.width.replace('px','');
		var oldHeight = image.style.height.replace('px','');
	
		var maxWidth = bigBox.offsetWidth - 12;
		maxHeight = maxHeight - 220;
				
		var widthProportion = maxWidth / oldWidth;
		var heightProportion = maxHeight / oldHeight;
		var proportion = Math.min(widthProportion,heightProportion);
	
		var newWidth = Math.round(oldWidth * proportion,0);
		var newHeight = Math.round(oldHeight * proportion,0);
	
		image.style.width = newWidth + 'px';
		image.style.height = newHeight + 'px';
	}
	bigBox.innerHTML = element('photo_' + id).innerHTML;	
	return null;
}

function fixPhoto(id)
{
	if (element('image_' + id))
	{
		var image = element('image_' + id);

		var oldWidth = image.style.width.replace('px','');
		var oldHeight = image.style.height.replace('px','');
	
		var maxWidth = 400;
		var maxHeight = 100000;
				
		var widthProportion = maxWidth / oldWidth;
		var heightProportion = maxHeight / oldHeight;
		var proportion = Math.min(widthProportion,heightProportion);
	
		var newWidth = Math.round(oldWidth * proportion,0);
		var newHeight = Math.round(oldHeight * proportion,0);
	
		image.style.width = newWidth + 'px';
		image.style.height = newHeight + 'px';
	}
	return null;
}
