// JavaScript Document

var message='#message';

///////////////////////Start Data View Functions////////////////////////////
function viewBodytype(PAGE){   // lode Body type for dash board
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view-bodytype.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);	
    }
 });
}

//function for view car colors
function viewColor(PAGE){
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view-color.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);	
    }
 });
}

//function for view manufacturer 
function viewManufacturer(PAGE){// lode Body type for dash board
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view-manufacturer.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);	
    }
 });
}

//function for view car model
function viewModel(PAGE){
    //alert(PAGE);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view-model.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

//function for view area
function viewCarType(PAGE){
    //alert(PAGE);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view_type.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

//function for view area
function viewVehicleType(PAGE){
    //alert(PAGE);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view_vehicle_type.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

//viewAds
function viewAds(PAGE){
    //alert(PAGE);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view_ads.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

//viewArticle
function viewArticle(PAGE){
    //alert(PAGE);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view_article.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewFeatureViewContent(PAGE){
    //alert(PAGE);
    //alert("AWA");
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "page="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/view-feature.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

///////////////////////Start Data View Functions////////////////////////////

//////////////////////start edit functions///////////////////////////////////////
function SaveFeatures(id){
    //alert(id);
    var feature_name = document.getElementById('type'+id).value;
   
    dataURL = "id="+id+"&feature_name="+feature_name+"&action="+"Save";
    //alert(dataURL);
    //alert(vehicletype);
    $.ajax({
    type: "POST",
    url: "../_controller/feature_controller.php",
    data: dataURL,
    success: function(msg){
            //alert(msg);
            if(msg=="1")
            {
                $('#old'+id).html(feature_name);
                document.getElementById('old'+id).style.display='';
        		document.getElementById('edit_value'+id).style.display='none';        
        	    document.getElementById('edit_btn'+id).style.display='';
                document.getElementById('save_btn'+id).style.display='none';
                $(message).html("Succesfully Upddated.");
            }
            else
            {
                $(message).html("Update Failed.");
            }
    }
 });
}
function SaveVehicleType(id){
    //alert(id);
    var vehicletype = document.getElementById('type'+id).value;
   
    dataURL = "id="+id+"&vehicletype="+vehicletype+"&action="+"Save";
    //alert(dataURL);
    //alert(vehicletype);
    $.ajax({
    type: "POST",
    url: "../_controller/vehicle_type_controller.php",
    data: dataURL,
    success: function(msg){
            //alert(msg);
            if(msg=="1")
            {
                $('#old'+id).html(vehicletype);
                document.getElementById('old'+id).style.display='';
        		document.getElementById('edit_value'+id).style.display='none';        
        	    document.getElementById('edit_btn'+id).style.display='';
                document.getElementById('save_btn'+id).style.display='none';
                $(message).html("Succesfully Upddated.");
            }
            else
            {
                $(message).html("Update Failed.");
            }
    }
 });
}

function SaveBodyType(id){
    //alert(id);
    var bodyname = document.getElementById('type'+id).value;
   
    dataURL = "id="+id+"&bodyname="+bodyname+"&action="+"Save";
    //alert(dataURL);
    //alert(vehicletype);
    $.ajax({
    type: "POST",
    url: "../_controller/body_type_controller.php",
    data: dataURL,
    success: function(msg){
            //alert(msg);
            if(msg=="1")
            {
                $('#old'+id).html(bodyname);
                document.getElementById('old'+id).style.display='';
        		document.getElementById('edit_value'+id).style.display='none';        
        	    document.getElementById('edit_btn'+id).style.display='';
                document.getElementById('save_btn'+id).style.display='none';
                $(message).html("Succesfully Upddated.");
            }
            else
            {
                $(message).html("Update Failed.");
            }
    }
 });
}

function SaveColor(id){
    //alert(id);
    var color = document.getElementById('type'+id).value;
   
    dataURL = "id="+id+"&color="+color+"&action="+"Save";
    //alert(dataURL);
    //alert(vehicletype);
    $.ajax({
    type: "POST",
    url: "../_controller/color_controller.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
            if(msg=="1")
            {
                $('#old'+id).html(color);
                document.getElementById('old'+id).style.display='';
        		document.getElementById('edit_value'+id).style.display='none';        
        	    document.getElementById('edit_btn'+id).style.display='';
                document.getElementById('save_btn'+id).style.display='none';
                $(message).html("Succesfully Upddated.");
            }
            else
            {
                $(message).html("Update Failed.");
            }
    }
 });
}
function SaveManufacturer(id){

    var brand_name = document.getElementById('type'+id).value;
    dataURL = "id="+id+"&brand_name="+brand_name+"&brand_img="+picFileName+"&action="+"Save";

    $.ajax({
    type: "POST",
    url: "../_controller/manufacturer_controller.php",
    data: dataURL,
    success: function(msg){
            if(msg=="1")
            {
                $('#old'+id).html(brand_name);
				$('#old_img'+id).html('<img  src="../../manufacturer_img/'+picFileName+'" alt="" height="50px" width="50px" />');
                document.getElementById('old'+id).style.display='';
        		document.getElementById('edit_value'+id).style.display='none';  
				
				document.getElementById('old_img'+id).style.display='';
        		document.getElementById('edit_old_img'+id).style.display='none';       
        	    document.getElementById('edit_btn'+id).style.display='';
                document.getElementById('save_btn'+id).style.display='none';
                $(message).html("Succesfully Upddated.");
            }
            else
            {
                $(message).html("Update Failed.");
            }           
    }
 });
}

function SaveCarType(id)
{

    var type = document.getElementById('type'+id).value;
    dataURL = "id="+id+"&type="+type+"&car_typeimg="+picFileName+"&action="+"Save";

    if(type=='')
    {
        $(message).html("Insert missing field.");
    }
    else
    {
        $.ajax({
        type: "POST",
        url: "../_controller/type_controller.php",
        data: dataURL,
        success: function(msg){
                if(msg=="1")
                {
                    $('#old'+id).html(type);
					$('#old_img'+id).html('<img  src="../../type_img/'+picFileName+'" alt="" height="50px" width="50px" />');
                    document.getElementById('old'+id).style.display='';
            		document.getElementById('edit_value'+id).style.display='none'; 
					document.getElementById('old_img'+id).style.display='';
        		    document.getElementById('edit_old_img'+id).style.display='none';          
            	    document.getElementById('edit_btn'+id).style.display='';
                    document.getElementById('save_btn'+id).style.display='none';
                    $(message).html("Succesfully Upddated.");
                }
                else
                {
                    $(message).html("Update Failed.");
                }                        
        }
     });
    }
}

function SaveModel(id){
    //alert(id);
    var model_make_name = document.getElementById('type_make_name'+id).value;
    var model_name = document.getElementById('type_model_name'+id).value;
    dataURL = "id="+id+"&model_make_name="+model_make_name+"&model_name="+model_name+"&action="+"Save";
    //alert(dataURL);
    //alert(vehicletype);
    if(model_make_name=='' || model_name=='')
    {
        $(message).html("Insert missing field.");
    }
    else
    {
        $.ajax({
        type: "POST",
        url: "../_controller/model_controller.php",
        data: dataURL,
        success: function(msg){
            //alert(msg);
                if(msg=="1")
                {
                    $('#oldModelMake'+id).html(model_make_name);
                    $('#oldModel'+id).html(model_name);
                    document.getElementById('oldModelMake'+id).style.display='';
                    document.getElementById('oldModel'+id).style.display='';
            		document.getElementById('edit_value_make_name'+id).style.display='none';
                    document.getElementById('edit_value_model_name'+id).style.display='none';        
            	    document.getElementById('edit_btn'+id).style.display='';
                    document.getElementById('save_btn'+id).style.display='none';
                    $(message).html("Succesfully Upddated.");
                }
                else
                {
                    $(message).html("Update Failed.");
                }                        
        }
     });
    }
}




function saveArticle(id)
{
    //alert("awa");
    $.post("../_controller/article_controller.php",{title:$("#title").val(),description:$("#description").val(),id:id,action:"Save"},function(data){
        
        //alert(data);
        if(data=="1")
        {
            $(message).html("Succesfully Updated.");
            //document.article.reset();
            //alert(data);
            //return true;
        }
        else
        {   
            $(message).html("Update failed.");
            //$("#message").fadeIn(2000);
            //return false;
        }
    });
}
/////////////////////////end edit functions////////////////////////

/////////////////////////start delete functions///////////////////
function deleteFunction_vehicle_type(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result) 
    {
        $.ajax({
        type: "POST",
        url: "../_controller/vehicle_type_controller.php",
        data: "id="+id + "& action="+action,
        success: function(msg){
            	   if(msg=="1")
                   {	 
                        document.getElementById(divid).style.display='none';
                        $(message).html("Deleted");
            	   }
                   else
                   {
                        $(message).html("Delete Failed.");
                   }        	   
            }
    });	
    }
    else
    {
        
    }
      });
}
//deleteFunctionFeatures
function deleteFunctionFeatures(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result) 
    {
        $.ajax({
        type: "POST",
        url: "../_controller/feature_controller.php",
        data: "id="+id + "& action="+action,
        success: function(msg){
            	   if(msg=="1")
                   {	 
                        document.getElementById(divid).style.display='none';
                        $(message).html("Deleted");
            	   }
                   else
                   {
                        $(message).html("Delete Failed.");
                   }        	   
            }
    });	
    }
    else
    {
        
    }
      });
}

