//--[JG]--Tuesday, February 20, 2007--------------
//----------------------------------------9/5/2008------[JG]

var debug = true;
// Assignment Package
var assignment = {	"Insurance":"" , 
					"AdjusterPhone":"", 
					"Adjuster":"",
					"FindByType":"Insurance",
					"TowYardList":"",
					"RepairShopList":""};
 
assignment.GetInsurance = function(MyCat) {
		assignment.FindByType = 'Insurance';

		var FindType = "Insurance";
		// Set Type
		var FindBy = MyCat;
		var URL;
		// Value passed only when entering by ID 
		var FindText = (arguments[1]) ? arguments[1] : null;

		if (FindText == null)
		{	// get the find Value
			FindText = document.getElementById('Find_Insurance').value;
		}

		if (FindText == '')
		{ return;
		}
		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText;
		
		xh.postResponse(URL,'','assignment.GetInsuranceResponse');

	}


assignment.GetInsuranceResponse = function(myResponse) {
	
		try{
			
			myResponse = unescape(myResponse);
			
			var result = eval(myResponse);
			assignment.Insurance = result;

			var oldInsuranceID = document.getElementById('Original_InsuranceID').value;
				document.getElementById('Original_InsuranceID').value = '';
			var insuranceSelect = document.getElementById('InsuranceID');
				
			var insuranceContent = '';

			insuranceSelect.innerHTML = '';
		
			var option1 =document.createElement('OPTION');
				option1.value = '';
				option1.innerHTML =  result.length +' Insurance(s) Found';
				insuranceSelect.appendChild(option1);
			
			for (i=0;i<result.length;i++) {
				var insuranceCo =  result[i];
				option1 =document.createElement('OPTION');
				option1.value = insuranceCo.InsuranceID;
				option1.innerHTML =  insuranceCo.Company;
				option1.selected = true;
				insuranceSelect.appendChild(option1);
			}
			assignment.GetSetAdjuster();

		}catch(e){if (debug){alert(e);}}

	}


assignment.GetAdjuster = function(MyCat) {
		assignment.FindByType = 'Adjuster';

		var FindType = "Adjuster";
		// Set Type
		var FindBy = MyCat;
		var URL;
		// Value passed only when entering by ID 
		var FindText = (arguments[1]) ? arguments[1] : null;

		if (FindText == null)
		{	// get the find Value
			FindText = document.getElementById('Find_Adjuster').value;
		}

		if (FindText == '')
		{ return;
		}
		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText+'&InsuranceCompanyID='+document.getElementById('InsuranceID').options[document.getElementById('InsuranceID').selectedIndex].value;

		xh.postResponse(URL,'','assignment.GetAdjusterResponse');
	}



assignment.GetAdjusterResponse = function(myResponse) {
	
		try{
			
			myResponse = unescape(myResponse);
			
			var result = eval(myResponse);
			assignment.Adjuster = result;

			var adjusterSelect = document.getElementById('InsContactID');

			adjusterSelect.innerHTML = '';
			
			var option1 =document.createElement('OPTION');
				option1.value = '';
				option1.innerHTML =  result.length +' Adjuster(s) Found';
				adjusterSelect.appendChild(option1);

			adjuster:
			for (i=0;i< assignment.Adjuster.length;i++) {
				var adjusterInfo=  assignment.Adjuster[i];

						option1 =document.createElement('OPTION');
						option1.value = adjusterInfo.InsContactID;
						option1.innerHTML =  adjusterInfo.LastName + ' ' + adjusterInfo.FirstName + ' (' + adjusterInfo.Company + ')';
						adjusterSelect.appendChild(option1);

			}


		}catch(e){if (debug){alert(e);}}

	}




