// JavaScript Document

// *********** JQuery. ************* //
// *********** JQuery. ************* //
function playSlideshow(num,prefix){
	// Set prefix.
	if (prefix == 0) {
		var prefix = "";
	}
	else if (prefix == 1) {
		var prefix = "../";
	}		
	var screenNumber = num;
	$.get(prefix+'slideshow.cfm?screen='+num+'&prefix='+prefix, function(data, status) {
		jQuery.facebox(data);
	});
}

// *********** ColdFusion AJAX. ************* //
// *********** ColdFusion AJAX. ************* //

//Open contact us window.
function openContactUs(prefix){
	// If window exists, destroy it.
	try{
	ColdFusion.Window.destroy('contactus',true);
	} catch (err) {}
	// Create new window.	
	var gen_config = {center:true,height:310,width:500,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('contactus','Contact Us',prefix+'common/contactus.cfm',gen_config);
	ob = ColdFusion.Window.getWindowObject('contactus');
    ob.center();	
}

//Submit contact us form.
function sendContactUsForm(prefix) {	
	// Call ColdFusion form validation.
	var check = _CF_checkContactUsForm(document.forms.ContactUsForm);
	// If forms ok.
	if (check == true) {
		// Disable submit button.
		document.ContactUsForm.submit.disabled = true; 
		// AJAX loader.
		document.getElementById("loader").style.display = "";
		// Create instance of proxy. 
		var proxy = new WLMap.com.components();	
		// Set form. 
		proxy.setForm("ContactUsForm");
		// Set callback.
		proxy.setCallbackHandler(function(myResults) {
			popURL = prefix+"common/contactus.cfm?requestsent=yes";
			ColdFusion.navigate(popURL,'contactus');			
		})
		// Set error handling.
		proxy.setErrorHandler(function(statusCode, statusMsg){
			alert("Error "+statusCode+": "+statusMsg);
		})		
		// Set CFC.
		proxy.sendContactEmail();
	}
}

//Open portal link window.
function openPortalWindow(prefix) {	
	// If window exists, destroy it.
	try{
	ColdFusion.Window.destroy('portal',true);
	} catch (err) {}
	// Create new window.	
	var portal_config = {center:true,height:200,width:435,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('portal','Portal Link',prefix+'common/portal_link.cfm',portal_config);	
	ob = ColdFusion.Window.getWindowObject('portal');
    ob.center();	
}

//Submit portal link form.
function submitPortalForm(prefix) {
	// Call ColdFusion form validation.
	var check = _CF_checkPortalForm(document.forms.PortalForm);
	// If forms ok.
	if (check == true) {
		// Create instance of proxy. 
		var proxy = new WLMap.com.components();			
		// Set form. 
		proxy.setForm("PortalForm");		
		// Set callback.
		proxy.setCallbackHandler(function(myResults) {
			popURL = prefix+"common/portal_link.cfm?url="+myResults;	
			ColdFusion.navigate(popURL,'portal');
		})
		// Set error handling.
		proxy.setErrorHandler(function(statusCode, statusMsg){
			alert("Error "+statusCode+": "+statusMsg);
		})		
		// Set CFC.
		proxy.getPortalLink();
	}
}

//Open demo window.
function openDemoWindow(prefix) {
	// If window exists, destroy it.
	try{
	ColdFusion.Window.destroy('demo',true);
	} catch (err) {}
	// Create new window.	
	var demo_config = {center:true,height:575,width:685,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('demo','WiziLegal: Overview',prefix+'screencasts/overview_general/overview_general.html?prefix='+prefix,demo_config);
	ob = ColdFusion.Window.getWindowObject('demo');
    ob.center();
	ColdFusion.Window.onHide('demo',cleanup);
}

function cleanup() {
	ColdFusion.Window.destroy('demo',true);
}

function openFeatures(){
	popURL="virtual-law-office-and-document-automation-features.cfm";
	// Create new window.
	var feature_config = {center:true,height:500,width:375,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('features','WiziLegal: Features',popURL,feature_config);	
	ob = ColdFusion.Window.getWindowObject('features');
    ob.center();	
}

function openPricing(){
	popURL="pricing-details.cfm";
	// Create new window.
	var feature_config = {center:true,height:300,width:500,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('price','WiziLegal: Pricing Details',popURL,feature_config);	
	ob = ColdFusion.Window.getWindowObject('price');
    ob.center();	
}

function openFAQs(){
	popURL="faqs.cfm";
	// Create new window.
	var feature_config = {center:true,height:300,width:500,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('faqs','WiziLegal: FAQs',popURL,feature_config);	
	ob = ColdFusion.Window.getWindowObject('faqs');
    ob.center();	
}

function openScreenShots(select_screen){
	popURL="../common/screen-shots.cfm?select_screen=" + select_screen;
	// Create new window.
	var screen_shots_config = {center:true,height:425,width:800,modal:true,resizable:false,initshow:true}
	ColdFusion.Window.create('screen_shots','WiziLegal: Screen Shots',popURL,screen_shots_config);	
	ob = ColdFusion.Window.getWindowObject('screen_shots');
    ob.center();	
}

function changeScreenShots(select_screen){
	popURL="../common/screen-shots.cfm?select_screen=" + select_screen;
	ColdFusion.navigate(popURL,'screen_shots');
}

// Open screencast tutorials.
function openScreencast(episode) {
	switch(episode) {
		case 1:
			var popURL = "../screencasts/overview_general/overview_general.html";
			var height = 575;
			break;
		case 2:
			var popURL = "../screencasts/overview_client/overview_client.html";
			var height = 650;
			break;			
		case 3:
			var popURL = "../screencasts/overview_administration/overview_administration.html";
			var height = 650;
			break;		
		default:
			var popURL = "../screencasts/overview_general/overview_general.html";
			var height = 575;
			break;			
	}	
	window.open(popURL,'Screencast','left=50,top=50,width=725,height='+height+',toolbar=0,resizable=1');
}