function deleteFunction_body_type(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result) 
    {
  		$.ajax({
        type: "POST",
        url: "../_controller/body_type_controller.php",
        data: "id="+id + "& action="+action,
        success: function(msg){
            	   if(msg=="1")
                   {	 
                        document.getElementById(divid).style.display='none';
                        $(message).html("Deleted");
            	   }
                   else
                   {
                        $(message).html("Delete Failed.");
                   }        	   
    
            }
        });	
    }
    else
    {
        
    }
      });
}
    
function deleteFunction_color(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result) 
    {
    		$.ajax({
       type: "POST",
       url: "../_controller/color_controller.php",
       data: "id="+id + "& action="+action,
       success: function(msg){
            	   if(msg=="1")
                   {	 
                        document.getElementById(divid).style.display='none';
                        $("#message").html("Deleted");
            	   }
                   else
                   {
                        $("#message").html("Delete Failed.");
                   }        	   
                }
            });	
    }
    else
    {
        
    }
      });
}
    
function deleteFunction1(divid,action,id,msg)
{
	//alert(divid);
jConfirm(msg , 'Please Confirm', function(result){
if (result) 
{
    $.ajax({
    type: "POST",
    url: "../_controller/manufacturer_controller.php",
    data: "id="+id + "& action="+action,
    success: function(msg){
		//alert(msg);
        	   if(msg=="1")
               {	 //alert("HNDIT");
                    document.getElementById(divid).style.display='none';
                    $("#message").html("Deleted");
        	   }
               else
               {
                    $("#message").html("Delete Failed.");
               }        
			   	   document.getElementById(divid).style.display='none';
            }
        });	
}
else
{
    
}
  });
}
function deleteFunction_model(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result)
    {
            $.ajax({
            type: "POST",
            url: "../_controller/model_controller.php",
            data: "id="+id + "& action="+action,
            success: function(msg){
        	   if(msg=="1")
               {	 
                    document.getElementById(divid).style.display='none';
                    $("#message").html("Deleted");
        	   }
               else
               {
                    $("#message").html("Delete Failed.");
               }     
			   document.getElementById(divid).style.display='none';   	   
           }
        });	
    }
    else
    {
        
    }
    });
}