assignment.GetSetAdjuster = function() {
	
		try{

		if (assignment.FindByType = 'Insurance'){

			var oldAdjusterID = document.getElementById('Original_InsContactID').value;
				document.getElementById('Original_InsContactID').value = '';

			var insuranceSelect = document.getElementById('InsuranceID');
		
			var selectedInsuranceID = insuranceSelect.options[insuranceSelect.selectedIndex].value;
			var adjusterSelect = document.getElementById('InsContactID');

			adjusterSelect.innerHTML = '';
			assignment.AdjusterPhone = new Array();
			
			insurance:
			for (i=0;i< assignment.Insurance .length;i++) {
				var insuranceCo =  assignment.Insurance[i];

				if (selectedInsuranceID ==insuranceCo.InsuranceID ){
					
					var option1 =document.createElement('OPTION');
					option1.value = '';
					option1.innerHTML = 'Select Adjuster';
					adjusterSelect.appendChild(option1);
					
					assignment.AdjusterPhone.push('');
					for (j=0;j< insuranceCo.InsContact.length;j++) {
						var adjusterMan = insuranceCo.InsContact[j];

						option1 =document.createElement('OPTION');
						option1.value = adjusterMan.InsContactID;
						option1.innerHTML =  adjusterMan.LastName + ' ' + adjusterMan.FirstName;

						if (oldAdjusterID == adjusterMan.InsContactID){
							option1.selected = true;
						}


						assignment.AdjusterPhone.push(adjusterMan.FullPhone);


						adjusterSelect.appendChild(option1);
					}
					assignment.SyncAdjusterPhone();
					break insurance;
				
				}
				
			}
		} else if (assignment.FindByType = 'Adjuster') {
			// since it was find by adjuster.. the user can just change this.. thats it... it wont trigger anything


		}


		}catch(e){if (debug){alert(e);}}

	}


// Dual Function now
assignment.SyncAdjusterPhone = function(){

		if (assignment.FindByType == 'Insurance'){

			try{
				
				var adjusterSelectIndex = document.getElementById('InsContactID').selectedIndex;

				document.getElementById("InsContact_Phone").innerHTML = 'Phone: '+ assignment.AdjusterPhone[adjusterSelectIndex];

			}catch(e){if (debug){alert(e);}}


		} else if (assignment.FindByType == 'Adjuster') {
		// sync the insurance company here and phone

			var adjusterSelect= document.getElementById('InsContactID')
			var incContactId = adjusterSelect.options[adjusterSelect.selectedIndex].value;

			var currentAdjuster;
	

			adjusterFor:
			for (var i =0;i < assignment.Adjuster.length ; i++){

				currentAdjuster = assignment.Adjuster[i];

				if (incContactId == currentAdjuster.InsContactID){

					document.getElementById("InsContact_Phone").innerHTML = 'Phone: '+ currentAdjuster.FullPhone;
					//adjusterSelect.options[adjusterSelect.selectedIndex].text = currentAdjuster.FirstName + ' ' + currentAdjuster.LastName;
					// now change the insurance Drop Down Box to add current adjusters insurance company

					var insuranceSelect = document.getElementById('InsuranceID');
								
					insuranceSelect.innerHTML = '';
						
					var option1 =document.createElement('OPTION');
						option1.value = currentAdjuster.InsuranceID;
						option1.innerHTML =  currentAdjuster.Company;
						option1.selected = true;
						insuranceSelect.appendChild(option1);


					break;
				}
			}
			// other type
			// Get the Insurance Companies
			// Populate the One On Top then dont change the one on top 
		} else {
		}
}

assignment.copyToInspection = function(){
		try{
			
			var insuredRadio= document.getElementById('AssignmentTypeCodeINS');
			var claimantRadio = document.getElementById('AssignmentTypeCodeCLA');
	
	
			if (!insuredRadio.checked && !claimantRadio.checked) 
			{
				alert("Select Insured or Claimant.");
				return false;
			}

			
			if (insuredRadio.checked) {
				document.getElementById('InspLocAddress').value = document.getElementById('InsuredAddress').value;
				document.getElementById('InspLocCity').value = document.getElementById('InsuredCity').value;
				document.getElementById('InspLocState').value = document.getElementById('InsuredState').value;
				document.getElementById('InspLocZip').value = document.getElementById('InsuredZip').value;
				document.getElementById('InspLocPhone').value = document.getElementById('InsuredPhone').value;
				document.getElementById('InspLocCellPhone').value = document.getElementById('InsuredCellPhone').value;
				document.getElementById('InspLocWorkPhone').value = document.getElementById('InsuredWorkPhone').value;
				document.getElementById('InspLocWorkExt').value = document.getElementById('InsuredWorkExt').value;

			}
			else {
				document.getElementById('InspLocAddress').value = document.getElementById('ClaimantAddress').value;
				document.getElementById('InspLocCity').value = document.getElementById('ClaimantCity').value;
				document.getElementById('InspLocState').value = document.getElementById('ClaimantState').value;
				document.getElementById('InspLocZip').value = document.getElementById('ClaimantZip').value;
				document.getElementById('InspLocPhone').value = document.getElementById('ClaimantPhone').value;
				document.getElementById('InspLocCellPhone').value = document.getElementById('ClaimantCellPhone').value;
				document.getElementById('InspLocWorkPhone').value = document.getElementById('ClaimantWorkPhone').value;
				document.getElementById('InspLocWorkExt').value = document.getElementById('ClaimantWorkExt').value;
			}
		}catch(e){if (debug){alert(e);}}

}

