browserName = navigator.appName;          
browserVer = parseInt(navigator.appVersion);

function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function moveXbySlicePos (x, imgname) { 
	var img = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
	
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) {
		x += img.x;
	}
	return x;
}

function getExplorerVersion()
{
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;

	var tempVers = navigator.appVersion;

	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) 
	{
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}


function moveYbySlicePos (y, imgname)
{
	var img = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
	if(!document.layers) 
	{
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par)
		{
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}    
	} 
	else if (img.y >= 0) 
		y += img.y;
		
	return y;
}

function ValidSearch ()
{
//	var tmp = document.search_form['s'].value;
//	if (tmp == "" || tmp == "type here..." || tmp == "TYPE HERE...")
//		alert("Please submit search criteria")
//	else
		document.search_form.submit();
}

function ChangeClassName (id,className)
{
	id.className = className;
}

function ShowDisclaimer ()
{
	var position
	if (navigator.appName == "Microsoft Internet Explorer")
		position = document.documentElement.scrollTop
	else
		position = window.pageYOffset
	
	if (position <= 100)
		position = 100;
	else
		position += 100;
	document.getElementById('div_disclaimer').style.top = position +'px';
	ShowDiv ('div_disclaimer');
}

function checkScroll(height) {
	document.getElementById('div_popup').style.top = Math.round((document.documentElement.clientHeight/2)-(height/2)+document.documentElement.scrollTop)+'px';
}

var VersionQue = new Array ();
function VersionCursor (div_name,current_version,contract_id)
{
	if (VersionQue[div_name])
		document.getElementById('vid_'+VersionQue[div_name]).style.backgroundImage 	= "none";

	VersionQue[div_name] 															= contract_id;
	document.getElementById('vid_'+contract_id).style.backgroundImage 				= "url('images/version_cursor.gif')";
	
	var url																			= 'ajax_version_summary.php?vnid='+current_version+'&vid='+div_name+'&uci='+contract_id;
	DoAjaxPage ('vi_'+div_name,url);
}

function VersionAction (div_name,task,contract_title)
{
	if (typeof VersionQue[div_name] != "undefined" && VersionQue[div_name] != '')
	{
		var contract_id = VersionQue[div_name];
		if (task == "view")
			goPopup('view_contract.php?uci='+contract_id,600,400,'yes','yes');
		else if (task == "edit")
			location.href = 'edit_contract.php?id='+contract_id;
		else if (task == "delete")
			DeleteContract(contract_id)
		else if (task == "delete all")
			DeleteAllContractVersion(contract_id)		
		else if (task == "print")
			goPopup('view_contract.php?p=1&uci='+contract_id,600,400,'yes','yes');
		else if (task == "email")
			ShowEmail(contract_id,contract_title)
		else if (task == "download")
			location.href = 'save_to_harddrive.php?uci='+contract_id;
		else if (task == "compare")
			ShowCompare (div_name,contract_id);
		else if (task == "share")			
			ShowShare(contract_id,contract_title)
		else if (task == "version")
			location.href = 'new_version.php?uci='+contract_id;
	}
	else
		alert ("You need to select contract first.");
}

function DoCommentsDiv (user_contract_id,for_edit)
{
	if (for_edit)
	{
		document.getElementById("comment_"+user_contract_id+"_view_body").style.display = "none";
		document.getElementById("comment_"+user_contract_id+"_edit_body").style.display = "block";		
	}
	else
	{
		document.getElementById("comment_"+user_contract_id+"_edit_body").style.display = "none";
		document.getElementById("comment_"+user_contract_id+"_view_body").style.display = "block";		

		var comments 	= document.getElementById("comment_"+user_contract_id+"_value").value
		document.getElementById("comment_"+user_contract_id+"_view").innerHTML = '<strong>Comments:</strong> '+comments;
		
		var url 		= "ajax_set_description.php";
		var parameters 	= "uci="+user_contract_id+"&description="+escape (comments)
		ShowSavingStatus ();
		makePOSTRequest(url, parameters,"CloseDivPopup (2)") 
	}
}

function CloseDivPopup (delayInSecond)
{
	setTimeout("SetDivPopupWindowStatus(0);", delayInSecond * 1000); 
	
}

function ShowSavingStatus ()
{
	var html	= '';
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 height=100 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td class="font12" align=center><strong>Saving...</strong></td>';
	html		+= '</tr>';	
	html		+= '</table>';
	
	DoDivPopupWindow (html,400);
}




function ShowDiv (div_name)
{
	document.getElementById(div_name).className 				= "visible";	
}

function HideDiv (div_name)
{
	document.getElementById(div_name).className 				= "invisible";	
}



function SetQuestionPosition (num_question)
{
	for (var i=1; i <= num_question; i++)
	{
		var status = document.getElementById("d_q"+i).className;
		if (status == "visible")
		{
			ShowDiv ("d_n"+i)	
			ShowDiv ("d_d"+i)
		}
		else
		{
			HideDiv ("d_n"+i)	
			HideDiv ("d_d"+i)
		}
	}
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
	{
		while(1)
		{
			curtop += obj.offsetTop;
			if(!obj.offsetParent)
				break;
			obj = obj.offsetParent;
		}
	}
	else if(obj.y)
		curtop += obj.y;
		
	return curtop;
}