function deleteFunction_type(divid,action,id,msg)
{	//alert("TYpe");
//alert(divid+" D "+action+" A "+id+" OI "+msg);
    jConfirm(msg , 'Please Confirm', function(result){
    if (result)
    {
            $.ajax({
            type: "POST",
            url: "../_controller/type_controller.php",
            data: "id="+id + "& action="+action,
            success: function(msg){
				//alert(msg);
        	   if(msg=="1")
               {	 
                    
                    $("#message").html("Deleted");
        	   }
               else
               {
                    $("#message").html("Delete Failed.");
               }   
			   document.getElementById(divid).style.display='none';     	   
           }
        });	
    }
    else
    {
    }
    });
}
function deleteFunction_ads(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result)
    {
            $.ajax({
            type: "POST",
            url: "../_controller/ads_controller.php",
            data: "id="+id + "& action="+action,
            success: function(msg){
                //alert(msg);
        	   if(msg=="1")
               {	 
                    document.getElementById(divid).style.display='none';
                    $("#message").html("Deleted");
        	   }
               else
               {
                    $("#message").html("Delete Failed.");
               }        	   
           }
        });	
    }
    else
    {
    }
    });
}

function deleteFunction(divid,action,id,msg)
{
    jConfirm(msg , 'Please Confirm', function(result){
    if (result)
    {
            $.ajax({
            type: "POST",
            url: "../_controller/article_controller.php",
            data: "id="+id + "& action="+action,
            success: function(msg){
                //alert(msg);
        	   if(msg=="1")
               {	 
                    document.getElementById(divid).style.display='none';
                    $("#message").html("Deleted");
        	   }
               else
               {
                    $("#message").html("Delete Failed.");
               }        	   
           }
        });	
    }
    else
    {
    }
    });
}
///////////////////////////end delete functions/////////////////////////