assignment.InspectionLocationCheck = function(myInspLoc) {

	var code = myInspLoc.options[myInspLoc.selectedIndex].value;
	var InspectionLocation_Select = document.getElementById('InspectionLocation_Select');
	var FindText = document.getElementById('InspLocName').value;

	if (code == 'BOD') {

		if (FindText == '')
				return false;

		InspectionLocation_Select.innerHTML = '';

		var FindType = "REPAIRSHOP";
		var FindBy = "COMPANY";
		var URL;
		// Value passed only when entering by ID 


		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText;

		xh2.postResponse(URL,'','assignment.InspectionLocationResponseRepairShop');

	} else if (code == 'SAL') {
		if (FindText == '')
			return false;

		InspectionLocation_Select.innerHTML = '';

		var FindType = "SALVAGETOWYARD";
		var FindBy = "COMPANY";

		var URL;
		// Value passed only when entering by ID 

		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText;
		//alert(URL );

		xh.postResponse(URL,'','assignment.InspectionLocationResponseTowYard');


	} else {
		// clear the Select
		InspectionLocation_Select.innerHTML = '';
		document.forms[0].InspLocName.value=myInspLoc.options[myInspLoc.selectedIndex].text;
	}
}

assignment.InspectionLocationResponseTowYard = function(myResponse) {
	
		try{
			myResponse = unescape(myResponse);
			
			var result = eval(myResponse);

			assignment.TowYardList = result;

			var InspectionLocation_Select = document.getElementById('InspectionLocation_Select');

			var option1 =document.createElement('OPTION');
			option1.value = '';
			option1.innerHTML = assignment.TowYardList.length + ' Tow Yard(s) Found';
			InspectionLocation_Select.appendChild(option1);
				
			for (j=0;j< assignment.TowYardList.length ;j++) {
				var towYard = assignment.TowYardList[j];

				option1 =document.createElement('OPTION');
				option1.value = j;
				option1.innerHTML =  towYard.CompanyName + '/ ' + towYard.City;
				InspectionLocation_Select.appendChild(option1);
			}

		}catch(e){if (debug){alert(e);}}

}

assignment.InspectionLocationResponseRepairShop = function(myResponse) {

	//RepairShopList
		try{
			myResponse = unescape(myResponse);
			
			var result = eval(myResponse);

			assignment.RepairShopList = result;

			var InspectionLocation_Select = document.getElementById('InspectionLocation_Select');

			var option1 =document.createElement('OPTION');
				option1.value = '';
				option1.innerHTML = assignment.RepairShopList.length + ' Body Shop(s) Found';
				InspectionLocation_Select.appendChild(option1);
					
			for (j=0;j< assignment.RepairShopList.length;j++) {
				var bodyShop = assignment.RepairShopList[j];

				option1 =document.createElement('OPTION');
				option1.value = j;
				option1.innerHTML =  bodyShop.CompanyName  + '/ ' + bodyShop.City;;

				InspectionLocation_Select.appendChild(option1);
			}

		}catch(e){if (debug){alert(e);}}
}

