// JavaScript Document
function createRequestObject() {
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  separator = ',';
    // The token used to separate data from multi-select inputs
  query = '' + this.location;
  qu = query
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }
  //alert(numKP);
  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.<
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }
  return FORM_DATA;
}
FORM_DATA = createRequestObject();
var timerID;
var cont=0;

function show_div(){	
	clearTimeout(timerID);
	timerID=0;
}


function showmsg(){
	//alert("ok"+cont);
	cont=cont+1;
	if(cont==8){
	 show_div();
	 cont=0;
	 document.getElementById("msg_t").innerHTML="&nbsp;";
	 document.getElementById("msg_t").style.display="none";	 
	 var cur_url=window.location.href.split("?");
	// alert(cur_url[0]);
	window.location=cur_url[0]+"#btm";
	}
}

 function submitForm(){
 var anch;
	if(validateForm("frm1")==true){		
		//document.forms["frm1"].submit();
		ajxsubmit();
	}
}

function set_msg(id){
	window.location="#btm";
	 timerID  = setInterval("showmsg()",500);
	if(trimString(id)==1){
		//alert("ok"+id);
			document.getElementById("msg_t").innerHTML="Your contact form has been successfully submitted.";
			//alert("ok"+document.getElementById("msg_t").innerHTML);
	}else if(trimString(id)=="0"){
			document.getElementById("msg_t").innerHTML="Your contact form <br>was not submitted due to error in SMTP,<br>please try again.";
	}else{
		document.getElementById("msg_t").innerHTML="&nbsp;";
	}
	
	
}