function GotoQuestion (question_id)
{
	question_id				= question_id.replace("q","");
	question_id				= question_id.replace("_div","");	
	tmp_question_id			= question_id.split("_");
	question_id				= tmp_question_id[0]
	
	var tmp_question		= "QR-"+question_id
	var tmpObj				= document.getElementById("CONTRACT_QUESTION_XML").contentWindow.document.getElementById(tmp_question)		
	if (tmpObj)
	{
		document.getElementById("CONTRACT_QUESTION_XML").contentWindow.document.body.scrollTop = findPosY(tmpObj)
	}
}


function QuestionNav (next_question,current_question)
{
	if (next_question == 1)
		ShowStep3_ReadYourContract ();

  	var tmp 				=  document.getElementById("d_q"+next_question).getElementsByTagName("input");
	var question_id			= "";
	for (var i = 0; i < tmp.length; i++)
	{
		var myItem = tmp.item(i);
		
		if (myItem.getAttribute("type") == "hidden")
		{
			question_id = myItem.getAttribute("name");
			question_id	= question_id.replace("q","");
			question_id	= question_id.replace("_div","");	

			break;
		}

   }	
	GotoQuestion (question_id);

	HideDiv ("d_q"+current_question)
	HideDiv ("d_n"+current_question)	
	HideDiv ("d_d"+current_question)

	ShowDiv ("d_q"+next_question)
	ShowDiv ("d_n"+next_question)	
	ShowDiv ("d_d"+next_question)
}

function QuestionRadioDiv (fieldname)
{
	GotoQuestion (fieldname);
	var size				= document.my_contract[fieldname].length;
	for (var i=0; i < size; i++)
	{
		var myobj			= document.my_contract[fieldname][i];	
		if (document.my_contract[fieldname][i].checked)
		{
			myobj.setAttribute("checked","checked")
			ShowDiv (fieldname+"_"+document.my_contract[fieldname][i].value+"_child")
		}
		else
		{	
			myobj.removeAttribute("checked")		
			HideDiv (fieldname+"_"+document.my_contract[fieldname][i].value+"_child")
		}
	}
	PrePopulate ('dummy_store','CONTRACT_QUESTION_XML','')
}

function QuestionExhibitDiv (fieldname,jumpToEnd)
{
	jumpToEnd -= 0;
	
	if (!jumpToEnd)
	{
		GotoQuestion (fieldname);
	}
	
	var size				= document.my_contract[fieldname].length;
	for (var i=0; i < size; i++)
	{
		var myobj			= document.my_contract[fieldname][i];	
		if (document.my_contract[fieldname][i].checked)
		{
			myobj.setAttribute("checked","checked")
			ShowDiv (fieldname+"_"+document.my_contract[fieldname][i].value+"_child")
		}
		else
		{	
			myobj.removeAttribute("checked")		
			HideDiv (fieldname+"_"+document.my_contract[fieldname][i].value+"_child")
		}
	}
	

	
	if (jumpToEnd)
	{	
		PrePopulate ('dummy_store','CONTRACT_QUESTION_XML','Add')
	
		var maxHeight = document.getElementById('CONTRACT_QUESTION_XML').contentWindow.document.body.scrollHeight;
		document.getElementById("CONTRACT_QUESTION_XML").contentWindow.document.body.scrollTop = maxHeight
	}
	else
	{

		PrePopulate ('dummy_store','CONTRACT_QUESTION_XML','Remove')
	}
	
}


function DoStep1Change (field)
{
	var value = "";
	if (field.type == "text" || field.type == "textarea")
	{
		if (field.name == "PART_A_ADDRESS2" || field.name == "PART_B_ADDRESS2")
		{
			if (field.value)
				value = "&nbsp;"+field.value		
			else
				value = "";
		}
		else if (field.name == "PART_A_ZIP" || field.name == "PART_B_ZIP" || field.name == "PART_A_STATE" || field.name == "PART_B_STATE")
		{
			if (field.value)
			{
				if (document.all)
					value = field.value+"&nbsp;";
				else
					value = field.value;
			}
			else
				value = "";
		
		}		
		else
			value = field.value
	}
	else if (field.type == "select-one")
	{
		value = field.options[field.selectedIndex].text;
	}


	if (document.getElementById("s_"+field.name))
	{
   		var tmp = document.getElementsByTagName("span");
		for (var i = 0; i < tmp.length; i++)
		{
			var myItem = tmp.item(i);
  			if (myItem.id == 's_'+field.name)
			{

				myItem.innerHTML = value;
			}
	   }
	
		PrePopulate ('dummy_store','CONTRACT_QUESTION_XML','')
	}
}

function isRadio (variable)
{
	if (variable.type == "radio")
		return true
	else if (typeof variable[0] != "undefined" && variable[0].type == "radio")
		return true
	else
		return false
}

function isCheckBox (variable)
{
	if (variable.type == "checkbox")
		return true
	else if (typeof variable[0] != "undefined" && variable[0].type == "checkbox")
		return true
	else
		return false
}

function isHidden (variable)
{
	if (variable.type == "hidden")
		return true
	else if (typeof variable[0] != "undefined" && variable[0].type == "hidden")
		return true
	else
		return false

}