//////////////////////////load add content//////////////////////////////
function viewAdsContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_ads.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewAdsEditContent(PAGE,id){
    //var id= document.getElementById('addsid').value;
    //alert(id);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE+"&id="+id,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/edit_ads.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewAreaContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_area.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewBodytypeContent(PAGE){
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_body_type.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewColorContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_color.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewFeatureContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_features.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewManufacturerContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_manufacturer.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewModelContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_model.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewVehicleTypeContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_vehicle_type.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewTypeContent(PAGE)
{
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_type.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function viewUserContent(PAGE)
{
    //alert("awa");
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_user.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

//viewArticleContent
function viewArticleAddContent(PAGE)
{
    //alert("awa");
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/add_article.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}
//viewArticleEditContent
function viewArticleEditContent(PAGE)
{
    var id = document.getElementById("article_id").value;
    
    //alert(PAGE);
    //alert(id);
    $("#AJAX_LODE_CONTENT").html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "PAGE="+PAGE+"&id="+id,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/edit_article.php",
    data: dataURL,
    success: function(msg){
        //alert(msg);
        $("#AJAX_LODE_CONTENT").html(msg);
    }
 });
}

function loadModel(action,div,id){
    $("#"+div).html("<center><img src='../images/ajax-load.gif' /></center>");
    dataURL = "action="+action+"&id="+id,
    $.ajax({
    type: "POST",
    url: "../ajax-lode/general_ajax_code.php",
    data: dataURL,
    success: function(msg){
        $("#"+div).html(msg);	
    }
 });
}

///////////////////////start new model load//////////////////////////////
function load_model(action,div,id){
	//alert("MF");
    image_path = http_path+"manager/images/ajax-load.gif";
    //alert("Awa Nwe");
    //alert(id);
    $("#"+div).html("<center><img src="+image_path+" /></center>");
    //dataURL = "action="+action+"&id="+id,
    //alert(dataURL);
    $.ajax({
    type: "POST",
    url: http_path+"manager/ajax-lode/general_ajax_code.php",
    data: "action="+action+"&id="+id,
    success: function(msg){
		//alert(msg);
        $("#"+div).html(msg);	
    }
 });
}

function load_model_year1(){
	//alert("MF");
}

function load_model_year(action,div,id){
	//alert("MF");
	var model_name = document.getElementById('ads_car_model').value;
	//alert(model_name);
    image_path = http_path+"manager/images/ajax-load.gif";
    
    //alert(id); 
    $("#"+div).html("<center><img src="+image_path+" /></center>");
    dataURL = "action="+action+"&id="+id+"&model_name="+model_name,
    //alert(dataURL);
    $.ajax({
    type: "POST",
    url: http_path+"manager/ajax-lode/general_ajax_code.php",
    data: dataURL,
    success: function(msg){
        $("#"+div).html(msg);	
    }
 });
}


function load_vehicle_chassi(action,div,id){
	
    image_path = http_path+"manager/images/ajax-load.gif";
    
   // alert(id);
    $("#"+div).html("<center><img src="+image_path+" /></center>");
    dataURL = "action="+action+"&id="+id,
    //alert(dataURL);
    $.ajax({
    type: "POST",
    url: http_path+"manager/ajax-lode/general_ajax_code.php",
    data: dataURL,
    success: function(msg){
        $("#"+div).html(msg);	
    }
 });
}

//muja

function load_vehicle_cc(action,div,id){
	
	var model_id = document.getElementById('ads_car_model').value;
	//alert(model_id);
    image_path = http_path+"manager/images/ajax-load.gif";
    
    $("#"+div).html("<center><img src="+image_path+" /></center>");
    dataURL = "action="+action+"&id="+id+"&model_id="+model_id,
    
    $.ajax({
    type: "POST",
    url: http_path+"manager/ajax-lode/general_ajax_code.php",
    data: dataURL,
    success: function(msg){
        $("#"+div).html(msg);	
    }
 });
}


function load_vehicle_color(action,div,id){
	
	//alert("MF");
	var model_id = document.getElementById('ads_car_model').value;
	var yearfrom = document.getElementById('yearfrom').value;
	var ads_enginefrom = document.getElementById('ads_enginefrom').value;
	//alert(ads_enginefrom+yearfrom+model_id);
    image_path = http_path+"manager/images/ajax-load.gif";
    //alert(image_path);
    $("#"+div).html("<center><img src="+image_path+" /></center>");
    dataURL = "action="+action+"&id="+id+"&model_id="+model_id+"&yearfrom="+yearfrom,
    
    $.ajax({
    type: "POST",
    url: http_path+"manager/ajax-lode/general_ajax_code.php",
    data: dataURL,
    success: function(msg){
		
        $("#"+div).html(msg);	
    }
 });
}


/*function load_vehicle_chassi(action,div,id){

	var model_id = document.getElementById('ads_car_model').value;
	//var yearfrom = document.getElementById('yearfrom').value;
	//var ads_enginefrom = document.getElementById('ads_enginefrom').value;
	//alert(ads_enginefrom+yearfrom+model_id);
    image_path = http_path+"manager/images/ajax-load.gif";
    //alert(image_path);
    $("#"+div).html("<center><img src="+image_path+" /></center>");
    dataURL = "action="+action+"&id="+id+"&model_id="+model_id,
    
    $.ajax({
    type: "POST",
    url: http_path+"manager/ajax-lode/general_ajax_code.php",
    data: dataURL,
    success: function(msg){
		
        $("#"+div).html(msg);	
    }
 });
}*/
/*function load_model_details(value)
{
    var make_name = document.getElementById("ads_car_brand").value;
    alert(value);
    alert(make_name);
    window.location = 'vehicle_brand/auc_vehicle.php?makename='+make_name+'&model='+value;
}*/

function full_search()
{
   
    var make_name = document.getElementById("ads_car_brand").value;
    var model_name = document.getElementById("ads_car_model").value;
    var from_year = document.getElementById("yearfrom").value;
    var to_year = document.getElementById('yearto').value;
	var ads_enginefrom = document.getElementById("ads_enginefrom").value;
	var veh_color = document.getElementById("veh_color").value;
	var d_chassi = document.getElementById('chassis_id').value;
	var page=1;
	//alert(from_year);
	
    //alert("make_name :-"+make_name+"model_name"+model_name+"from_year"+from_year+"ads_enginefrom"+ads_enginefrom);
    
    window.location = "vehicle_brand/advance_auc_vehicle.php?makename="+make_name+'&model='+model_name+'&d_chassi='+d_chassi+'&from_year='+from_year+'&ads_enginefrom='+ads_enginefrom+'&veh_color='+veh_color+'&to_year='+to_year+'&page='+page;
}

//////////////////////////end new model load////////////////////////////

//////////////////////////end load add content//////////////////////

//////////////////////////Data Add Functions////////////////////////
function addArea()
{
        var area = document.getElementById("area").value;
        if(area =='')
        {            
            //alert('here');
            $(message).html('Insert Missing Field/s');            
        }
        else
        {
            //$("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "http://localhost/GandH_WorkS/nikoba/manager/_controller/area_controller.php",
            data: "area="+area,
            success: function(msg)
            {
                 //$("#ajaxloadimg").hide();
            	 $(message).html("Succesfully Added");	 
    	 	     document.getElementById("area").value = "";
            }
   });
        }//end of else
}

