var sheetstatus;
if (top.location != location) {
    top.location.href = document.location.href ;
	}

function fullScreen(theURL) {
window.open("mediawindow.php?mediafile="+theURL, '', 'fullscreen=yes, scrollbars=auto');
}
// Iterates through all elements that support the ACCESSKEY attribute.
function highlightAccessKeys() {
    //don't do anything in old browsers
    if (!document.getElementsByTagName) return;

    var labels = document.getElementsByTagName('LABEL');
    for (var i = 0; i < labels.length; i++) {
        var control = document.getElementById(labels[i].htmlFor);
        if (control && control.accessKey) {
            highlightAccessKey(labels[i], control.accessKey);
        } else if (labels[i].accessKey) {
            highlightAccessKey(labels[i], labels[i].accessKey);
        }
    }

    var tagNames = new Array('A', 'BUTTON', 'LEGEND');
    for (var j = 0; j < tagNames.length; j++) {
        var elements = document.getElementsByTagName(tagNames[j]);
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].accessKey) {
                highlightAccessKey(elements[i], elements[i].accessKey);
            }
        }
    }
}

// Highlights the specified character in the specified element
function highlightAccessKey(e, accessKey) {
    if (e.hasChildNodes()) {
        var childNode, txt;
        
        //find the first text node that contains the access character
        for (var i = 0; i < e.childNodes.length; i++) {
            txt = e.childNodes[i].nodeValue;
            if (e.childNodes[i].nodeType == 3 &&
                txt.toLowerCase().indexOf(accessKey.toLowerCase()) != -1) {
            
                childNode = e.childNodes[i];
                break;
            }
        }
        
        if (!childNode) {
            //access character was not found
            return;
        }

        var pos = txt.toLowerCase().indexOf(accessKey.toLowerCase());
        var span = document.createElement('SPAN');
        var spanText = document.createTextNode(txt.substr(pos, 1));
        span.className = 'accesskey';
        span.appendChild(spanText);

        //the text before the access key
        var text1 = document.createTextNode(txt.substr(0, pos));
        //the text after the access key
        var text2 = document.createTextNode(txt.substr(pos + 1));
        
        if (text1.length > 0) e.insertBefore(text1, childNode);
        e.insertBefore(span, childNode);
        if (text2.length > 0) e.insertBefore(text2, childNode);

        e.removeChild(childNode);
    }
}

function checkSame(){
	if(document.getElementById('sameasshipto').checked == 1){
		document.getElementById('BillToFN').value = document.getElementById('ShipToFN').value;
		document.getElementById('BillToMI').value = document.getElementById('ShipToMI').value;
		document.getElementById('BillToLN').value = document.getElementById('ShipToLN').value;
		document.getElementById('BillToAddress').value = document.getElementById('ShipToAddress').value;
		document.getElementById('BillToCity').value = document.getElementById('ShipToCity').value;
		document.getElementById('BillToState').value = document.getElementById('ShipToState').value;
		document.getElementById('BillToZip').value = document.getElementById('ShipToZip').value;
	}
	if(document.getElementById('sameasshipto').checked != 1){
		document.getElementById('BillToFN').value = '';
		document.getElementById('BillToMI').value = '';
		document.getElementById('BillToLN').value = '';
		document.getElementById('BillToAddress').value = '';
		document.getElementById('BillToCity').value = '';
		document.getElementById('BillToState').value = '';
		document.getElementById('BillToZip').value = '';
	}
}

function pageOffset() {
var theobject=document.all? document.all.ATBAR : document.getElementById("ATBAR")
var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
var dsocleft=document.all? iebody.scrollLeft : pageXOffset
var dsoctop=document.all? iebody.scrollTop : pageYOffset
if (document.all||document.getElementById){
theobject.style.left=dsocleft+"px"
theobject.style.top=dsoctop+"px"
}
    setTimeout('pageOffset()',1);
}

function resetPage(){
  setActiveStyleSheet('normal');
  hiVis('default');
  sheetstatus = 'default';
  window.location.reload();
}

