var popup = false;
var ftopt = true;
var mopts = new Array();
var mopth = new Array();
var mopto = new Array();
var moptw = new Array();
var moptu = new Array();

var menuopts;
var menunods;
var mi,n,s;
	mopts['home'] = "mbtn_dyo4van1.gif";
    mopth['home'] = "mbtn_dyo4van1_hi.gif";
    mopto['home'] = "mbtn_dyo4van1_on.gif";
    moptw['home'] = "82px";
		
	mopts['events'] = "mbtn_ueuuwy4x.gif";
    mopth['events'] = "mbtn_ueuuwy4x_hi.gif";
    mopto['events'] = "mbtn_ueuuwy4x_on.gif";
    moptw['events'] = "154px";
	
	mopts['about'] = "mbtn_1s325la3.gif";
    mopth['about'] = "mbtn_1s325la3_hi.gif";
    mopto['about'] = "mbtn_1s325la3_on.gif";
    moptw['about'] = "82px";
				
function makePage() {
	sw = document.body.clientWidth;
	sh = document.body.clientHeight;
	document.getElementById("pagearea").style.width=sw.toString() + "px";
	document.getElementById("pagearea").style.height=sh.toString() + "px";
	makeHeader();
	makeFooter();
	setMenu();
	setAJAX();
	setPageVals();
	}

function setPageVals(){
	v = document.location.href
	p = v.lastIndexOf("/") 
	v = v.substr(p+1)
	createInput('thispage',v)
	}

function doProcess(p,v) {
	createInput('doaction',p);
	if (v) { createInput('dovalue',v) };
	document.getElementById("mainForm").action='process.asp';
	document.getElementById("mainForm").submit();
	}

function doPage(s,p,v) {
	createInput('doaction',p);
	if (v) { createInput('dovalue',v) };
	document.getElementById("mainForm").action=s;
	document.getElementById("mainForm").submit();
	}
	
function createInput(n,v,t,f) {
    if ( !v ) { v = ''; };
    if ( !t ) { t = 'hidden'; };
	if ( !f ) { f = 'mainForm'; };
	cfo = document.getElementById(f);
	cel = document.createElement('input');	cel.type = t; cel.name = n;	cel.id = n; cel.value = v;
	cfo.appendChild(cel);
    }
	
function setTimeStamp() {
	tob = new Date();
	syr = tob.getFullYear(); smo = tob.getMonth()+1; sda = tob.getDate();
	shr = tob.getHours();smi = tob.getMinutes(); sse = tob.getSeconds(); sms = tob.getMilliseconds();
	cfo = document.getElementById("mainForm")
	cel = document.createElement('input');	cel.type = 'hidden'; cel.name = 'timestmp';	cel.id = 'timestmp';
	cfo.appendChild(cel)
	cel = document.createElement('input');	cel.type = 'hidden'; cel.name = 'timeoffs';	cel.id = 'timeoffs';
	cfo.appendChild(cel)
	document.getElementById("timestmp").value = syr.toString()+smo.toString()+sda.toString()+shr.toString()+smi.toString()+sse.toString();
	document.getElementById("timeoffs").value = tob.getTimezoneOffset();
	}
	
function trimValue(tv) {
  xx = tv;
  while ( xx.substr(xx.length-1) == ' ' ) { xx = xx.substr(0, xx.length-1) };
  while ( xx.charAt(0) == ' ' ) { xx = xx.slice(1) };
  return xx;
  }
	
function setMenu() {
	makeMenu() 
	menuopts = document.getElementsByName("menuitem");
	menunods = document.getElementsByName("menunode");
	w = 2;
	p = 0;
	for (i in mopts) {
		v = parseInt(moptw[i]);
		menunods[p].style.width = v + "px";
		p++;
		w = w + v;
		};
	document.getElementById("menubtns").style.width = w + "px";
	}

function setChoice(s) {
	n = 0;
	p = 0;
	for (i in mopts) {
		menuopts[p].src='./images/menu/' + mopts[i];
		if ( i ==  s ) { n = p };
		p++
        }
	if ( mopto[s] ) { 
		menuopts[n].src='./images/menu/' + mopto[s];
		}
	mi = s;
	};

function hiMenu(s) {
	if ( s != mi ) {
		n = 0; 
		p = 0;
		for (i in mopts) { 
			if ( i == s ) { n = p };
			p++
			};
		menuopts[n].src='./images/menu/' + mopth[s];
		}
	}