function DoFormExtraction (fieldname)
{
	var tmp	= document.my_contract[fieldname];
	if (typeof tmp == "undefined")
	{
		// Need to remove question that does not exist in  RTE
		var qid = fieldname.replace("q","QR-");
		var elem = document.getElementById(qid);
		if (elem)
			elem.parentNode.removeChild(elem)			
		
		return new Array();
	}
	else
	{	
		var answer = new Array ();
		if (tmp.type == "text" || tmp.type == "textarea")
		{
			if (tmp.value)
			{
				tmp.setAttribute("value",(tmp.value).replace(/<br>/g,"\n"))
				answer.push("TEXT|"+(tmp.value).replace(/\n/g,"<br>"));			
			}
			else
				answer.push("TEXT|"+"[INSERT TEXT]");	
			
		}
		else if (tmp.type == "select-one")
		{
			var size				= tmp.length;
			for (var i=0; i < size; i++)
			{
				var myobj				= tmp[i];	
				if (tmp.selectedIndex == i)
				{
					myobj.setAttribute("selected","selected")
				}
				else
				{
					myobj.removeAttribute("selected")		
				}
			}	
		
			answer.push(tmp.options[tmp.selectedIndex].value);
		}
		else if (isRadio (tmp))
		{
			if (typeof document.my_contract[fieldname].length == "undefined")
			{
				answer.push(tmp.value);	
			}
			else
			{	
				var size = document.my_contract[fieldname].length;
				
				for (var i=0; i < size; i++)
				{
					if (document.my_contract[fieldname][i].checked)
					{
						answer.push(document.my_contract[fieldname][i].value);
					}
				}
			}
		}
		else if (isCheckBox (tmp))
		{
			if (typeof document.my_contract[fieldname].length == "undefined")
			{
				answer.push(tmp.value);	
			}
			else
			{	
				var size = document.my_contract[fieldname].length;
				
				for (var i=0; i < size; i++)
				{
					if (document.my_contract[fieldname][i].checked)
					{
						answer.push(document.my_contract[fieldname][i].value);
					}
				}
			}
		}
		else if (isHidden(tmp))
		{
			if (typeof document.my_contract[fieldname].length == "undefined")
			{
				answer.push(tmp.value);	
			}
			else
			{
				var size = document.my_contract[fieldname].length;
				for (var i=0; i < size; i++)
				{
					answer.push(tmp[i].value);	
				}	
			}
		}
		
		return answer;
	}
}

function DoReplacement (fieldname, content)
{
	var result	= new Array ();
	
	var tmp		= content
	while (tmp.indexOf("[") != -1)
	{
		var start 	= tmp.indexOf("[")
		var end		= tmp.indexOf("]")
		result.push (tmp.substring(start+1,end))
		tmp			= tmp.slice(end+1)	
	}

	for (var i=0; i < result.length; i++)
	{
		var value	= DoFormExtraction (fieldname+"_"+result[i])+"";
		content		= content.replace("["+result[i]+"]",value.replace("TEXT|",""));
	}
	return content
}

function UpdateStorage ()
{
	var tmpObj 				= document.getElementById("CONTRACT_QUESTION_XML").contentWindow.document		
	var tmp 				= tmpObj.body.innerHTML;
	document.getElementById("dummy_store").innerHTML = tmp;
}

function DoAnswer (question_id)
{
	var answer = DoFormExtraction ("q"+question_id);

	var content	= '';
	for (var j=0; j < answer.length; j++)
	{
		if (answer[j].indexOf("TEXT|") != -1)
			content	+= ' '+ answer[j].replace ("TEXT|","");
		else
		{
			var tmp = document.getElementById("q"+question_id+"_"+answer[j]+"_content").innerHTML;
			if (tmp.indexOf("[") != -1)
				tmp = DoReplacement ("q"+question_id+"_"+answer[j],tmp);
			content	+= ' '+ tmp;
			if (document.getElementById("q"+question_id+"_"+answer[j]+"_child") != null)
			{
				if (document.getElementById("q"+question_id+"_"+answer[j]+"_child").innerHTML != "")
				{
					content += DoAnswer (question_id+"_"+answer[j]);
				}
			}
		}

	}


	return content;
}

function DoRTEListner (target)
{
	var tmp = document.getElementById(target).contentWindow.document;
	if (tmp.addEventListener)
	{
		checkAttach = tmp.addEventListener('keyup', UpdateStorage, true);		
	}
	else if (tmp.attachEvent)
	{
		// IE
		checkAttach = tmp.attachEvent('onkeyup', UpdateStorage);
	
	}
	else 
	{
		// old browser
		tmp.onmouseout = UpdateStorage();
	}	
}


function PrePopulate (source,target,exhibit_status)
{
	var node   = document.getElementById(source);
	var myDOM  = document.getElementById(source).getElementsByTagName("span");
	
	for (var i =0; i < myDOM.length; i++)
	{
		var tmp = myDOM[i].getAttribute("id")
		if (tmp)
		{
			var question_id = tmp.replace("QR-","");
			
			// Make sure that we dealing with question
			if (!isNaN(question_id))
			{
				if (typeof document.my_contract['q'+question_id+'_div'] != "undefined")
				{
					var id = document.my_contract['q'+question_id+'_div'].value;
					document.getElementById(tmp).innerHTML = DoAnswer (question_id)
				}
			}
		}
	}

	var	frameHtml = "";
		frameHtml += "<style type='text/css'>\n";
		frameHtml += "body {\n";
		frameHtml += "background: #FFFFFF;\n";
		frameHtml += "margin-left: 4px; margin-top: 2px;\n";
		frameHtml += "padding: 0px;\n";
		frameHtml += "font-family: Arial, Helvetica, sans-serif;\n";
		frameHtml += "font-size: 12px;\n";
		frameHtml += "}\n";
		frameHtml += "</style>\n";	
		
	// Update RTE
	var tmpObj = document.getElementById(target).contentWindow.document
	
	// Store the current position
	var prev_scroll = 0
	if (document.getElementById(target).contentWindow.document.body)
		prev_scroll = document.getElementById(target).contentWindow.document.body.scrollTop

	var tmp_html =	node.innerHTML;

	
	if (exhibit_status == 'Add')
	{
		tmp_html+= "<!-- START EXHIBIT -->";
		tmp_html += "<BR><HR>";
		tmp_html += "<!-- END EXHIBIT -->";		
		tmp_html += '<p STYLE="page-break-before: always"><b>EXHIBIT A</b></p>'
		tmp_html += '<br>'		
	}
	else
	{
		var tmp = tmp_html.split ("<!-- START EXHIBIT -->")
		tmp_html = tmp[0];
	}
	node.innerHTML	= tmp_html;
	var html_result = frameHtml+node.innerHTML	
	tmpObj.open();
	tmpObj.write(html_result);
	tmpObj.close();   

	if (document.getElementById(target).contentWindow.document.body)
	{
		// Need to access the value 3 times... a bug in IE
		document.getElementById(target).contentWindow.document.body.scrollTop = prev_scroll;		
		document.getElementById(target).contentWindow.document.body.scrollTop = prev_scroll;
		document.getElementById(target).contentWindow.document.body.scrollTop = prev_scroll;
	}

	DoRTEListner (target);
}