function hiVis(visSheet){
if(visSheet == 'hivis'){
 var i, a, main;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('title') == 'default') {
      a.disabled = true;
	}
	if(a.getAttribute('title') == 'defaultto') {
      a.disabled = true;
	}
	if(a.getAttribute('title') == 'hivisto') {
      a.disabled = true;
	}
    if(a.getAttribute('title') == 'hivis'){
		a.disabled = false;
    }
  }
}

if(visSheet == 'hivisto'){
 var i, a, main;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('title') == 'default') {
      a.disabled = true;
	}
	if(a.getAttribute('title') == 'defaultto') {
      a.disabled = true;
	}
	if(a.getAttribute('title') == 'hivis') {
      a.disabled = true;
	}
    if(a.getAttribute('title') == 'hivisto'){
		a.disabled = false;
    }
  }
}

if(visSheet == 'default'){
 var i, a, main;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('title') == 'default') {
      a.disabled = false;
	}
	if(a.getAttribute('title') == 'defaultto') {
      a.disabled = true;
	}
	if(a.getAttribute('title') == 'hivis') {
      a.disabled = true;
	}
    if(a.getAttribute('title') == 'hivisto'){
		a.disabled = true;
    }
  }
}

if(visSheet == 'defaultto'){
	var i, a, main;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('title') == 'default') {
      a.disabled = true;
	}
	if(a.getAttribute('title') == 'defaultto') {
      a.disabled = false;
	}
	if(a.getAttribute('title') == 'hivis') {
      a.disabled = true;
	}
    if(a.getAttribute('title') == 'hivisto'){
		a.disabled = true;
    }
  }
}

}

function UpdateFontsize(fsize){
setActiveStyleSheet(NewTitle);
}

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') != 'default' && a.getAttribute('title') != 'hivis' && a.getAttribute('title') != 'hivisto' && a.getAttribute('title') != 'defaultto') {
      a.disabled = true;
      if(a.getAttribute('title') == title) a.disabled = false;
    }
  }
}

function getActiveVisSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('rel').indexOf('style') != -1 && !a.disabled && a.getAttribute('title') != 'normal' && a.getAttribute('title') != 'large1' && a.getAttribute('title') != 'large2' && a.getAttribute('title') != 'large3' && a.getAttribute('title') != 'large4') return a.getAttribute('title');
  }
  return null;
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('rel').indexOf('style') != -1 && !a.disabled && a.getAttribute('title') != 'default' && a.getAttribute('title') != 'hivis' && a.getAttribute('title') != 'hivisto' && a.getAttribute('title') != 'defaultto') return a.getAttribute('title');
  }
  return null;
}


function getPreferredStyleSheet() {
  var i, a;
  for(i=3; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute('rel').indexOf('style') != -1
       && a.getAttribute('rel').indexOf('alt') == -1
       && a.getAttribute('title')
       ) return a.getAttribute('title');
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  var vsheet = getActiveVisSheet();
  createCookie('evasstyle', title, 365);
  createCookie('evassheet', vsheet, 365);
}

