/* initial header code */
if (self != top) top.location.href = self.document.href;
/* javascript splash code */
function hidesplash(){
document.getElementById("splash").style.display = "none";
}
function showsplash(){
document.getElementById("splash").style.display = "block";
}

/* tool tips functions */
function getoddTipDisplay(eid,event) {
var scrollTop = document.body.scrollTop ? document.body.scrollTop :
            document.documentElement.scrollTop;
	var theid = eid.id;
	eid.title = '';
	var thedisplay = theid+'-disc';	
	var loc=findGetOddPosition(eid);
	var x=loc[0];
	var y=loc[1];
	var sid = document.getElementById(thedisplay);

	switch (theid){
		case "begging":
			x = x + document.getElementById("sidebar-left").clientWidth;
			y=scrollTop;
			break;
		case "getoddLogo":
			y=y+100;
			eid.style.backgroundColor = "aqua";
			eid.style.borderTop = "1px solid #000000";
			eid.style.borderLeft = "1px solid #000000";
			eid.style.borderRight = "1px solid #000000";
			break;
		default:
		;
	}
	sid.style.left = x+'px';
	sid.style.top= y+'px';
	sid.style.display = 'block';
	return;
}

function getoddTipHide(eid) {
	var theid = eid.id;
	var thedisplay = theid+'-disc';	
	thedisplay = document.getElementById(thedisplay).style.display = 'none';
	switch (theid){
		case "getoddLogo":	
		eid.style.backgroundColor = "transparent";
		eid.style.borderTopStyle = "none";
		eid.style.borderLeftStyle = "none";
		eid.style.borderRightStyle = "none";
		break;
	}
	return;
}

/* home display functions */
function homeleftshow(eid,event) {
	var theid = eid.id;
	eid.title = '';
	var thedisplay = theid+'-disc';	
	loc=findGetOddPosition(eid);
	var x=loc[0];
	var y=loc[1];
	var sid = document.getElementById(thedisplay);
	y = y + 90;
	var ccid = document.getElementById('content');
	var loc=findGetOddPosition(ccid);
	x=loc[0];
	sid.style.left = x+'px';
	sid.style.top= y+'px';
	sid.style.display = 'block';
	return;
}

function homerightshow(eid,event) {
	var theid = eid.id;
	eid.title = '';
	var thedisplay = theid+'-disc';	
	var loc=findGetOddPosition(eid);
	var x=loc[0];
	var y=loc[1];
	var sid = document.getElementById(thedisplay);
	y = y + 90;
	var	ccid = document.getElementById('content');
	loc=findGetOddPosition(ccid);
	x=loc[0];
	sid.style.left = x+'px';
	sid.style.top= y+'px';
	sid.style.display = 'block';
	return;
}

function homehide(eid) {
	var theid = eid.id;
	var thedisplay = theid+'-disc';	
	thedisplay = document.getElementById(thedisplay).style.display = 'none';
	return;
}

/* archive display functions */
function archiveshow(eid,event) {
var scrollTop = document.body.scrollTop ? document.body.scrollTop :
            document.documentElement.scrollTop;
	var theid = eid.id;
	eid.title = '';
	var thedisplay = theid+'-disc';	
	var loc=findGetOddPosition(eid);
	var x=loc[0];
	var y=loc[1];
	var sid = document.getElementById(thedisplay);

	y = y + 65;

	sid.style.left = x+'px';
	sid.style.top= y+'px';
	sid.style.display = 'block';
	return;
}

function archivehide(eid) {
	var theid = eid.id;
	var thedisplay = theid+'-disc';	
	thedisplay = document.getElementById(thedisplay).style.display = 'none';
	return;
}

/*	note functions */

function noteshow(eid,event,ddisplay) {

	var text = 'note:<br />'+ddisplay;
	eid.title = '';
	var thedisplay = 'oddnote';	
	var loc=findGetOddPosition(eid);
	var x=loc[0];
	var y=loc[1];
	var sid = document.getElementById(thedisplay);
	sid.innerHTML = text;
	var ccid = document.getElementById('content');
	loc=findGetOddPosition(ccid);	
	var oddwidth = ccid.clientWidth;
	var xend = x+415;
	var cend = loc[0]+ oddwidth;
	var offset = xend-cend;
	var temp = x-offset;
	if(offset > 0)x=temp;
	y = y + 60;

	sid.style.left = x+'px';
	sid.style.top= y+'px';
	sid.style.display = 'block';
	return;
}

function notehide(eid) {
	var thedisplay = 'oddnote';	
	var did = document.getElementById(thedisplay);
	did.style.display = 'none';

	return;
}


/* common javascript functions */
function findGetOddPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}

/* count the number of words in a field */
function CountWords(this_field) {
var char_count = this_field.value.length;
var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;
}

if(word_count > 100){
alert('Your word count of '+word_count+"\nis greater than 100\nPlease reduce the number of words \nand resubmit");
return false;
}
return true;
}


function imgcover(theid){

var osid = document.getElementById(theid);
var oheight=osid.offsetHeight;
var owidth=osid.offsetWidth;
var iiid = document.getElementById(theid+'_cover');
iiid.style.height = oheight+'px';
iiid.style.width = owidth+'px';
var	loc=findGetOddPosition(osid);
	iiid.style.left=loc[0]+'px';
	iiid.style.top=loc[1]+'px';
}