assignment.changeInspectionLocationData = function (myLoc){
	
	var myInspLoc = document.getElementById('InspectionLocationCode');
	var code = myInspLoc.options[myInspLoc.selectedIndex].value;
	var shopSelected = myLoc.options[myLoc.selectedIndex].value;

	// if value is zero
	if (shopSelected == '')
		return false;

	try{
		if (code == 'BOD') {
			if (assignment.RepairShopList[shopSelected] ){

				document.getElementById('InspLocName').value =  assignment.RepairShopList[shopSelected].CompanyName;
				document.getElementById('InspLocAddress').value = assignment.RepairShopList[shopSelected].Address;
				document.getElementById('InspLocCity').value = assignment.RepairShopList[shopSelected].City;
				document.getElementById('InspLocState').value = assignment.RepairShopList[shopSelected].State;
				document.getElementById('InspLocZip').value = assignment.RepairShopList[shopSelected].Zip;
				document.getElementById('InspLocWorkPhone').value = assignment.RepairShopList[shopSelected].Phone;
				document.getElementById('InspLocWorkExt').value = '';
//					document.getElementById('InspLocCellPhone').value = RepairShopList[shopSelected].;
//					document.getElementById('InspLocPhone').value = RepairShopList[shopSelected].;
//					document.getElementById('InspLocWorkExt').value = RepairShopList[shopSelected].;
			}
		} else if (code == 'SAL') {
				if (assignment.TowYardList[shopSelected] ){

				document.getElementById('InspLocName').value =  assignment.TowYardList[shopSelected].CompanyName;
				document.getElementById('InspLocAddress').value = assignment.TowYardList[shopSelected].Address;
				document.getElementById('InspLocCity').value = assignment.TowYardList[shopSelected].City;
				document.getElementById('InspLocState').value = assignment.TowYardList[shopSelected].State;
				document.getElementById('InspLocZip').value = assignment.TowYardList[shopSelected].Zip;
				document.getElementById('InspLocWorkPhone').value = assignment.TowYardList[shopSelected].Phone;
				document.getElementById('InspLocWorkExt').value = '';
//					document.getElementById('InspLocPhone').value = TowYardList[shopSelected].;
//					document.getElementById('InspLocWorkPhone').value = TowYardList[shopSelected].;

			}
		} else {
		}
	}catch(e){if (debug){alert(e);}}
}



assignment.FormTypeSelect= function(mySelect){
	var show, hide;
	var selectedValue = mySelect.options[mySelect.selectedIndex].value;


	if (selectedValue == 'Property'){
		show = dom.getByClass(document,'PropertyTypeSpecific');
		hide = dom.getByClass(document,'VehicleTypeSpecific');
	}
	else{

		hide = dom.getByClass(document,'PropertyTypeSpecific');
		show = dom.getByClass(document,'VehicleTypeSpecific');

	}
	/// make Display None
	var temp;
	for (var i = 0; i < show.length; i++ ){
		temp = show[i];
		temp.style.display = 'block';

	}
	// hide 
	for (var i = 0; i < hide.length; i++ ){
		temp = hide[i];
		temp.style.display = 'none';
	}
}
assignment.InsuredClaimantSelect = function(){
		try{
			var insuredClaimantSelect = document.getElementById('AssignmentTypeCode');
			var selectedValue = insuredClaimantSelect.options[insuredClaimantSelect.selectedIndex].value;

			var insuredDiv = document.getElementById('Insured');
			var claimantDiv = document.getElementById('Claimant');

			if (selectedValue == 'INS') {
				insuredDiv.style.display = 'block';
				claimantDiv.style.display = 'none';
			}
			else {
				claimantDiv.style.display = 'block';
				insuredDiv.style.display = 'none';
			}


		}catch(e){if (debug){alert(e);}}
}
assignment.GetAppraiser = function() {
		var FindType = "Appraiser";
		// Set Type

		// try arguement 1 first
		
		var FindBy = (arguments[1]) ? arguments[1] : null;

		if (FindBy == null)
		{
			var findBySelect = document.getElementById('Appraiser_Find_By');
			FindBy  = 	findBySelect.options[findBySelect.selectedIndex].value;

		}
		document.getElementById('Appraiser_Find_By').selectedIndex = 0;

		var URL;
		// Value passed only when entering by ID 
		var FindText = (arguments[0]) ? arguments[0] : null;
		if (FindText == null)
		{	// get the find Value
			FindText = document.getElementById('Find_Appraiser').value;
		}


		if ((FindText == '') || (FindBy == ''))
		{
			return false;
		}


		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText;
		//alert(URL );

		xh2.postResponse(URL,'','assignment.GetAppraiserResponse');
	}

	