function loMenu(s) {
	if ( s != mi ) {
		n = 0; 
		p = 0;
		for (i in mopts) { 
			if ( i == s ) { n = p };
			p++
			};
		menuopts[n].src='./images/menu/' + mopts[s];
		}
	}
  
function goMenu(s) {
	setChoice(s);
	doProcess("menu-" + s);
	}

function makeMenu() {
	h = '';
	h = h + '<div id="menuends"><img src="./images/menu/mend_kf4dqmvv.gif"></div>';
	for (i in mopts) {
		s = '';
		c = "'" + i + "'";
		s = s + '<div id="menunode" name="menunode" ';
		s = s + 'onmouseover="hiMenu(' + c + ')" ';
		s = s + 'onmouseout="loMenu(' + c + ')" ';
		s = s + 'onclick="goMenu(' + c + ')">';
		s = s + '<img id="menuitem" name="menuitem" src="./images/menu/' + mopts[i] + '"></div>';
		h = h + s;
		};
	h = h + '<div id="menuends"><img src="./images/menu/mend_zwvvqwjp.gif"></div>';
	document.getElementById("menubtns").innerHTML = h;
	}
  
function makeHeader() {
	sx = document.body.clientWidth - 780;
	mr = "this.className='textinpth'";
	mt = "this.className='textinpt'";
	bs = "doURL('http://castnotice.blogspot.com','blogspot')";
	oc = "doProcess('setlogin')";
	gh = "doProcess('menu-home')";
	h  = '';	
	h = h + '<div id="topbox">';
	h = h + '    <div style="float:left;height:74px;width:380px;text-align:left">';
	h = h + '    <img id="logoimg" src="./images/head/cimg_u1pvdx56.png" border=0 style="cursor:pointer" onclick="'+gh+'">'
	h = h + '    </div>';
	h = h + '    <div style="float:left;height:74px;width:'+sx+'px;text-align:left">';
	h = h + '    <img id="logoimg" src="./images/head/mbak_kair3ufg.gif" border=0 style="height:74px;width:'+sx+'px">';
	h = h + '    </div>';
	h = h + '    <div style="float:right;height:74px;text-align:right;width:400px;background:#242424;text-align:right">';
	h = h + '        <div style="clear:both;width:360px;height:24px;text-align:right;padding-right:10px;padding-top:3px">';
	h = h + '        <img src="./images/head/cimg_u1pvdx45.gif" border=0>';
	h = h + '        </div>';

	h = h + '        <div id="topopts" style="float:right;width:360px;height:16px;padding-top:0px;padding-right:30px">';
	h = h + '        	<div id="topopts" style="float:right;width:165px;height:44px;text-align:right" onmouseover="'+mr+'" onmouseout="'+mt+'" onclick="'+bs+'">Check out our Blog!</div>';
	h = h + '       	<div id="topopts" style="float:right;width:150px;height:44px;text-align:right" onmouseover="'+mr+'" onmouseout="'+mt+'" onclick="'+oc+'">Sign up | Forgot password</div>';
	h = h + '    	</div>';

	h = h + '        <div id="topopts" style="float:right;width:370px;height:20px;padding-top:3px;padding-right:30px">';
	h = h + '           <div id="topopts" style="float:right;width:70px;padding-top:1px">'
	h = h + '               <img src="./images/head/btnh_si4zxhtg.png"'
	h = h + '                    onmouseover="this.src=\'./images/head/btnh_si4zxhtg_hi.png\'"'
	h = h + '                    onmouseout="this.src=\'./images/head/btnh_si4zxhtg.png\'"'
	h = h + '                    onclick="doHeadLogin()">'
	
	h = h + '               </div>'
	h = h + '           <div id="topopts" style="float:left;width:55px;padding-top:5px;padding-right:1px">User Id:</div>'
	h = h + '           <div id="topopts" style="float:left;width:85x"><input type="text" id="headcode" name="headcode" size=9 style="width:80px;height:16px"></div>'
	h = h + '           <div id="topopts" style="float:left;width:70px;padding-top:5px">Password:</div>'
	h = h + '           <div id="topopts" style="float:left;width:85px"><input type="password" id="headpswd" name="headpswd" size=9 style="width:80px;height:16px"></div>'
	h = h + '    	</div>';

	h = h + '    </div>';
	h = h + '</div>';
	document.getElementById("headarea").innerHTML = h;
	}