function DoDivPopupWindow (content,height)
{
	SetDivPopupWindowStatus (1,height);
	var html = '';
	html += '<table border=0 cellpadding=0 cellspacing=0 width="100%">';
	html += '<tr>';
	html += '<td align="center"  valign="middle">';
	html += content
	html += '</td>';
	html += '</tr>';
	html += '</table>';
	html += '<iframe></iframe>';
	document.getElementById("div_popup").innerHTML	= html
}

function SetDivPopupWindowStatus (isItOn,height)
{
	if (isItOn)
	{	
		checkScroll(height)
		document.getElementById("wrapper").className 	= "trans25";		
		document.getElementById("div_popup").className 	= "popup_window";
	}
	else
	{
		document.getElementById("wrapper").className 	= "";		
		document.getElementById("div_popup").className 	= "invisible";
	}
}

function DoPost(obj,url,parameters,fcn)
{
	var poststr = "";
	var parameter = parameters.split("|");
	for (var i=0; i < parameter.length; i++)
	{
		if (poststr)
			poststr	+= "&"
		poststr		+= parameter[i] + "=" + escape( document.getElementById(parameter[i]).value )  
	}

	makePOSTRequest(url, poststr,fcn);
}

var http_request = false;
function makePOSTRequest(url, parameters,fcn) 
{
	http_request = false;
	if (window.XMLHttpRequest) // Mozilla, Safari,...
	{ 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
			http_request.overrideMimeType('text/html');
		}
	} 
	else if (window.ActiveXObject) // IE
	{ 
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} 
			catch (e)  { }
		}
	}
	if (!http_request) 
	{
		alert('Cannot create XMLHTTP instance');
		return false;
	}

	http_request.onreadystatechange =  new Function(fcn);
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

function DoNothing ()
{

}

function DoAjaxPage (div_name,url)
{
	var url = url+"&nocache="+(new Date()-0);
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest();
		xmlHttp.onreadystatechange = new Function("processAJAX('"+div_name+"')");;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject) 
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlHttp) 
		{
		
			xmlHttp.onreadystatechange = new Function("processAJAX('"+div_name+"')");;
			xmlHttp.open("GET", url, true);
			xmlHttp.send();
		}
	}
}

function processAJAX(div_name) 
{
	// only if req shows "complete"
	if (xmlHttp.readyState == 4)
	{
		// only if "OK"
		if (xmlHttp.status == 200)
		{
			document.getElementById(div_name).innerHTML=xmlHttp.responseText 
		}
		else 
			alert("There was a problem retrieving the XML data:\n" + xmlHttp.statusText);
	}
}

function ShowEmailThankYou ()
{
	var html	= '';
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Email to a Friend</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td align=left>'+CONTRACT_TITLE+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left>';
	html		+= 'Contract sent.';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	
	DoDivPopupWindow (html,400);
}

function ShowMakePublicThankYou ()
{
	setTimeout("window.location.reload(true)", 4000); 	
	var html	= '';
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Make Public</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td>';
	html		+= 'Please wait while it is being saved.';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	DoDivPopupWindow (html,400);	
}

function ShowEmailDraftThankYou ()
{
	var html	= '';
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Email to a Friend</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td align=left>'+CONTRACT_TITLE+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left>';
	html		+= 'Contract sent.';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	
	DoDivPopupWindow (html,400);
}

var CONTRACT_TITLE = '';
function ShowEmail (user_contract_id,title)
{
	CONTRACT_TITLE = title
	var html	= '';
	
	
	html		+= '<form method="post" action="javascript:DoPost(document.getElementById(\'email_form\'),\'email_to_friend.php\',\'contract_title|id|your_name|your_email|recipient_name|recipient_email|message\',\'ShowEmailThankYou()\');" name="email_form" id="email_form">';	
	html		+= '<input type="hidden" id="id" value="'+user_contract_id+'">';
	html		+= '<input type="hidden" id="contract_title" value="'+title+'">';	
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Email to a Friend</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td align=left>'+title+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left>';
	html		+= '<p>Your Name:<br><input type="text" id="your_name" value="'+FIRST_NAME+' '+LAST_NAME+'" size=20></p>';
	html		+= '<p>Your Email:<br><input type="text" id="your_email" value="'+EMAIL+'" size=20></p>';	
	html		+= '<p>Recipient Name:<br><input type="text" id="recipient_name" size=20></p>';
	html		+= '<p>Recipient Email:<br><input type="text" id="recipient_email" size=20></p>';		
	html		+= '<p>Message:<br><textarea id="message" cols="50" rows="5"></textarea></p>';			
	html		+= '<input type="submit" id="cmd" value="Send It!">';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	html		+= '</form>';
	DoDivPopupWindow (html,400);
}

