
/**********************************************************************************/
/*****************************AJAX MODAL DIALOGS***********************************/
/**********************************************************************************/

open_get_flash_dialog = function() {
	//
	// Dialog dimensions
	//
	var width         = 535;
	var height        = 195;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '';
	url += '/Dialogs/GetFlash.aspx' + params;
	open_dialog(url, width, height);
}

open_360_dialog = function(modelid, modelyear, modelname) {
	//
	// Dialog dimensions
	//
	var width         = 660;
	var height        = 600;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '?modelID=' + modelid + '&modelYear=' + modelyear + '&modelName=' + modelname;
	url += '/Dialogs/360.aspx' + params;
	open_dialog(url, width, height);
}

open_privacy_dialog = function() {
	//
	// Dialog dimensions
	//
	var width         = 600;
	var height        = 600;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '';
	url += '/Dialogs/Privacy.aspx' + params;
	open_dialog(url, width, height);
}

open_casis_dialog = function() {
	//
	// Dialog dimensions
	//
	var width         = 585;
	var height        = 350;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '';
	url += '/Dialogs/CASIS.aspx' + params;
	open_dialog(url, width, height);
}

open_copyright_dialog = function() {
	//
	// Dialog dimensions
	//
	var width         = 600;
	var height        = 445;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '';
	url += '/Dialogs/Copyright.aspx'; + params;
	open_dialog(url, width, height);
}

open_tvspots_dialog = function(model) {
	
	if(typeof model=="undefined")
		model = '';
	
	//
	// Dialog dimensions
	//
	var width         = 600;
	var height        = 620;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '';
	params += '?model=' + model
	url += '/Dialogs/TVSpots.aspx' + params;
	open_dialog(url, width, height);
}

open_dealer_locator_dialog = function(postalcode) {
	//
	// Dialog dimensions
	//
	var width         = 640;
	var height        = 325;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '?postalcode=' + postalcode;
	url += '/Dialogs/DealerSearch.aspx' + params;
	open_dialog(url, width, height);
}

//open_sales_event_1_dialog = function() {
//	//
//	// Dialog dimensions
//	//
//	var width         = 765;
//	var height        = 700;
//	//
//	//Construct the appropriate url for the given environment.
//	//
//	var url = "";
//	//
//	// add querysting parameters 
//	//
//	var params = '';
//	url += '/PriceAdvantage.aspx' + params;
//	open_dialog(url, width, height);
//}

open_rally_support_program_dialog = function() {
	//
	// Dialog dimensions
	//
	var width         = 900;
	var height        = 700;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "";
	//
	// add querysting parameters 
	//
	var params = '';
	url += '/Offers/AjaxRallyProgram.aspx' + params;
	open_dialog(url, width, height);
}



/**********************************************************************************/
/****************************IFRAME MODAL DIALOGS**********************************/
/**********************************************************************************/

open_configurator_dialog = function(LangID, Year, ModelID, TrimID) {
	if (typeof(Year) == "undefined"){ Year=""; }
	if (typeof(ModelID) == "undefined"){ ModelID=""; }
	if (typeof(TrimID) == "undefined"){ TrimID=""; }
	
	//Dailog dimensions
	var width         = 900;
	var height        = 700;
	
	//Configurator external domain and with internal/external port numbers
	var ext_domain = "configurator.mitsubishi-motors.ca";
	var test_port = 20475;
	var demo_port = 30475;
	
	//Construct the appropriate url for the given environment.
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		case "alphademo2.dmt.ca":
			url += "alphademo1.dmt.ca" + '/';
			break;
		default:
			url += ext_domain + '/';
	}
	url += 'BuildYourMitsubishi.aspx?TimePeriodID='+ Year + '&ModelID=' + ModelID + '&TrimID=' + TrimID + '&lng=' + LangID;
	
	//open the dialog
	open_iframe_dialog(url, width, height);
}

open_comparator_dialog = function(LangID, ModelName, ModelYear) {
	var language_id = 22;//Default English
	if(LangID==3)
		language_id = 26;//French
		
	if(ModelName=='Lancer_Sportback')
		ModelName = 'Lancer+Sportback';
	if(ModelName=='Eclipse_Spyder')
		ModelName = 'Eclipse+Spyder';
	
	//Dailog dimensions
	var width         = 900;
	var height        = 700;
	
	//Configurator external domain and with internal/external port numbers
	var ext_domain = "comparator.mitsubishi-motors.ca";
	var test_port = 20004;
	var demo_port = 30004;
	
	//Construct the appropriate url for the given environment.
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		default:
			url += ext_domain + '/';
	}
	url += '/browser.asp?language_id=' + language_id + '&compareclicked=true&guid=&screen=select&category=select_version&country=&translated_country=&translated_make=Mitsubishi&localmake=Mitsubishi&make=MITSUBISHI&model=' + '&localmodel='+ ModelName + '&translated_model=' + ModelName;
	
	//open the dialog
	open_iframe_dialog(url, width, height, true, 'yes');
}