function addBodytype()
{
        var bodyname = document.getElementById("bodyname").value;
        //alert(bodyname);
        if(bodyname =='')
        {            
            //alert('here');
            $(message).html('Insert Missing Field');            
        }
        else
        {
            //$("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/body_type_controller.php",
            data: "bodyname="+bodyname+"&action="+"Add",
            success: function(msg)
            {
                if(msg=="1")
                {
                     //alert(msg);
                     //$("#ajaxloadimg").hide();
                	 //$("#message").fadeIn(2000);
                     $(message).html("Succesfully Added.");
                     document.getElementById("bodyname").value = "";
                 }
                 else
                 {
                    $(message).html("Error");
                 }	 
    	 	//document.getElementById("bodyname").value = "";
            }
   });
        }//end of else

}

function addColor()
{
        var color = document.getElementById("colorv").value;
        //alert(color);
        if(color =='')
        {            
            //alert('here');
            $(message).html('Insert Missing Field/s.');            
        }
        else
        {
            $("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/color_controller.php",
            data: "color="+color+"&action="+"Add",
            success: function(msg)
            {//alert(msg);
                if(msg=="1")
                {
                     //alert(msg);
                     //$("#ajaxloadimg").hide();
                	 $(message).html('Succesfully Added.');	 
        	 	     document.getElementById("color").value = "";
                }
                 else
                 {
                    $(message).html("Error");
                 }                                
            }
   });
        }//end of else
}