var VERSION_ID = '';
var USER_CONTRACT_ID = '';


function processCompare() 
{
	// only if req shows "complete"
	if (xmlHttp.readyState == 4)
	{
		// only if "OK"
		if (xmlHttp.status == 200)
		{
			var html	= '';
			
			html		+= '<form name="compare_form" id="compare_form">';	
			html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
			html		+= '<tr>';
			html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
			html		+= '</tr>';	
			html		+= '<tr>';
			html		+= '<td align=left><strong>Compare Versions</strong></td>';
			html		+= '</tr>';		
			html		+= xmlHttp.responseText;		
			html		+= '<tr>';
			html		+= '<td>';
			html		+= '<input type="button" onclick="DoCompare (\'compare_form\',\'source\',\'target\')" value="Compare">';
			html		+= '</td>';
			html		+= '</tr>';			
			html		+= '</table>';
			html		+= '</form>';
			DoDivPopupWindow (html,400);			
		}
		else 
			alert("There was a problem retrieving the XML data:\n" + xmlHttp.statusText);
	}
}

function validMakePublic ()
{
	if (document.make_public_form.CONTRACT_CATEGORY_ID.selectedIndex)
	{
		DoPost(document.getElementById('make_public_form'),'make_contract_public.php','CONTRACT_ID|CONTRACT_CATEGORY_ID|DEFAULT_SHOW_WHAT','ShowMakePublicThankYou()');
	}
	else
		alert("Please select a Public Category")
}

function processMakePublic() 
{
	// only if req shows "complete"
	if (xmlHttp.readyState == 4)
	{
		// only if "OK"
		if (xmlHttp.status == 200)
		{
			var html	= '';
			
			html		+= '<form method="post" name="make_public_form" id="make_public_form">';				
			html		+= '<input type="hidden" id="cmd" value="Submit">';
			html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
			html		+= '<tr>';
			html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
			html		+= '</tr>';	
			html		+= '<tr>';
			html		+= '<td align=left><strong>Make Public</strong></td>';
			html		+= '</tr>';		
			html		+= xmlHttp.responseText;		
			html		+= '<tr>';
			html		+= '<td>';
			//html		+= '<input type="submit" id="cmd" value="Submit">';			
			html		+= '<input type="button" id="cmd" value="Submit" onclick="validMakePublic()">';			
			html		+= '</td>';
			html		+= '</tr>';			
			html		+= '</table>';
			html		+= '</form>';
			DoDivPopupWindow (html,400);			
		}
		else 
			alert("There was a problem retrieving the XML data:\n" + xmlHttp.statusText);
	}
}

function ShowCompare (version_id,user_contract_id)
{
	var url ="ajax_version_compare.php?uci="+user_contract_id+"&vid=" + version_id+ "&nocache="+(new Date()-0);
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest();
		xmlHttp.onreadystatechange = new Function("processCompare()");;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject) 
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlHttp) 
		{
		
			xmlHttp.onreadystatechange = new Function("processCompare()");;
			xmlHttp.open("GET", url, true);
			xmlHttp.send();
		}
	}
}

function ShowMakePublic (contract_id)
{
	var url ="ajax_contract_make_public.php?ci="+contract_id+ "&nocache="+(new Date()-0);
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest)
	{
		xmlHttp = new XMLHttpRequest();
		xmlHttp.onreadystatechange = new Function("processMakePublic()");;
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject) 
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlHttp) 
		{
		
			xmlHttp.onreadystatechange = new Function("processMakePublic()");;
			xmlHttp.open("GET", url, true);
			xmlHttp.send();
		}
	}
}


function ShowEmailDraft ()
{
	var html	= '';
	
	html		+= '<form method="post" action="javascript:DoPost(document.getElementById(\'email_form\'),\'email_draft_to_friend.php\',\'contract_title|contract_body|your_name|your_email|recipient_name|recipient_email|message\',\'ShowEmailDraftThankYou()\');" name="email_form" id="email_form">';	
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Email to a Friend</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td align=left>';
	html		+= '<p>Your Name:<br><input type="text" id="your_name" value="'+FIRST_NAME+' '+LAST_NAME+'" size=20></p>';
	html		+= '<p>Your Email:<br><input type="text" id="your_email" value="'+EMAIL+'" size=20></p>';	
	html		+= '<p>Recipient Name:<br><input type="text" id="recipient_name" size=20></p>';
	html		+= '<p>Recipient Email:<br><input type="text" id="recipient_email" size=20></p>';		
	html		+= '<p>Subject:<br><input type="text" id="contract_title" size=20></p>';	
	html		+= '<p>Message:<br><textarea id="message" cols="50" rows="5"></textarea></p>';			
	html		+= '<input type="submit" id="cmd" value="Send It!">';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	var tmpObj 	= document.getElementById("CONTRACT_QUESTION_XML").contentWindow.document		
	var tmp 	= tmpObj.body.innerHTML;	
	
	html		+= '<div class="invisible"><textarea id="contract_body" cols="50" rows="5">';
	html		+= tmp;
	html		+= '</textarea></div>';
	html		+= '</form>';
	DoDivPopupWindow (html,400);
}

