
function valform(formid) {
var myform=document.getElementById(formid);
var mydemo=window.location.search;
var myreqs=0;
$(".req").each(function(){
if($(this).val()==''){
	$(this).css("background","yellow");
	myreqs=1;
}
	});
if(mydemo){
$('#cncontact').append('<input type="hidden" name="demo" value="yes" /\>');

}

if(myreqs){
	alert('Please enter a value for the indicated fields.');
	return false;
	} else {
	myform.submit();
//alert('howdy');
	}
}


function requestdemo() {
var mydemo = window.location.search;
if (mydemo) {
$('demo').checked = true;
$('demorow').style.backgroundColor="yellow";
//alert(mydemo);
	}
}
//window.onload=requestdemo;

function findPos(obj) {			/* finds the x,y location of obj */
var curleft = curtop = 0;
  if (obj.offsetParent) {
      do {
         curleft += obj.offsetLeft;
         curtop += obj.offsetTop;
      } while (obj = obj.offsetParent);
return [curleft,curtop];
  }
}

function makeId() {			/* creates a unique number string */
	return parseInt(new Date().getTime().toString().substring(0, 10))
}

function addFrame(thediv,loc) {		/* clones both the dummy div and the inset and inserts them into the dom at the location of the link */
var myid = "id_"+makeId();		/* to use, make inset as div with class = "inset" and a unique id (e.g. "myinset", */
var container = $('#insetframe').clone(true);	/* then a link like this: onclick="addFrame('myinset',this);return false" */
$(container).attr('id',myid);			/* might need to pass an inset size at some point, we'll see. */
$('body').append($(container));
var myinnards=$('#'+thediv).html();
//$(container).append($('#'+thediv).text().clone());
$(container).children('h5').after('<p>'+myinnards+'</p>');//before('<strong>HELLO</strong>');

var theloc = findPos(loc);
var ht=theloc[1]+"px";
var wt=(theloc[0]-300)+"px";

//$(container).append($(newDiv));
$(container).css({"left":wt,"top":ht}).fadeIn('fast');
//alert(theloc.toString()+", "+myid);
//alert($('#'+thediv).text())
}

function fadeInset(obj) {			/* removes the cloned inset from the dom */
//var myins=obj.parentNode.parentNode.id;
alert(obj);
//	$("#"+obj.id).fadeOut().remove();//document.body.removeChild($(obj.id));
}