function makeFooter() {
	h  = '';
	d  = new Date(); y = d.getFullYear();
	co = 'Copyright &copy; 2009-'+y+' CastNotice.com/August Tellar, Inc.';
	mr = "this.className='textinpth'";
	mr = "this.className='textinpth'";
	mt = "this.className='textinpt'";
  
	oc = new Array();
	oc['jsd'] = "doURL('http://jschultzdesign.com','jschultz')";
	oc['con'] = "goMenu('about')";
	oc['faq'] = "doPage('faqs.asp','site-faqs')";
	oc['trm'] = "doPage('tos.asp','site-term')";
	oc['prv'] = "doPage('privacy.asp','site-priv')";
  
	h = h + '<div id="footerarea">';
	h = h + '  <div id="footerchar" style="float:left">';
	h = h + co;
	h = h + '  </div>';
	if ( ftopt == true ) {
		h = h + '  <div id="footerchar" style="float:right">';
		h = h + '  <span class="textinpt" onmouseover="'+mr+'" onmouseout="'+mt+'" onclick="'+oc['con']+'">';
		h = h + '  Contact</span>';
		h = h + '  | ';
		h = h + '  <span class="textinpt" onmouseover="'+mr+'" onmouseout="'+mt+'" onclick="'+oc['faq']+'">';
		h = h + '  FAQs</span>';
		h = h + '  | ';
		h = h + '  <span class="textinpt" onmouseover="'+mr+'" onmouseout="'+mt+'" onclick="'+oc['trm']+'">';
		h = h + '  Terms of Service</span>';
		h = h + '  | ';
		h = h + '  <span class="textinpt" onmouseover="'+mr+'" onmouseout="'+mt+'" onclick="'+oc['prv']+'">';
		h = h + '  Privacy Policy</span>';
		h = h + '  </div>';
		h = h + '</div>';
		}
	document.getElementById("footerarea").innerHTML = h;
	}
	
function getContent(x) {
	parms = ""
	parms = parms + 'dorequest=' + x
	xmlHttp.open("POST",doscript,true)
	xmlHeader()
	xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { showContent(xmlHttp.responseText) } }
	xmlHttp.send(parms)
	}

function setPopScreen(x) {
	parms = ""
	parms = parms + 'dorequest=' + x + "&"
	parms = parms + 'reqwidth=' + document.body.clientWidth + "&"
	parms = parms + 'reqheight=' + document.body.clientHeight
	xmlHttp.open("POST",doscript,true)
	xmlHeader()
	xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { fillPopScreen() } }
	xmlHttp.send(parms)
	}
	
function fillPopScreen(x) {
//	alert(xmlHttp.responseText)
	showPopScreen()
	document.getElementById("popscreen").innerHTML = xmlHttp.responseText
	}
	
function showPopScreen() {
	scroll(0,0)
	popup = true
	sw = document.body.clientWidth
	sh = document.body.clientHeight
	document.getElementById("popscreen").style.width=sw.toString() + "px"
	document.getElementById("popscreen").style.height=sh.toString() + "px"
	h = ''
	document.getElementById("popscreen").innerHTML = h
	document.getElementById("popscreen").style.display = 'inline'
	document.getElementById("pagearea").style.visibility = 'hidden'
	}
	
function hidePopScreen() {
	popup = false
	document.getElementById("popscreen").innerHTML = ''
	document.getElementById("popscreen").style.display = 'none'
	document.getElementById("pagearea").style.visibility = 'visible'
	}
	
function doResize() {
	if ( popup == true ) { hidePopScreen() }
	}
  
function doURL(u,n,a) {
	t = u
	if ( t == '' ) { t = document.getElementById(a).href }
	n = n.replace(/\s/g,'')
    window.open (t,n,"")
	}

function doHeadLogin(x) {
    u = trimValue(document.getElementById("headcode").value)
	p = trimValue(document.getElementById("headpswd").value)
	b = false
	if ( u != '' ) { 
		if ( p != '' ) {
			b = true
			createInput('doaction','dologin')
			setTimeStamp()
			document.getElementById("mainForm").action = 'backstage.asp'
			document.getElementById("mainForm").submit()
			}
		}
	if ( b == false ) {
		if ( x == '' ) {
			alert('Please enter your User ID and Password')
			}
		}
	document.getElementById("headpswd").focus()
	if ( u == '' ) { document.getElementById("headcode").focus() }
	}
	