function ShowShare (user_contract_id,title)
{
	CONTRACT_TITLE = title
	var html	= '';
	
	html		+= '<form method="post" action="javascript:DoPost(document.getElementById(\'share_form\'),\'share_to_friend.php\',\'contract_title|id|your_name|your_email|emails|message\',\'ShowShareThankYou()\');" name="share_form" id="share_form">';	
	html		+= '<input type="hidden" id="id" value="'+user_contract_id+'">';
	html		+= '<input type="hidden" id="contract_title" value="'+title+'">';	
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr valign="top">';
	html		+= '<td align=left></td>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left colspan=2>'+title+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left>';
	html		+= '<p>Your Name:<br><input type="text" id="your_name" value="'+FIRST_NAME+' '+LAST_NAME+'" size=20></p>';
	html		+= '<p>Your Email:<br><input type="text" id="your_email" value="'+EMAIL+'" size=20></p>';	
	html		+= '<p>People to share with (One email per line)<br>(WARNING: Once shared, this person can edit and save changes to this version only):<br><textarea id="emails" cols="50" rows="5" style="overflow: auto;"></textarea></p>';			
	html		+= '<p>Message:<br><textarea id="message" cols="50" rows="5"></textarea></p>';			
	html		+= '<input type="submit" id="cmd" value="Send It!">';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	html		+= '</form>';
	DoDivPopupWindow (html,400);
}

function ShowShareThankYou ()
{
	var html	= '';
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Share to a Friend</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td align=left>'+CONTRACT_TITLE+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left>';
	html		+= 'Contract sent.';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	
	DoDivPopupWindow (html,400);
}


function ShowCollaborationMember (user_contract_id,title)
{
	CONTRACT_TITLE = title
	var html	= '';
	
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left><strong>Collaboration Member</strong></td>';
	html		+= '</tr>';		
	html		+= '<tr>';
	html		+= '<td align=left>'+title+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=align=center>';
	html		+= '<div id="div_members" style="overflow: auto; height:100px;width:350px"></div>';	
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	DoDivPopupWindow (html,400);
	DoAjaxPage ("div_members","collaboration_member.php?uci="+user_contract_id)		
}

var USER_CONTRACT_ID = ''
function ShowComments (user_contract_id,title)
{
	CONTRACT_TITLE = title
	USER_CONTRACT_ID = user_contract_id
	var html	= '';
	
	html		+= '<form method="post" action="javascript:DoPost(document.getElementById(\'comment_form\'),\'post_comments.php\',\'uci|comment\',\'ShowCommentThankYou()\');" name="comment_form" id="comment_form">';	
	html		+= '<input type="hidden" id="uci" value="'+user_contract_id+'">';
	html		+= '<table border=0 cellpadding=0 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=left class="font12"><strong>Add a Note</strong></td>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)"><b>X</b></a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left colspan=2>'+title+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left colspan=2>';
	html		+= '<p>Note:<br><textarea id="comment" cols="50" rows="5" class="textarea"></textarea></p>';			
	html		+= '<input type="submit" id="cmd" value="Post Note">';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	html		+= '</form>';	
	
	DoDivPopupWindow (html,400);
}

var prev_source_value = '';
var prev_target_value = '';
function SetComparison (form_name,source,target)
{
	var myform 				= eval ("document."+form_name);
	var source_value 		= myform[source].options[myform[source].selectedIndex].value
	var target_value 		= myform[target].options[myform[target].selectedIndex].value	
	var prev_source_value 	= source_value;
	var prev_target_value 	= target_value;	
	
	for (var i=0; i < myform[source].length; i++)
	{
		document.test.test2.options[2].style.color="#d8d8d8"
	}
	
	alert(document.test.test2.options[i].value)
}

function DoCompare (form_name,source,target)
{
	var myform 				= eval ("document."+form_name);
	var source_value 		= myform[source].options[myform[source].selectedIndex].value
	var target_value 		= myform[target].options[myform[target].selectedIndex].value	
	location.href			= "version_comparison.php?suci="+source_value+"&tuci="+target_value;
}

function ShowCommentThankYou ()
{
	var html	= '';
	html		+= '<table border=0 cellpadding=5 cellspacing=0 width=400 style="border: 1px solid black;background-color:#f5f5f5;padding:5px;" class="font11">';
	html		+= '<tr>';
	html		+= '<td align=left class="font12"><strong>Your Comment Has Been Added</strong></td>';
	html		+= '<td align=right><a href="javascript:SetDivPopupWindowStatus(0)">X</a></td>';
	html		+= '</tr>';	
	html		+= '<tr>';
	html		+= '<td align=left colspan=2>'+CONTRACT_TITLE+'</td>';
	html		+= '</tr>';			
	html		+= '<tr>';
	html		+= '<td align=left colspan=2>';
	html		+= 'comment posted.';
	html		+= '</td>';
	html		+= '</tr>';			
	html		+= '</table>';
	
	DoDivPopupWindow (html,400);
	DoAjaxPage ("d_comment_area","contract_comments.php?uci="+USER_CONTRACT_ID)		
}

function TaskForm (value)
{
	document.my_contract["task"].value = value;
	CmdForm ("Save So Far")
}