assignment.GetAppraiserResponse = function(myResponse) {
		try{
		
			myResponse = unescape(myResponse);
			//alert(myResponse );
			var result = eval(myResponse);

			var oldAppraiserID = document.getElementById('Original_AppraiserID').value;
		

			var AppraiserSelect = document.getElementById('AppraiserID');
				
			AppraiserSelect.innerHTML = '';
		
			var option1 =document.createElement('OPTION');
				option1.value = '';
				option1.innerHTML =  result.length +' Appraiser(s) Found';
				AppraiserSelect.appendChild(option1);
			
			for (i=0;i<result.length;i++) {
				var appraiserMan =  result[i];
				option1 =document.createElement('OPTION');
				option1.value = appraiserMan.AppraiserID;

				option1.innerHTML =  appraiserMan.LastName + ' ' + appraiserMan.FirstName + ' (today=' + appraiserMan.Today + '/open=' + appraiserMan.Open + ')' ;

				if (oldAppraiserID == appraiserMan.AppraiserID)
					option1.selected = true;

				AppraiserSelect.appendChild(option1);
			}
		}catch(e){if (debug){alert(e);}}

	}
	/*
	<select id="Appraiser_Find_By" name="Appraiser_Find_By"  class="SelectSearch" onchange=""/>
									<option value="">Find By</option>
									<option value="zip">Zip</option>
									<option value="city">City</option>
									<option value="county">County</option>
									<option value="name">Name</option>
							</select>
					<input type="text" name="Find_Appraiser" id ="Find_Appraiser" size="9" value="">
					<input type="Button" value="Find" class="SelectSearch"  name="Find" onclick="//assignment.GetInsurance('COMPANY'); return false;" />
					<input type="hidden" name="Original_AppraiserID" id ="Original_AppraiserID" size="15" value="<?=BlankIfNull('AppraiserID'); ?>">
					<input type="hidden" name="Original_InspLocZip" id ="Original_InspLocZip" size="15" value="<?= (IsSet($_SESSION['InspLocZip']))?$_SESSION['InspLocZip']:'' ?>">
					<Select id="AppraiserID" name="AppraiserID" style="width:200px;" onchange=""><option value=""></option></select>
			<img src="/images/blank.gif" alt="" border="0" onload="assignment.GetAppraiser('','<?=BlankIfNull('AppraiserID'); ?>'); ">
*/


assignment.FindCityState = function(){

	try{
		var city,state;
		var FindType = "CityState";
	
		city = document.getElementById('City_Find').value;
		state = document.getElementById('State_Find').value;

		if ((city == '') && (state == ''))
		{
			return false;
		}

		

		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+city+'&FindText='+state;
	//	alert(URL );

		xh2.postResponse(URL,'','assignment.GetCityStateResponse');



	}catch(e){
		if (debug){alert(e);}}
	return false;
}

assignment.GetCityStateResponse = function(myResponse){
	try{
			
			myResponse = unescape(myResponse);
	//		alert(myResponse );
			var result = eval(myResponse);

		
			var AppraiserSelect = document.getElementById('AppraiserCity_Result');
				
			AppraiserSelect.innerHTML = '';
		
			var option1;
			
			for (i=0;i<result.length;i++) {
				var appraiserCity =  result[i];
				option1 =document.createElement('OPTION');
				option1.value =  appraiserCity.City + ', ' + appraiserCity.State;
				option1.innerHTML =  appraiserCity.City + ', ' + appraiserCity.State;
				AppraiserSelect.appendChild(option1);
			}

	}catch(e){if (debug){alert(e);}}
}

var claimEZE = {}



/*---------------------------------------------------------*/
// TNY - TinyMCE Functionality

// TNY: Default Parameters for each Tiny Instance
claimEZE.DefaultTinyParams = {
	debug : false,
	mode : "textareas",
	gecko_spellcheck : true,
	button_tile_map : false,
	plugins : "spellchecker,contextmenu,emotions,paste,devkit,save",
	remove_script_host : false,
	relative_urls : false,
	theme : "advanced",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left"
};

// TNY: SpellChecker for Class SpellCheck
claimEZE.DefaultSpellCheck = {
	debug : false,
	mode : "textareas",
	editor_selector : "SpellCheck",
	gecko_spellcheck : false,
	button_tile_map : false,
	plugins : "spellchecker,paste",
	remove_script_host : false,
	relative_urls : false,
	theme : "advanced",
	theme_advanced_toolbar_location : "bottom",
	theme_advanced_toolbar_align : "right",
	theme_advanced_buttons1 : "pastetext,spellchecker",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : ""
};


