/*******************************************************************************
 * CARLIST.MY WEBSITE - MALAYSIA'S #1 CAR CLASSIFIED WEBSITE                   *
 * Version      : 2.0                                                          *
 * Name         : form-car-request.js                                    	   *
 * Description  : This JavaScript file contains UI-related functions for the   *
 *                interface to view all the car requests that belong to a 	   *
 *				  particular user.											   *
 * Written By   : Evylene Ng Yuen Tin                                          *
 * Created On   : 04 January 2009                                              *
 * Modified On  : 04 January 2009                                              *
 *                                                                             *
 * COPYRIGHT NOTICE                                                            *
 * Copyright (C) 2008 - 2009 Auto Discounts Sdn. Bhd. All Rights Reserved.     *
 *                                                                             *
 * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
 * DEALINGS IN THE SOFTWARE.                                                   *
 *******************************************************************************/
var myCarRequests = {
	ready : function() {		
		$("table#my-car-requests tr:even td").css("background-color","#CCC");
		$("table#my-car-requests tr:even td a.delete").addClass("bg-grey-delete");
		$("table#my-car-requests tr:even td a.edit").addClass("bg-grey-edit");
	}
}

var confirmDelete = {
	ready : function() {
		$("#dialog-confirm-deletion").dialog({
			autoOpen: false,
			bgiframe: true,
			resizable: false,
			height: 140,
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			title: "Delete Car Request",
			buttons: {
				'No': function() {					
					$(this).dialog('close');
				},
				'Yes': function() {
					var car_request_id = $("input#car_request_id").val();
					window.location.assign("update-car-request.php?action=Delete&id=" + car_request_id);
				}
			}			
		});
		
		$("a.delete").unbind("click").bind("click", function($e) {
			var car_request_id = $(this).attr("id");
			$("input#car_request_id").val(car_request_id);
			$("#dialog-confirm-deletion").dialog("open");
			$e.preventDefault();
			return false;
		});
	}
}

$(document).ready(myCarRequests.ready);
$(document).ready(confirmDelete.ready);