// JavaScript Document
function vwd_massageForm(obj){
	var isQuery=setAction(obj);
	setSuccess(isQuery);
	setY(obj,isQuery);
	MM_findObj('subject').value = obj.name.replace(/_/g,' ');
	MM_findObj('recipient').value = 'info@compliancetechnologies.com'; //'rde'
	writeCookie('email',MM_findObj('email').value,9999);
}

function setY(obj,isQuery){
	var z="";
	if (obj.name.indexOf('pdf')!= -1) z='pdf';
	if (isQuery == false) {
		MM_findObj('y').value = obj.name.replace(/_/g,'')+'.'+z ;//
	} 
}

function setSuccess(isQuery){
	var successPage = "http://www.compliancetechnologies.com/cti_checkyouremail.shtml";
	if (isQuery == true) successPage = "http://www.compliancetechnologies.com/cti_querythankyou.shtml";
	MM_findObj('success').value = successPage ;
}

function setAction(obj) {
	var isQuery=false;
	var useReply="cti_"+obj.name.replace(/_/g,'')+".txt";
	if (useReply.indexOf("query") != -1) {
		useReply = "/cgi-bin/cgiemail/cti_query.txt";//"FormScript="query";
		isQuery = true;
	} else {
		if (useReply.indexOf("pdf") != -1) {
			useReply = "/cgi-bin/cgiemail/cti_pdfdownload.txt";
		}
	}
//	MM_findObj("form1").action="http://www.compliancetechnologies.com/cgi-bin/cgiemail/cgi-bin/"+useReply;
	MM_findObj("form1").action="http://www.compliancetechnologies.com/"+useReply;
return isQuery;
}

function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function vwd_submitTo(obj){
	var theForm=obj.name;
	if (theForm.indexOf("query") != -1) theForm="query";
	obj.action="http://www.compliancetechnologies.com/cgi/cti_formreply_"+theForm+".pl";
	//writeCookie('email',eAddr,9999);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