// TNY: Create instance of TinyMCE Editor
//  @Element/ElementID
claimEZE.CreateEditor = function(MyID) {
	
	if(tinyMCE == null) {
		alert('Error: Editor not set');
		return;
	} else if(dom.$(MyID) == null) {
		alert('Error: Cannot find element to edit');
		return;
	}

	var TinyParams = this.DefaultTinyParams;

	if((arguments[1] != null) && (arguments[1] == 'Small')) {
		TinyParams.save_onsavecallback = 'rblg.DestroyEditor';
		TinyParams.theme_advanced_buttons1 = "bold,italic,forecolor,|,link,unlink";
		TinyParams.theme_advanced_buttons2 = "fontsizeselect,spellchecker";
		TinyParams.theme_advanced_buttons3 = "";
		TinyParams.file_browser_callback = "";
	} else if((arguments[1] != null) && (arguments[1] == 'SmallImg')) {
		TinyParams.save_onsavecallback = 'rblg.DestroyEditor';
		TinyParams.theme_advanced_buttons1 = "bold,italic,forecolor,|,link,unlink,image";
		TinyParams.theme_advanced_buttons2 = "fontsizeselect,spellchecker";
		TinyParams.theme_advanced_buttons3 = "";
		TinyParams.file_browser_callback = "";
	} else {
		TinyParams.theme_advanced_buttons1 = "bold,italic,underline,strikethrough,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifyright,justifycenter,justifyfull,|,forecolor,backcolor,|,link,unlink";
		TinyParams.theme_advanced_buttons2 = "cut,copy,paste,pastetext,pasteword,|,fontselect,fontsizeselect,|,spellchecker,|,image,emotions";
		//TinyParams.theme_advanced_buttons1 = "bold,italic,underline,strikethrough,|,undo,redo,|,bullist,numlist,|,outdent,indent,|,justifyleft,justifyright,justifycenter,justifyfull,|,forecolor,backcolor,|,link,unlink,image,emotions";
		//TinyParams.theme_advanced_buttons2 = "cut,copy,paste,pastetext,pasteword,|,styleselect,formatselect,fontselect,fontsizeselect,|,spellchecker";
		TinyParams.theme_advanced_buttons3 = "";
	}

	TinyParams.file_browser_callback = "rblg.FileBrowser";

	tinyMCE.init(TinyParams);
	tinyMCE.execCommand('mceAddControl', true, MyID);
}

// TNY: Destroy one instance of TinyMCE Editor
//  @EditorInstance
claimEZE.DestroyEditor = function(Editor) {
	tinyMCE.triggerSave();
	tinyMCE.execCommand('mceRemoveControl', true, (typeof Editor == 'string') ? Editor : Editor.formTargetElementId);
}

// TNY: Destroy all TinyMCE Editor Instances
claimEZE.DestroyAllEditors = function() {
	for(var i in tinyMCE.instances)
		if(typeof tinyMCE.instances[i] != 'function')
			rblg.DestroyEditor(tinyMCE.instances[i]);
}

// TNY: Custom TinyMCE File Browser Window
claimEZE.FileBrowser = function(FieldName, URL, Type, Win) {
	if((Type == 'image') || (Type == 'thumb') || (Type == 'album')) {
		tinyMCE.openWindow({
			file : '/_blog.image.browser/?BlogID=' + blog.BlogID + '&Type=' + Type,
			title : 'Image Browser',
			width : 640,
			height : 480,
			close_previous : 'no'
			},{
			window : Win,
			input : FieldName,
			resizable : "yes",
			inline : "yes"
		});
	}
	return(false);
}


//--[JG]--Monday, February 26, 2007--------------
// Appraisal js Functions
//-----------------------------------------------
assignment.GetRepairShop = function() {
		var FindType = "REPAIRSHOP";
		// Set Type

		// try arguement 1 first
		
		var FindBy = (arguments[1]) ? arguments[1] : null;

		if (FindBy == null)
		{
			var findBySelect = document.getElementById('Repairshop_Find_By');
			FindBy  = 	findBySelect.options[findBySelect.selectedIndex].value;

		}
		document.getElementById('Repairshop_Find_By').selectedIndex = 0;

		var URL;
		// Value passed only when entering by ID 
		var FindText = (arguments[0]) ? arguments[0] : null;

		if (FindText == null)
		{	// get the find Value
			FindText = document.getElementById('Find_RepairShop').value;
		}



		if ((FindText == '') || (FindBy == ''))
		{
			return false;
		}
		
		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText;

		xh2.postResponse(URL,'','assignment.GetRepairShopResponse');
	}