open_preowned_inventory_dialog = function(vehicleGUID, langid, stylesheet){
	//
	// Dialog dimensions
	//
	var width         = 745;
	var height        = 865; 
	
	var test_port = 20046;
	var demo_port = 30046;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		default:
			url ='http://preowned.mitsubishi-motors.ca/';
	}
	//
	// add querysting parameters for
	//		currently selected language
	//		selected vehicle
	//		stylesheet name to apply
	//
	//url ='http://preowned.mitsubishi-motors.ca/';
	var params = '?lang=' + langid + '&guid=' + vehicleGUID.replace('#','') + '&stylesheet=' + stylesheet
	url += 'Inventory/CorporateVehicleDetails.aspx' + params
	//
	//open the dialog
	//
	open_iframe_dialog(url, width, height);
}

open_prospect_dialog = function(langid, pid, sourceid, modelid, stylesheet){
	//
	// Dialog dimensions
	//
	var width              = 666;
	var height             = 700;
	var educationEdgePage  = 2;
	var warrantyPage       = 3;
	var conceptCarsKMIPage = 4;
	
	switch(pid) {
		case educationEdgePage:
			if(langid==3) {
				width  = 650;
				height = 780;
			}
			else {
				width  = 650;
				height = 750;
			}
			break;
		case warrantyPage:
			if(langid==3) {
				width  = 650;
				height = 680;
			}
			else {
				width  = 650;
				height = 660;
			}
			break;
		case conceptCarsKMIPage:
			if(langid==3) {
				width  = 650;
				height = 720;
			}
			else {
				width  = 650;
				height = 700;
			}
			break;
		case 0:
			if(langid==3) {
				width  = 666;
				height = 800;
			}
			else {
				width  = 666;
				height = 850;
			}
			break;			
		default:
			height = 700;
	}
	
	var test_port = 20041;
	var demo_port = 30041;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		default:
			//This will be behind SSL
			url = "https://secure.mitsubishi-motors.ca/dct/";
	}
	//
	// add querysting parameters 
	//
	if(modelid==undefined)modelid='';
	//url = "https://secure.mitsubishi-motors.ca/dct/";
	//alert('open_prospect_dialog using:https://secure.mitsubishi-motors.ca/dct/');
	var params = '?lng=' + langid + '&pid=' + pid + '&sourceid=' + sourceid + '&stylesheet=' + stylesheet + '&modelid=' + modelid;
	url += 'BrochureRequest.aspx' + params
	//
	//open the dialog
	//
	open_iframe_dialog(url, width, height);
}

open_testdrive_dialog = function(langid, modelid, modelyear){
	//
	// Dialog dimensions
	//
	var width         = 400;
	var height        = 620;
	if(langid==3)
		height        = 630;

	var test_port = 20041;
	var demo_port = 30041;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		default:
			//This will be behind SSL
			url = "https://secure.mitsubishi-motors.ca/dct/";
	}
	//
	// add querysting parameters 
	//
	if(modelid==undefined)modelid='';
	var params = '?lng=' + langid + '&mmcmodelid=' + modelid + '&myear=' + modelyear;
	url += 'TestDriveRequest.aspx' + params
	//
	//open the dialog
	//
	open_iframe_dialog(url, width, height);
}


open_contactus_dialog = function(langid){
	//
	// Dialog dimensions
	//
	var width         = 650;
	var height        = 640;
	
	var test_port = 20041;
	var demo_port = 30041;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		default:
			//This will be behind SSL
			url = "https://secure.mitsubishi-motors.ca/dct/";
	}
	//
	// add querysting parameters 
	//
	var params = '?lng=' + langid;
	url += 'ContactUs.aspx' + params
	//
	//open the dialog
	//
	open_iframe_dialog(url, width, height);
}


open_sendtoafriend_dialog = function(langid, model){
	//
	// Dialog dimensions
	//
	var width         = 400;
	var height        = 400;
	
	var test_port = 20041;
	var demo_port = 30041;
	//
	//Construct the appropriate url for the given environment.
	//
	var url = "http://";
	var domain = document.domain;
	switch(domain) {
		case 'localhost':
		case 'windshield':
		case 'build':
		case 'staging':
			url += domain + ':' + test_port + '/';
			break;
		case "demo1.dmt.ca":
			url += domain + ':' + demo_port + '/';
			break;
		default:
			//This will be behind SSL
			url = "https://secure.mitsubishi-motors.ca/dct/";
	}
	//
	// add querysting parameters 
	//
	var params = '?lng=' + langid + '&model=' + model;
	url += 'SendToAFriend.aspx' + params;
	//
	//open the dialog
	//
	open_iframe_dialog(url, width, height);
}