function addFeature(){
    var feature_name = document.getElementById('feature_name').value;
        if(feature_name =='')
        {            
            $(message).html('Insert Missing Field/s.');            
        }
        else
        {
            $("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/feature_controller.php",
            data: "feature_name="+feature_name+"&action="+"Add",
            success: function(msg)
            {			
                if(msg=="1")
                {
                     //$("#ajaxloadimg").hide();
                	 $(message).html('Succesfully Added.');	 
        	 	     document.getElementById("feature_name").value = "";
                }
                 else
                 {
                    $(message).html("Error");
                 }                                
            }
   });
        }//end of else

}


function addManufacturer()
{
        var brand_name = document.getElementById("brand_name").value;
        //alert(manufacturer);
        if(brand_name =='')
        {            
            //alert('here');
            $(message).html('Insert Missing Field/s.');            
        }
        else
        {
            $("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/manufacturer_controller.php",
            data: "brand_name="+brand_name+"&brand_img="+picFileName+"&action="+"Add",
            success: function(msg)
            {
				
                if(msg=="1")
                {
                     //alert(msg);
                     $(message).html('Succesfully Added.'); 
        	 	     document.getElementById("manufacturer").value = "";
                 }
                 else
                 {
                    $(message).html("Error");
                 }
            }
   });
        }//end of else
}

function addModel()
{
        var model_make_name = document.getElementById("model_make_name").value;
        var model_name = document.getElementById("model_name").value;
        //alert(model_make_name);
        //alert(model_name);
        if(model_make_name =='' || model_name=='')
        {            
            //alert('here');
            $(message).html('Insert Missing Field/s.');            
        }
        else
        {
            //$("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/model_controller.php",
            data: "model_make_name=" +model_make_name +"&model_name="+model_name+"&action="+"Add",
            success: function(msg)
            {
                if(msg=="1")
                {
                     //alert(msg);
                     //$("#ajaxloadimg").hide();
                	 $(message).html("Succesfully Added.");
    	 	         document.getElementById("model_make_name").value = "";
                     document.getElementById("model_name").value = "";                    
                }
                else
                {
                    $(message).html("Error.");
                }	 
            }
   });
        }//end of else
}

