function debug(){
			fname=document.getElementById("name");
			fstreet=document.getElementById("street");
			femail=document.getElementById("email");
			fphone=document.getElementById("phone");
			fcity=document.getElementById("city");
			frest=document.getElementById("upload");

				fname.value="Name";
				fstreet.value="Street";
				femail.value="Email.Email@Email.Email";
				fphone.value="1234567890";
				fcity.value="Citry";
				//rest.value="C:\Documents and Settings\claw.COMPANY\Desktop\test.cdt";
		}
		
function formValidate(){
fname=document.getElementById("name");
fcompany=document.getElementById("company");
fstreet=document.getElementById("street");
femail=document.getElementById("email");
fphone=document.getElementById("phone");
ffax=document.getElementById("fax");
flognumber=document.getElementById("lognumber");
fcity=document.getElementById("city");
fmessage=document.getElementById("message");
 
if (fname.value == "" || 0){
alert("Please enter your name.");
fname.style.borderColor = "orange";
fname.focus();
}
else if (fstreet.value == "" || 0){
alert('Please enter your street address.');
fstreet.style.borderColor = "orange";
fstreet.focus();
}
else if (fcity.value == "" || 0){
alert('Please enter your address information.');
fcity.style.borderColor = "orange";
fcity.focus();
}
else if (validate_email(femail) == false){
alert ('Please enter a valid email address.');
femail.style.borderColor = "orange";
femail.focus();
}
else if (fphone.value == ""|| 0){
alert ("Please enter a phone number.");
fphone.style.borderColor = "orange";
fphone.focus();
}
else if (checkInternationalPhone(fphone.value)==false){
alert ("Please enter a valid phone number.");
fphone.style.borderColor = "orange";
fphone.focus();
}



else{
	
	upload(fname.value,fcompany.value,fstreet.value,fcity.value,fphone.value,ffax.value,femail.value,flognumber.value,fmessage.value);
}
 
 
}

function validate_email(field)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
  {return false;}
else {return true;}
}
}
 
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
 
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
 
function checkInternationalPhone(strPhone){
	var bracket=3
	strPhone=trim(strPhone)
	if(strPhone.indexOf("+")>1) return false
	if(strPhone.indexOf("-")!=-1)bracket=bracket+1
	if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
	var brchr=strPhone.indexOf("(")
	if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
	if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function clearFields(){
	$(".restTDinput").fadeOut("slow");
		$(".restTDtitle").fadeOut("slow");
		$(".instructions").html("<p style='color:red;'>Please wait until your file has completely uploaded before closing this window!</p>");
}

function showComplete(){
	
	$(".restTableForm,.instructions").fadeOut("fast", function(){
	$(".midcol").html("<p><b>Your CEREC&reg; restoration has been received.</b><br>A support represesntative will be contacting you shortly.<b><br><a href='http://www.cereconline.com/cerec/'>Click here to continue browsing the site.</a></p>").fadeIn("slow");
		//$(".instructions").html("<img src='check.jpg' style='float:left; margin-right: 3px; margin-top: -15px;'> <p style='font-size: 1.5em; margin-left: 2px; padding-left: 5px;'>Upload Complete.<p>").fadeIn("slow");
	});
	
		
}

function upload(name,company,street,city,phone,fax,email,lognumber,message){
	
				var obj = swfobject.getObjectById("SironaUpload");
					if (obj) {
					  obj.uploadFile(name,company,street,city,phone,fax,email,lognumber,message); // e.g. an external interface call
					}else{
						alert("Upload object not found.");
					}
}