function CmdForm (value)
{
	if (value == "I am Finished!" || value == "Save So Far")
		document.my_contract["CONTRACT_ANSWER"].value = document.getElementById("question_box").innerHTML;

	document.my_contract["CONTRACT_XML"].value = document.getElementById("dummy_store").innerHTML		

	document.my_contract["cmd"].value = value;
	updateRTEs();
	document.my_contract.submit();

	return false;

}


function ViewThis(is_print)
{
	var html		= '';
	// Header
	html			+= '<html>';
	html			+= '<head>';
	html			+= '	<title>WhichDraft.com</title>';
	html			+= '	<link rel="STYLESHEET" type="text/css" href="css/wd_print.css">';
	html			+= '</head>';
	if (is_print)
		html		+= '<body onload="window.print();">';
	else
		html		+= '<body style="color:black">';
	var tmpObj 		= document.getElementById("CONTRACT_QUESTION_XML").contentWindow.document		
	var tmp 		= tmpObj.body.innerHTML;

	tmp				= tmp.replace(/background-color/ig,"nothing");	

	var tmp2		= tmp.split ("<!-- START EXHIBIT -->");
	if (tmp2.length == 2)
	{
		var tmp3	= tmp2[1].split ("<!-- END EXHIBIT -->");
		tmp			= tmp2[0]+tmp3[1];
	}
		
	html			+= tmp;
	html			+= '<div id="view_header"><img src="images/chop.gif" alt="A Free Contract From WhichDraft.com" width="99" height="100"></div>';

	html			+= '</td></tr></table>';
	html			+= '</body>';
	html			+= '</html>';
	
	var str = 'toolbar=1,scrollbars=1,location=0,statusbar=1,menubar=1,resizable=1'	
	var win = window.open("","_blank", str);
	win.document.open("text/html", "replace");	
	win.document.write(html);
	win.document.close();
	win.window.focus();	
}

function goPopup(url,width,height,scroll,menu)
{
	if (menu == "yes")
		window.open(url, '_blank', 'width='+width+',height='+height+',scrollbars='+scroll+',menubar=yes,toolbar=yes');	
	else
		window.open(url, '_blank', 'width='+width+',height='+height+',scrollbars='+scroll);
}

function DeleteAccount ()
{
	var status				= confirm("Are you sure you want to delete your account? All saved contracts will be lost.");
	if (status)
	{
		location.href = "delete_account.php";
	}	
}

function DeleteContract (user_contract_id)
{
	var status               = confirm ("Are you sure you want to delete this version?")
	if (status)
	{
		location.href = "delete_contract.php?uci="+user_contract_id;
	}
}

function DeleteAllContractVersion (user_contract_id)
{
	var status               = confirm ("Are you sure you want to delete this contract?")
	if (status)
	{
		location.href = "delete_all_contract_version.php?uci="+user_contract_id;
	}
}

	
function DoPreview (form_name)
{
	var	current_form		= eval ('document.'+form_name);
	
	if (document.all) // This require when form is within DIV for IE for work
		current_form 		= document.getElementById(form_name);

	var arguements	= DoFormPackaging (current_form);

	var url					= "ajax_question_preview.php"
	makePOSTRequest(url, arguements,"ShowPreviewQuestion ()");

}

function ShowPreviewQuestion ()
{
	// only if req shows "complete"
	if (http_request.readyState == 4)
	{
		// only if "OK"
		if (http_request.status == 200)
		{
			document.getElementById('d_preview').innerHTML=http_request.responseText 
		}
		else 
			alert("There was a problem retrieving the XML data:\n" + http_request.statusText);
	}
	
}

function DoFormPackaging (my_form)
{

	var reqStr = ""; 
	var isFormObject;
	for(i=0; i < my_form.elements.length; i++) 
	{ 
		switch (my_form.elements[i].tagName) 
		{ 
			case "INPUT": 
				if (my_form.elements[i].type == "text" || 
					my_form.elements[i].type == "hidden" || 
					my_form.elements[i].type == "password")
				{
					reqStr += my_form.elements[i].name + "=" + escape(my_form.elements[i].value)
					isFormObject = true;
				}
				else if (my_form.elements[i].type == "checkbox" ||
						 my_form.elements[i].type == "radio")
				{
					if (my_form.elements[i].checked) 
					{
						reqStr += my_form.elements[i].name + "=" + my_form.elements[i].value; 
						isFormObject = true;						
					}
				}
				break; 
			case "TEXTAREA": 
				reqStr += my_form.elements[i].name + "=" + escape(my_form.elements[i].value); 
				isFormObject = true;				
				break; 
			case "SELECT": 
				var sel = my_form.elements[i]; 
				reqStr += sel.name + "=" + sel.options[sel.selectedIndex].value; 
				isFormObject = true;				
				break;
		} 
		if ((isFormObject) && ((i+1)!= my_form.elements.length)) 
		{ 
			reqStr += "&"; 
		} 
		isFormObject = false;
	} 
	return reqStr; 

}


function ConfirmDeletion (formName,fieldname,error_msg)
{
	var myForm = eval ('document.'+formName);

	var id    = myForm[fieldname].value;
	if (id)
	{
		var status               = confirm (error_msg)
		if (status)
		{
			myForm["cmd"].value = "Delete";
			myForm.submit();		
		}
	}	
}