function addType()
{       
 
        var type = document.getElementById("typex").value;
		//alert(type);
        if(type =='')
        {
            $(message).html('Insert Missing Field/s.');            
        }
		
        else
        {
            $("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/type_controller.php",
            data: "type=" +type+"&car_typeimg=" +picFileName+"&action="+"Add",
            success: function(msg)
            {   
//alert(msg);
                if(msg=="1")
                {
                	 $(message).html("Succesfully Added.");
        	 	     document.getElementById("type").value = "";
                }
                else
                {
                    $(message).html("Error.");
                }	                  
            }
   });
        }//end of else
}

function addUser(){
//alert("M");
}


function addVehicleType()
{
        var vehicletype = document.getElementById("vehicletype").value;
        //alert(model_make_name);
        //alert(vehicletype);
        if(vehicletype =='')
        {            
            //alert('here');
            $(message).html('Insert Missing Field/s.');            
        }
        else
        {
            //$("#ajaxloadimg").show();
            $.ajax({
            type: "POST",
            url: "../_controller/vehicle_type_controller.php",
            data: "vehicletype=" +vehicletype+"&action="+"Add",
            success: function(msg)
            {
                if(msg=="1")
                {
                     //alert(msg);
                     //$("#ajaxloadimg").hide();
                	 $(message).html("Succesfully Added."); 
        	 	     document.getElementById("vehicletype").value = "";
                }
                else
                {
                    $(message).html("Error.");
                }	                                   
            }
   });
        }//end of else
}

function addAds()
{   
    //alert("Awa");
    //var ads_chassi_id = document.getElementById('ads_chassi_id').value;
    //alert(ads_chassi_id);
    var str = "";
       $("input[name=features]:checked").each(function()
       {
       if(this.value!="on")
        str += this.value+",";
         });
   picFileName_send = picFileName.join(",");
    $.post("../_controller/ads_controller.php",{ads_car_type:$("#ads_car_type").val(),ads_car_brand:$("#ads_car_brand").val(),ads_car_model:$("#ads_car_model").val(),ads_year:$("#ads_year").val(),ads_condition:$("#ads_condition").val(),ads_chassi_id:$("#ads_chassi_id").val(),ads_engine:$("#ads_engine").val(),ads_fuel:$("#ads_fuel").val(),ads_car_seats:$("#ads_car_seats").val(),ads_car_doors:$("#ads_car_doors").val(),ads_ex_color:$("#ads_ex_color").val(),ads_in_color:$("#ads_in_color").val(),ads_passengers:$("#ads_passengers").val(),ads_transmission:$("#ads_transmission").val(),ads_car_comments:$("#ads_car_comments").val(),ads_drive_type:$("#ads_drive_type").val(),features_id:str,ads_images:picFileName_send,ads_rate:$("#ads_rate").val(),ads_milage:$("#ads_milage").val(),ads_status:$("#ads_status").val(),action:"Add"},function(data){
     
     
	       //alert(data);
        if(data=="1")
        {
            //alert(data);
            $(message).html("Succesfully Added."); 
			$(message).fadeOut(5000);
            document.forms["ads"].reset();
            $('#files').hide();
            //document.getElementById('ads_car_type').value = '';

            //form.ads.reset();
			//var fields = Array("ads_car_type","ads_car_brand","ads_car_model","ads_year","ads_condition","ads_engine","ads_fuel","ads_car_seats","ads_car_doors","ads_ex_color","ads_in_color","ads_passengers","ads_transmission","ads_car_comments","ads_drive_type");
//			
//			for($mf=0;$mf<fields.length;$mf++){
//				document.getElementById(fields[$mf]).value = '';
//			
//			}	
			
        }
        else
        {
            $(message).html("Succesfully Added.");
			$(message).fadeOut(5000);
            document.forms["ads"].reset();
            $('#files').hide();

        }
		
		
    });
	
}


