/*
 C2000;C-WD.NET
 Author: Seth Keiper
 Check Up: Mon, 25 Sep 2006 10:43:34
 INDEX DATE SCRIPT 
*/
var i,cul,overts,ajxmlreq,xmlobject,dest;
var W3CDOM = (document.createElement && document.getElementsByTagName);
window.onload = init;
if (!document.getElementById){
	window.location = "/upgrade/";
}
if(navigator.appName == "WebTV"){
	alert("This site may not be compatable with WebTV.");
}
function getxmlobject(){
	var objxmlhttp=null;
	if (window.XMLHttpRequest){
		objxmlhttp=new XMLHttpRequest();
	} else if (window.ActiveXObject){
		objxmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objxmlhttp;
}
function makepostrequest(url,parameters){
	ajxmlreq = false;
	if (window.XMLHttpRequest){
		ajxmlreq = new XMLHttpRequest();
		if (ajxmlreq.overrideMimeType){
			ajxmlreq.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject){
		try{
			ajxmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
			try{
				ajxmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){}
		}
	}
	if (!ajxmlreq){
		document.getElementById('forminfo').innerHTML = 'Cannot create XMLHTTP instance';
		return false;
	}
	ajxmlreq.onreadystatechange = alertcontents;
	ajxmlreq.open('POST',url,true);
	ajxmlreq.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	ajxmlreq.setRequestHeader("Content-length",parameters.length);
	ajxmlreq.setRequestHeader("Connection","close");
	ajxmlreq.send(parameters);
	return '';
}
function alertcontents(){
	if (ajxmlreq.readyState == 4){
		if (ajxmlreq.status == 200){
			result = ajxmlreq.responseText;
			vxmldl = result.split('|');
			vararray=vxmldl[0];
			if (vararray == 'contactinformation'){
				hidediv('forminput');
				hidediv('forminfo');
				hidediv('formnamesuggestions');
			}
			document.getElementById(vxmldl[0]).innerHTML = vxmldl[1];
		} else{
			document.getElementById('forminfo').innerHTML = 'There was a problem with the request.';
		}
	}
}
function get(itemid){
	obj=document.getElementById(itemid);
	var poststr = "svmca=" + encodeURI( document.getElementById("svmca").value) +
	"&ip=" + encodeURI( document.getElementById("ip").value) +
	"&httpref=" + encodeURI( document.getElementById("httpref").value) +
	"&httpagent=" + encodeURI( document.getElementById("httpagent").value) +
	"&name=" + encodeURI( document.getElementById("name").value) +
	"&email=" + encodeURI( document.getElementById("email").value) +
	"&attn=" + encodeURI( document.getElementById("attn").value) +
	"&urgency=" + encodeURI( document.getElementById("urgency").value) +
	"&notes=" + encodeURI( document.getElementById("notes").value);
	makepostrequest('/xmlrpc',poststr);
}
function sendxmlrpc(){
	var obj=document.getElementById("cwdcontact");
	var poststr = "svmca=" + encodeURI( document.getElementById("svmca").value) +
	"&ip=" + encodeURI( document.getElementById("ip").value) +
	"&httpref=" + encodeURI( document.getElementById("httpref").value) +
	"&httpagent=" + encodeURI( document.getElementById("httpagent").value) +
	"&name=" + encodeURI( document.getElementById("name").value) +
	"&email=" + encodeURI( document.getElementById("email").value) +
	"&attn=" + encodeURI( document.getElementById("attn").value) +
	"&urgency=" + encodeURI( document.getElementById("urgency").value) +
	"&notes=" + encodeURI( document.getElementById("notes").value);
	makepostrequest('/xmlrpc',poststr);
}
function showdiv(id){
	if (document.getElementById){
		document.getElementById(id).style.display = "block";
		document.getElementById(id).style.visibility = "visible";
	} 
}
function hidediv(id){
	if (document.getElementById){
		document.getElementById(id).style.display = "none";
		document.getElementById(id).style.visibility = "hidden";
	}
}
function init(){
	if (!W3CDOM) return;
	var inputs;
	var id_name = document.getElementById('name');
	var id_email = document.getElementById('email');
	var id_attn = document.getElementById('attn');
	var id_urgency = document.getElementById('urgency');
	var id_notes = document.getElementById('notes');
	var id_submit = document.getElementById('submit');
	var id_reset = document.getElementById('reset');
	var id_openbutton = document.getElementById('openbutton');
	var id_closebutton = document.getElementById('closebutton');
	var id_mnnxt1 = document.getElementById('mnnxt1');
	var id_mnnxt2 = document.getElementById('mnnxt2');
	var id_mnnxt1p = document.getElementById('mnnxt1p');
	var id_mnnxt3f = document.getElementById('mnnxt3f');
	var id_mnnxt2p = document.getElementById('mnnxt2p');
	var id_mnnxtcf = document.getElementById('mnnxtcf');
	if(document.getElementById("noscript")) document.getElementById("noscript").style.display="none";
	var divs=document.getElementsByTagName('div');
	for(i=0;i<divs.length;i++){
		if (divs[i].className.match("op_bt")){
			id_openbutton.onclick=function(){ showdiv('httpcont'); };
			id_openbutton.onmouseover=function(){ had(id_openbutton); showdiv('overts'); return true; };
			id_openbutton.onmouseout=function(){ ha(id_openbutton); hidediv('overts'); return true; };
		}
		if (divs[i].className.match("clos_bt")){
			id_closebutton.onclick=function(){ hidediv('overtt'); hidediv('httpcont'); };
			id_closebutton.onmouseover=function(){ had(id_closebutton); showdiv('overtt'); return true; };
			id_closebutton.onmouseout=function(){ ha(id_closebutton); hidediv('overtt'); return true; };
		}
	}
	var inputs=document.getElementsByTagName('input');
	for(i=0;i<inputs.length;i++){
		if (inputs[i].className.match("fmname")){
			id_name.onfocus=function(){ id_name.className='focuseditem'; sndreq('name','Absolute'); };
			id_name.onblur=function(){ id_name.className='unfocuseditem'; sndreq('cls','Absolute'); };
			id_name.onkeyup=function(){ ajaxsh(id_name.value,'name'); };
		}
		if (inputs[i].className.match("fmemail")){
			id_email.onfocus=function(){ id_email.className='focuseditem'; sndreq('email','Absolute'); };
			id_email.onblur=function(){ id_email.className='unfocuseditem'; sndreq('cls','Absolute'); };
		}
		if (inputs[i].className.match("fmchk")){
			id_urgency.onfocus=function(){ id_urgency.className='focuseditem'; sndreq('urgency','Absolute'); };
			id_urgency.onblur=function(){ id_urgency.className='unfocuseditem'; sndreq('cls','Absolute'); };
		}
		if (inputs[i].className.match("fmsubmit")){
			id_submit.onmouseover=function(){ id_submit.className='focuseditem'; sndreq('submit','Absolute'); };
			id_submit.onfocus=function(){ id_submit.className='focuseditem'; sndreq('submit','Absolute'); };
			id_submit.onmouseout=function(){ id_submit.className='unfocuseditem'; sndreq('cls','Absolute'); };
			id_submit.onblur=function(){ id_submit.className='unfocuseditem'; sndreq('cls','Absolute'); };
		}
		if (inputs[i].className.match("fmreset")){
			id_reset.onmouseover=function(){ id_reset.className='focuseditem'; sndreq('reset','Absolute'); };
			id_reset.onfocus=function(){ id_reset.className='focuseditem'; sndreq('reset','Absolute'); };
			id_reset.onmouseout=function(){ id_reset.className='unfocuseditem'; sndreq('cls','Absolute'); };
			id_reset.onblur=function(){ id_reset.className='unfocuseditem'; sndreq('cls','Absolute'); };
		}
		if (inputs[i].className.match("mnnxt1")){
			id_mnnxt1.onmouseover=function(){ ha(id_mnnxt1); return true; };
			id_mnnxt1.onfocus=function(){ ha(id_mnnxt1); return true; };
			id_mnnxt1.onmouseout=function(){ had(id_mnnxt1); return true; };
			id_mnnxt1.onblur=function(){ had(id_mnnxt1); return true; };
			id_mnnxt1.onclick=function(){ sndreq('Main1','Absolute'); };
		}
		if (inputs[i].className.match("mnnxt2")){
			id_mnnxt2.onmouseover=function(){ ha(id_mnnxt2); return true; };
			id_mnnxt2.onfocus=function(){ ha(id_mnnxt2); return true; };
			id_mnnxt2.onmouseout=function(){ had(id_mnnxt2); return true; };
			id_mnnxt2.onblur=function(){ had(id_mnnxt2); return true; };
			id_mnnxt2.onclick=function(){ alert('Absolute + '+id_mnnxt2); sndreq('Main2','Absolute'); };
		}
		if (inputs[i].className.match("mnnxt1p")){
			id_mnnxt1p.onmouseover=function(){ ha(id_mnnxt1p); return true; };
			id_mnnxt1p.onfocus=function(){ ha(id_mnnxt1p); return true; };
			id_mnnxt1p.onmouseout=function(){ had(id_mnnxt1p); return true; };
			id_mnnxt1p.onblur=function(){ had(id_mnnxt1p); return true; };
			id_mnnxt1p.onclick=function(){ sndreq('Main1','Absolute'); };
		}
		if (inputs[i].className.match("mnnxt3f")){
			id_mnnxt3f.onmouseover=function(){ ha(id_mnnxt3f); return true; };
			id_mnnxt3f.onfocus=function(){ ha(id_mnnxt3f); return true; };
			id_mnnxt3f.onmouseout=function(){ had(id_mnnxt3f); return true; };
			id_mnnxt3f.onblur=function(){ had(id_mnnxt3f); return true; };
			id_mnnxt3f.onclick=function(){ sndreq('Main3','Absolute'); };
		}
		if (inputs[i].className.match("mnnxt2p")){
			id_mnnxt2p.onmouseover=function(){ ha(id_mnnxt2p); return true; };
			id_mnnxt2p.onfocus=function(){ ha(id_mnnxt2p); return true; };
			id_mnnxt2p.onmouseout=function(){ had(id_mnnxt2p); return true; };
			id_mnnxt2p.onblur=function(){ had(id_mnnxt2p); return true; };
			id_mnnxt2p.onclick=function(){ sndreq('Main2','Absolute'); };
		}
		if (inputs[i].className.match("mnnxtcf")){
			id_mnnxtcf.onmouseover=function(){ ha(id_mnnxtcf); return true; };
			id_mnnxtcf.onfocus=function(){ ha(id_mnnxtcf); return true; };
			id_mnnxtcf.onmouseout=function(){ had(id_mnnxtcf); return true; };
			id_mnnxtcf.onblur=function(){ had(id_mnnxtcf); return true; };
			id_mnnxtcf.onclick=function(){ location.href='http://c-wd.net/company/stile/QWJzb2x1dGU'; };
		}
	}
	var txtarea=document.getElementsByTagName('textarea');
	for(i=0;i<txtarea.length;i++){
		if (txtarea[i].className.match("fmnotes")){
			id_notes.onfocus=function(){ id_notes.className='focuseditem'; sndreq('notes','Absolute'); };
			id_notes.onblur=function(){ id_notes.className='unfocuseditem'; sndreq('cls','Absolute'); };
		}
	}
	var select=document.getElementsByTagName('select');
	for(i=0;i<select.length;i++){
		if (select[i].className.match("fmattn")){
			id_attn.onfocus=function(){ id_attn.className='focuseditem'; sndreq('attn','Absolute'); };
			id_attn.onblur=function(){ id_attn.className='unfocuseditem'; sndreq('cls','Absolute'); };
		}
	}
	var links = document.getElementsByTagName("a");
	for (var i=0; i < links.length; i++){
		if (links[i].className.match("newwin")){
			links[i].onclick = function(){
				window.open(this.href);
				return false;
			}
		}
	}
}
function sndreq(action,css){
	xmlobject=getxmlobject();
	if (xmlobject==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="/rpc?action="+action+"&cssA="+css;
	xmlobject.onreadystatechange=stch;
	xmlobject.open("GET",url,true);
	xmlobject.send(null);
}
function stch(){
	if (xmlobject.readyState==4 || xmlobject.readyState=="complete"){
		var xmlresponse=xmlobject.responseText;
		xmlresp = xmlresponse.split('|');
		document.getElementById(xmlresp[0]).innerHTML=xmlresp[1];
	}
}
function had(id){
	this.className='had';
}
function ha(id){
	this.className='ha';
}
function formo(id){
	id.className='focuseditem';
}
function formt(id){
	id.className='unfocuseditem';
}
function ajaxsh(str,name){
	if (str.length==0){
		hidediv('formnamesuggestions');
		document.getElementById("formnamesuggestions").innerHTML="";
		return;
	} 
	xmlobject=getxmlobject();
	if (xmlobject==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="/rpc?q="+str+"&sq="+name;
	url=url+"&sid="+Math.random();
	xmlobject.onreadystatechange=statechanged;
	xmlobject.open("GET",url,true);
	xmlobject.send(null);
}
function statechanged(){
	if (xmlobject.readyState==4 || xmlobject.readyState=="complete"){ 
		document.getElementById("formnamesuggestions").style.display = 'block';
		document.getElementById("formnamesuggestions").innerHTML=xmlobject.responseText;
	}else{
		// something went wrong,report the errors
	}
}
function transfername(sugname){
	if (document.getElementById){
		dest=document.getElementById('name');
		if (dest){
			dest.value = sugname;
		}
	}
}
function opac(id,opacStart,opacEnd){
	var chgspd = Math.round(1000 / 100);
	var tmrrn = 0;
	if(opacStart > opacEnd){
		for(i = opacStart;i >= opacEnd;i--){
			setTimeout("selectopac(" + i + ",'" + id + "')",(tmrrn * chgspd));
			tmrrn++;
		}
	} else if(opacStart < opacEnd){
		for(i = opacStart;i <= opacEnd;i++){
			setTimeout("selectopac(" + i + ",'" + id + "')",(tmrrn * chgspd));
			tmrrn++;
		}
	}
}
function selectopac(opacity,id){
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function addEvent(elm, evType, fn, useCapture) {
	if(!elm) var elm="window";
	if (elm.addEventListener) { 
		elm.addEventListener(evType, fn, useCapture); 
		return true; 
	} else if (elm.attachEvent) { 
		var r = elm.attachEvent('on' + evType, fn); 
		EventCache.add(elm, evType, fn);
		return r; 
	} else {
		elm['on' + evType] = fn;
	}
}
function getEventSrc(e) {
	if (!e) e = window.event;
	if (e.originalTarget){
		return e.originalTarget;
	} else if (e.srcElement){
		return e.srcElement;
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler, bCapture){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			}
		}
	}
};
addEvent("window","unload",EventCache.flush,false);