//-----Updated to add Blank---------------9/5/2008------[JG]	
assignment.GetRepairShopResponse = function(myResponse) {
		try{
		
			myResponse = unescape(myResponse);
			//alert(myResponse );
			var result = eval(myResponse);

			var oldID = document.getElementById('Original_RepairShopID').value;
		

			var selectInput = document.getElementById('RepairShopID');
				
			selectInput.innerHTML = '';

			var option0 =document.createElement('OPTION');
			option0.value = '0';
			option0.innerHTML =  '';
			selectInput.appendChild(option0);

		if (result.length>0) {
			var option1 =document.createElement('OPTION');
				option1.value = '';
				option1.innerHTML =  result.length +' Repair Shops(s) Found';
				selectInput.appendChild(option1);
		}			
			
			var option2 =document.createElement('OPTION');
				option2.value = '';
				option2.innerHTML =  'Add a new Repair Facility';
				selectInput.appendChild(option2);



			for (i=0;i<result.length;i++) {
				var dataElement =  result[i];
				option1 =document.createElement('OPTION');
				option1.value = dataElement.RepairShopID;

				option1.innerHTML =  dataElement.CompanyName + '/' + dataElement.City ;

				if (oldID == dataElement.RepairShopID)
					option1.selected = true;

				selectInput.appendChild(option1);
			}
		}catch(e){if (debug){alert(e);}}

	}

assignment.GetSalvageTowYard = function() {
		var FindType = "SALVAGETOWYARD";
		// Set Type

		// try arguement 1 first
		
		var FindBy = (arguments[1]) ? arguments[1] : null;

		if (FindBy == null)
		{
			var findBySelect = document.getElementById('SalvageTowYard_Find_By');
			FindBy  = 	findBySelect.options[findBySelect.selectedIndex].value;

		}
		document.getElementById('SalvageTowYard_Find_By').selectedIndex = 0;

		var URL;
		// Value passed only when entering by ID 
		var FindText = (arguments[0]) ? arguments[0] : null;
		if (FindText == null)
		{	// get the find Value
			FindText = document.getElementById('Find_SalvageTowYard').value;
		}
		if ((FindText == '') || (FindBy == ''))
		{
			return false;
		}

		URL = '?IDX=ATS.assignment.datagrab&Type=' +FindType+ '&FindBy='+FindBy+'&FindText='+FindText;
		//alert(URL );

		xh.postResponse(URL,'','assignment.GetSalvageTowYardResponse');
	}

	

assignment.GetSalvageTowYardResponse = function(myResponse) {
		try{
		
			myResponse = unescape(myResponse);
			//alert(myResponse );
			var result = eval(myResponse);

			var oldID = document.getElementById('Original_SalvageTowYardID').value;
		

			var selectInput = document.getElementById('SalvageTowYardID');
				
			selectInput.innerHTML = '';

			if (result.length>0) {
				var option1 =document.createElement('OPTION');
					option1.value = '';
					option1.innerHTML =  result.length +' Salvage/Tow Yard(s) Found';
					selectInput.appendChild(option1);
			}	


			var option2 =document.createElement('OPTION');
				option2.value = '';
				option2.innerHTML =  'Add a new Salvage/Tow Yard';
				selectInput.appendChild(option2);
		
			for (i=0;i<result.length;i++) {
				var dataElement =  result[i];
				option1 =document.createElement('OPTION');
				option1.value = dataElement.SalvageTowYardID;

				option1.innerHTML =  dataElement.CompanyName + '/' + dataElement.City ;

				if (oldID == dataElement.SalvageTowYardID)
					option1.selected = true;

				selectInput.appendChild(option1);
			}
		}catch(e){if (debug){alert(e);}}

	}
	


claimEZE.OpenNewWindow = function(link){
	NewWindow = window.open(link,'EstWindow', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0,width=900, height=800');
 
}

//--[JG]--Monday, February 26, 2007--------------
// json submit to /
claimEZE.PostSubmit = function (elements) {
	var form = document.createElement('form');

	for (var x in elements){
		var e = document.createElement('input');
		e.setAttribute('type', 'hidden');
		e.setAttribute('name', x);
		e.setAttribute('value', elements[x]);
		form.appendChild(e);
	}

	form.method = 'post';
	form.action = '/';
	document.body.appendChild(form);
	form.submit();
}


var cnt = 0;