function saveAds(id)
{
     var str = "";
       $("input[name=features]:checked").each(function()
       {
       if(this.value!="on")
        str += this.value+",";
         });
			
		var temp_arr = new Array();
		$("#imgs input:hidden").each(function(i){
			if($(this).attr('value')!=''){
				//alert(temp_arr[i]);
				temp_arr[i] = $(this).attr('value');
			}
		});
		//alert("TemP "+temp_arr);
		//if()
		if(temp_arr.length==0){
			//alert(1);
				picFileName_send = picFileName.join(",");
		}
		else if(picFileName.join(",").length!=0 && temp_arr.length!=0)
		{
			//alert(2);
			//alert(temp_arr);
   			
			picFileName_send = picFileName.join(",") +","+temp_arr;
  		}
		else{
			//alert(3);
			//alert("HNDIT "+temp_arr);
			//picFileName_send = temp_arr;
			//alert(picFileName_send);
			
			picFileName_send = temp_arr.join(",");
		
		}
  // alert("picFileName"+picFileName_send);
   
   //alert(picFileName_send);
    $.post("../_controller/ads_controller.php",{ads_car_type:$("#ads_car_type").val(),ads_car_brand:$("#ads_car_brand").val(),ads_car_model:$("#ads_car_model").val(),ads_year:$("#ads_year").val(),ads_condition:$("#ads_condition").val(),ads_chassi_id:$("#ads_chassi_id").val(),ads_engine:$("#ads_engine").val(),ads_fuel:$("#ads_fuel").val(),ads_car_seats:$("#ads_car_seats").val(),ads_car_doors:$("#ads_car_doors").val(),ads_ex_color:$("#ads_ex_color").val(),ads_in_color:$("#ads_in_color").val(),ads_passengers:$("#ads_passengers").val(),ads_transmission:$("#ads_transmission").val(),ads_car_comments:$("#ads_car_comments").val(),ads_drive_type:$("#ads_drive_type").val(),features_id:str,ads_images:picFileName_send,ads_rate:$("#ads_rate").val(),ads_milage:$("#ads_milage").val(),ads_status:$("#ads_status").val(),id:id,action:"Save"},function(data){
		
       // alert(" Ads_imageS "+picFileName_send);
        //alert(data);
        
        if(data=="1")
        {
            $(message).html("Succesfully Updated.");
			$("#message").fadeIn(2000);
            $('#files').hide();
			$('#imgs').hide();
			document.forms["ads"].reset();
			//document.ads.reset();
			
			
        }
        else
        {   
            $(message).html("Succesfully Updated.");
            $("#message").fadeIn(2000);
            //return false;
			
            $('#files').hide();
			$('#imgs').hide();
			document.forms["ads"].reset();
			//document.ads.reset();
        }
    });
}





function addArticle()
{
    //alert('hari');
    $.post("../_controller/article_controller.php",{title:$("#title").val(),description:$("#description").val(),action:"Add"},function(data){
        
        //alert(data);
        
        if(data=="1")
        {
            $("#message").html("Succesfully Updated.");
            document.article.reset();
            //return true;
        }
        else
        {
            $("#message").html("Update Failed.");
            //return false;
        }
    });
}


//////////////////////end add  Functions/////////////////////////

function login2(){
	//alert("here");
	$.post("../_controller/login-controller.php",{username:$('#username').val(),password:$('#password').val()},function data(){
		//alert(data);
		if(data){
		
		}
	
	});
}

function login(){
	var username = document.getElementById('username').value;
	var password = document.getElementById('password').value;
	
	//alert(password);
	$.ajax({
	type: "POST",
	url: "../../muja.php",
	data: "username=" +username+"&password=" +password,
	
	success: function(msg){
			//alert(msg);
		}
	});
}
 
function user_edit(){
	//alert("muja came here");
	//$.().html
	document.getElementById('edit_but').style.display='none';
	document.getElementById('add_but').style.display='';
	
	var span_id  = Array("edit_span","edit_span1","edit_span2","edit_span3","edit_span4","edit_span5","edit_span6","edit_span7");
	
	for(i=0;i<span_id.length;i++){
	 document.getElementById(span_id[i]).style.display='';
	}
	
	var show_id =Array("show_det","show_det1","show_det2","show_det3","show_det4","show_det5","show_det6","show_det7");
	
	for(i=0;i<show_id.length;i++){
	 document.getElementById(show_id[i]).style.display='none';
	}
	

} 