function setPageUp(){
	var title = 'normal';
	var visisheet = 'default';
  var cookie = readCookie('evasstyle');
  var cookie2 = readCookie('evassheet');
  title = cookie ? cookie : getPreferredStyleSheet();
  visisheet = cookie2 ? cookie2 : hiVis();
  if(visisheet == null){
  setActiveStyleSheet('normal');
  hiVis('default');
  visisheet = 'default';
  title = 'normal';
  sheetstatus = 'default';
  }
  setActiveStyleSheet(title);
  hiVis(visisheet);


// set sheetstatus variable according to which style sheet is active
  if(visisheet == 'default'){
	  sheetstatus = 'default';
  }
  if(visisheet == 'defaultto'){
	  sheetstatus = 'defaultto';
  }
  if(visisheet == 'hivis'){
	  sheetstatus = 'hivis';
  }
  if(visisheet == 'hivisto'){
	  sheetstatus = 'hivisto';
  }
  // Resize IMAGES according to which Font Size is set...
  var imp, art, zwidth, zheight;
		for(imp=0; (art = document.getElementsByTagName('img')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			if(title == 'large1'){
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			}
			if(title == 'large2'){
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			}
		}
  // Resize SWF (Object tags) according to which Font Size is set...
		for(imp=0; (art = document.getElementsByTagName('object')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			if(title == 'large1'){
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			}
			if(title == 'large2'){
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			}
		}
  // Resize EMBED (Object tags) according to which Font Size is set...
		for(imp=0; (art = document.getElementsByTagName('embed')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			if(title == 'large1'){
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			}
			if(title == 'large2'){
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
			}
		}
		//alert('Stylesheet: '+getActiveVisSheet()+' | Fontsize: '+getActiveStyleSheet());
		ToggleVis();
ToggleVis();
}
  
function FontUp(){
var imp, art;
for(imp=0; (art = document.getElementsByTagName('link')[imp]); imp++) {
if(art.getAttribute('rel').indexOf('style') != -1 && !art.disabled && art.getAttribute('title') != 'default' && art.getAttribute('title') != 'hivis' && art.getAttribute('title') != 'hivisto' && art.getAttribute('title') != 'defaultto'){
	//return a.getAttribute('title');
	//alert(art.getAttribute('title'));
	if(art.getAttribute('title') == 'normal'){
		setActiveStyleSheet('large1');
		for(imp=0; (art = document.getElementsByTagName('img')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('object')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('embed')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
		}
		return;
	}
	if(art.getAttribute('title') == 'large1'){
		setActiveStyleSheet('large2');
		for(imp=0; (art = document.getElementsByTagName('img')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('object')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('embed')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth * 1.25);
			art.height = (zheight * 1.25);
		}
		return;
	}
}
}
}

function FontDown(){
var imp, art;
for(imp=0; (art = document.getElementsByTagName('link')[imp]); imp++) {
if(art.getAttribute('rel').indexOf('style') != -1 && !art.disabled && art.getAttribute('title') != 'default' && art.getAttribute('title') != 'hivis' && art.getAttribute('title') != 'hivisto' && art.getAttribute('title') != 'defaultto'){
	if(art.getAttribute('title') == 'large2'){
		setActiveStyleSheet('large1');
		for(imp=0; (art = document.getElementsByTagName('img')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth / 1.25);
			art.height = (zheight / 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('object')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth / 1.25);
			art.height = (zheight / 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('embed')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth / 1.25);
			art.height = (zheight / 1.25);
		}
		return;
	}
	if(art.getAttribute('title') == 'large1'){
		setActiveStyleSheet('normal');
		for(imp=0; (art = document.getElementsByTagName('img')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth / 1.25);
			art.height = (zheight / 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('object')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth / 1.25);
			art.height = (zheight / 1.25);
		}
		for(imp=0; (art = document.getElementsByTagName('embed')[imp]); imp++) {
			zwidth = art.width;
			zheight = art.height;
			art.width = (zwidth / 1.25);
			art.height = (zheight / 1.25);
		}
		return;
	}
}
}
}

function ToggleImages(){
	if(sheetstatus == null){
		sheetstatus = 'default';
	}
	if(sheetstatus == 'default'){
		sheetstatus = 'defaultto';
		hiVis('defaultto');
		return;
	}
	if(sheetstatus == 'defaultto'){
		sheetstatus = 'default';
		hiVis('default');
		return;
	}
	if(sheetstatus == 'hivis'){
		sheetstatus = 'hivisto';
		hiVis('hivisto');
		return;
	}
	if(sheetstatus == 'hivisto'){
		sheetstatus = 'hivis';
		hiVis('hivis');
		return;
	}
}

function ToggleVis(){
	if(sheetstatus == null){
		sheetstatus = 'default';
	}
	if(sheetstatus == 'default'){
		sheetstatus = 'hivis';
		hiVis('hivis');
		return;
	}
	if(sheetstatus == 'defaultto'){
		sheetstatus = 'hivisto';
		hiVis('hivisto');
		return;
	}
	if(sheetstatus == 'hivis'){
		sheetstatus = 'default';
		hiVis('default');
		return;
	}
	if(sheetstatus == 'hivisto'){
		sheetstatus = 'defaultto';
		hiVis('defaultto');
		return;
	}
}