function DoPreviewButton (object)
{
	var myForm = document.my_contract
	
	if (object.type == "radio")
	{
		var length = myForm[object.name].length;
		if (typeof length != "undefined")
		{
			for (var i=0; i < length; i++)
			{
				if (myForm[object.name][i].checked)
				{
					ShowDiv (object.name+'_'+myForm[object.name][i].value+'_content');
				}
				else
				{
					HideDiv (object.name+'_'+myForm[object.name][i].value+'_content');
				}
			}
		}
	}
	else if (object.type == "checkbox")
	{
		var length = myForm[object.name].length;
		if (typeof length != "undefined")
		{
			for (var i=0; i < length; i++)
			{
				if (myForm[object.name][i].checked)
				{
					ShowDiv (object.name+'_'+myForm[object.name][i].value+'_content');
				}
				else
				{
					HideDiv (object.name+'_'+myForm[object.name][i].value+'_content');
				}
			}
		}
	}
	else if (object.type == "select-one")
	{
		var length = object.length;
		if (typeof length != "undefined")
		{
			for (var i=0; i < length; i++)
			{
				if (object.selectedIndex == i)
				{
					ShowDiv (object.name+'_'+object.options[i].value+'_content');
				}
				else
				{
					HideDiv (object.name+'_'+object.options[i].value+'_content');
				}
			}
			
	
		}
	}
}

function setBlank (form_name,fieldname,default_value)
{
	var tmp = eval("document."+form_name);
	
	if (tmp[fieldname].value == default_value)
		tmp[fieldname].value = "";
}

function setDefault  (form_name,fieldname,default_value)
{
	var tmp = eval("document."+form_name);
	
	if (tmp[fieldname].value == "")
		tmp[fieldname].value = default_value;	
}

function RenderRating (value)
{
	if (value == 0)
		value = document.rating_form['value'].value;
	
	// Set the star empty
	for (var i=1; i <= 5; i++)
	{
		 document["star"+i].src = "images/star_gray.gif";
	}
	
	// Set the star full
	for (var i=1; i <= value; i++)
	{
		 document["star"+i].src = "images/star_yellow.gif";	
	}	
}



function ResizeStepPosition ()
{
	if (document.getElementById('step1_letsgo'))
	{
		var x,y;
	
		x = moveXbySlicePos (-190, 'step1_position');
		y = moveYbySlicePos (18, 'step1_position');
	
		document.getElementById('step1_letsgo').style.left = x+'px';	
		document.getElementById('step1_letsgo').style.top = y+'px';		
		
		x = moveXbySlicePos (-185, 'step2_position');
		y = moveYbySlicePos (80, 'step2_position');
	
		document.getElementById('step2_clickarrows').style.left = x+'px';	
		document.getElementById('step2_clickarrows').style.top = y+'px';			
	
		x = moveXbySlicePos (935, 'step2_position');
		y = moveYbySlicePos (160, 'step2_position');
		
		document.getElementById('step3_readyourcontract').style.left = x+'px';	
		document.getElementById('step3_readyourcontract').style.top = y+'px';		

		setTimeout("ResizeStepPosition()",1000);	
	}

}

setTimeout("ResizeStepPosition()",2000);

function ShowStep1_LetsGo ()
{
	var x,y;

	x = moveXbySlicePos (-190, 'step1_position');
	y = moveYbySlicePos (18, 'step1_position');

	document.getElementById('step1_letsgo').style.left = x+'px';	
	document.getElementById('step1_letsgo').style.top = y+'px';		
		
	document.getElementById('step1_letsgo').style.display = 'block';

}

function ShowStep2_ClickArrows ()
{
	var x,y;
	
	document.getElementById('step1_letsgo').style.display = 'none';	

	x = moveXbySlicePos (-185, 'step2_position');
	y = moveYbySlicePos (80, 'step2_position');

	document.getElementById('step2_clickarrows').style.left = x+'px';	
	document.getElementById('step2_clickarrows').style.top = y+'px';		
		
	document.getElementById('step2_clickarrows').style.display = 'block';
	
}

function ShowStep3_ReadYourContract ()
{
	var x,y;
	if (document.getElementById('step2_clickarrows'))
	{
		if (document.getElementById('step2_clickarrows').style.display != 'none')
		{
			document.getElementById('step2_clickarrows').style.display = 'none';	
		
			x = moveXbySlicePos (935, 'step2_position');
			y = moveYbySlicePos (160, 'step2_position');
		
			document.getElementById('step3_readyourcontract').style.left = x+'px';	
			document.getElementById('step3_readyourcontract').style.top = y+'px';		
				
			document.getElementById('step3_readyourcontract').style.display = 'block';
		}
	}
}



var step1_filled = new Array ();
for (var k =1; k <= 10; k++)
	step1_filled[k] = 0;
	
function CheckStep1 (field,field_pos)
{
	var value = "";
	if (field.type == "text" || field.type == "textarea")
	{
		if (field.name == "PART_A_ADDRESS2" || field.name == "PART_B_ADDRESS2")
		{
			if (field.value)
				value = "&nbsp;"+field.value		
			else
				value = "";
		}
		else if (field.name == "PART_A_ZIP" || field.name == "PART_B_ZIP" || field.name == "PART_A_STATE" || field.name == "PART_B_STATE")
		{
			if (field.value)
			{
				if (document.all)
					value = field.value+"&nbsp;";
				else
					value = field.value;
			}
			else
				value = "";
		
		}		
		else
			value = field.value
	}
	else if (field.type == "select-one")
	{
		value = field.options[field.selectedIndex].text;
	}

	if (value)
		step1_filled[field_pos] = 1;
	else
		step1_filled[field_pos] = 0;
		
	var total = 0;	
	for (var k =1; k <= 10; k++)
		total += step1_filled[k];
	

	if (total == 10)
		ShowStep2_ClickArrows ()
}

