$(function(){
$("#tabs").tabs();
$("#tabs1").tabs({collapsible: true});
$("#tabs1").tabs( "select" , 0 );
//$("#tabs2").tabs({collapsible: false});
//$("#tabs2").tabs( "select" , 0 );
$("#obem_from_search").example("От");
$("#obem_to_search").example("До");
$("#price_from_search").example("От");
$("#price_to_search").example("До");
$("#c_name_l").example("Login");
$("#c_pass_l").example("Password");
$('#swfupload-control').swfupload({
upload_url: "/upload-file.php?post_id=" + $('span#post_id').text(),
file_post_name: 'uploadfile',
file_size_limit : "4096",
file_types : "*.jpg;*.png;*.gif",
file_types_description : "Image files",
file_upload_limit : 16,
flash_url : "/js/swfupload/swfupload.swf",
//button_image_url : '/js/swfupload/XPButtonUploadText_61x22.png',
button_image_url : '/js/swfupload/knop2.png',
//button_image_url : '',
button_width : 91,
button_height : 24,
//button_text : 'Добавить фото',
button_placeholder : $('#button')[0],
debug: false})
.bind('fileQueued', function(event, file){
var listitem='
'+
'| Фото: '
+file.name+
' ('+Math.round(file.size/1024)+' KB) '+
''+
' Pending '+
' '+
' | |
';
$('#log').append(listitem);
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
// start the upload since it's queued
$(this).swfupload('startUpload');
})
.bind('fileQueueError', function(event, file, errorCode, message){
alert('Size of the file '+file.name+' is greater than limit');
})
.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
//$('#queuestatus').text('Выбрано файлов: '+numFilesSelected+' / Загружено: '+numFilesQueued);
})
.bind('uploadStart', function(event, file){
$('#log li#'+file.id).find('p.status').text('Загрузка...');
$('#log li#'+file.id).find('span.progressvalue').text('0%');
$('#log li#'+file.id).find('span.cancel').hide();
})
.bind('uploadProgress', function(event, file, bytesLoaded){
//Show Progress
var percentage=Math.round((bytesLoaded/file.size)*100);
$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
})
.bind('uploadSuccess', function(event, file, serverData){
var pathtofile='
';
var item=$('#log li#'+file.id);
item.find('div.progress').css('width', '100%');
item.find('span.progressvalue').text('100%');
item.find('div.p_im').html(pathtofile);
item.addClass('success').find('p.status').html('Файл загружен!');
})
.bind('uploadComplete', function(event, file){
// upload has completed, try the next one in the queue
$(this).swfupload('startUpload');
})
});
// begin add_post functions
(function($){
// очищаем select
$.fn.clearSelect = function() {
return this.each(function(){
if(this.tagName=='SELECT') {
this.options.length = 0;
$(this).attr('disabled','disabled');
}
});
}
// заполняем select
$.fn.fillSelect = function(dataArray) {
return this.clearSelect().each(function(){
if(this.tagName=='SELECT') {
var currentSelect = this;
$.each(dataArray,function(index,data){
var option = new Option(data.text,data.value);
if($.support.cssFloat) {
currentSelect.add(option,null);
} else {
currentSelect.add(option);
}
});
}
});
}
})(jQuery);
$(document).ready(function(){
// выбор года
function adjustYear(){
var proizvValue = $('#proizv').val();
var tmpSelect = $('#year');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
adjustModel();
} else {
$.getJSON('/mods/cascadeSelectYear.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustModel(); });
}
};
function adjustYear_z(){
var proizvValue = $('#proizv_z').val();
var tmpSelect = $('#year_z');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
adjustModel();
} else {
$.getJSON('/mods/cascadeSelectYear.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustModel_z(); });
}
};
function adjustYear_d(){
var proizvValue = $('#proizv_d').val();
var tmpSelect = $('#year_d');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
adjustModel();
} else {
$.getJSON('/mods/cascadeSelectYear.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustModel_d(); });
}
};
function adjustYear_u(){
var proizvValue = $('#proizv_u').val();
var tmpSelect = $('#year_u');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
adjustModel();
} else {
$.getJSON('/mods/cascadeSelectYear.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustModel_u(); });
}
};
// выбор модели
function adjustModel(){
var proizvValue = $('#proizv').val();
var yearValue = $('#year').val();
var tmpSelect = $('#model');
if(proizvValue.length == 0||yearValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel.php',{proizv:proizvValue,year:yearValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_z(){
var proizvValue = $('#proizv_z').val();
var yearValue = $('#year_z').val();
var tmpSelect = $('#model_z');
if(proizvValue.length == 0||yearValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel.php',{proizv:proizvValue,year:yearValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_d(){
var proizvValue = $('#proizv_d').val();
var yearValue = $('#year_d').val();
var tmpSelect = $('#model_d');
if(proizvValue.length == 0||yearValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel.php',{proizv:proizvValue,year:yearValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_u(){
var proizvValue = $('#proizv_u').val();
var yearValue = $('#year_u').val();
var tmpSelect = $('#model_u');
if(proizvValue.length == 0||yearValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel.php',{proizv:proizvValue,year:yearValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_search(){
var proizvValue = $('#proizv_search').val();
var tmpSelect = $('#model_search');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel_search.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_search_z(){
var proizvValue = $('#proizv_search_z').val();
var tmpSelect = $('#model_search_z');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel_search.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_search_d(){
var proizvValue = $('#proizv_search_d').val();
var tmpSelect = $('#model_search_d');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel_search.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
function adjustModel_search_u(){
var proizvValue = $('#proizv_search_u').val();
var tmpSelect = $('#model_search_u');
if(proizvValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
} else {
$.getJSON('/mods/cascadeSelectModel_search.php',{proizv:proizvValue},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); });
}
};
jQuery('.del_model').click(function(event) {
var title_link = jQuery(this).attr('title');
var link = this;
jQuery.ajax({
url: title_link,
type:'POST',
success: function(){
jQuery(link).parent("div").find(".text").text("Saved")
.fadeOut(3000);
}
});
});
$('#proizv').change(function(){adjustYear();}).change();
$('#year').change(adjustModel);
$('#proizv_z').change(function(){adjustYear_z();}).change();
$('#year_z').change(adjustModel_z);
$('#proizv_d').change(function(){adjustYear_d();}).change();
$('#year_d').change(adjustModel_d);
$('#proizv_u').change(function(){adjustYear_u();}).change();
$('#year_u').change(adjustModel_u);
$('#proizv_search').change(adjustModel_search);
$('#proizv_search_z').change(adjustModel_search_z);
$('#proizv_search_d').change(adjustModel_search_d);
$('#proizv_search_u').change(adjustModel_search_u);
var container = $('div.container');
var validator = $("#form").validate({
errorContainer: container,
errorLabelContainer: $("ol", container),
wrapper: 'li',
meta: "validate"
});
var container_m = $('div.container_m');
var validator = $("#form_m").validate({
errorContainer: container_m,
errorLabelContainer: $("ol", container_m),
wrapper: 'li',
meta: "validate"
});
var container_l = $('div.container_l');
var validator = $("#form_l").validate({
errorContainer: container_l,
errorLabelContainer: $("ol", container_l),
wrapper: 'li',
meta: "validate"
});
var container_e = $('div.container_e');
var validator = $("#form_e").validate({
errorContainer: container_e,
errorLabelContainer: $("ol", container_e),
wrapper: 'li',
meta: "validate"
});
var container_d = $('div.container_d');
var validator = $("#form_d").validate({
errorContainer: container_d,
errorLabelContainer: $("ol", container_d),
wrapper: 'li',
meta: "validate"
});
var container_u = $('div.container_u');
var validator = $("#form_u").validate({
errorContainer: container_u,
errorLabelContainer: $("ol", container_u),
wrapper: 'li',
meta: "validate"
});
var container_z = $('div.container_z');
var validator = $("#form_z").validate({
errorContainer: container_z,
errorLabelContainer: $("ol", container_z),
wrapper: 'li',
meta: "validate"
});
/*
$(".cancel").click(function() {
validator.resetForm();
});
*/
});
/*
function search_sort(s){
window.location.href = window.location.pathname + "&sort=" + s ;
};
*/
function insertParam2(key,value)
{
key = escape(key); value = escape(value);
var s = document.location.search;
var kvp = key+"="+value;
var r = new RegExp("(&|\\?)"+key+"=[^\&]*");
s = s.replace(r,"$1"+kvp);
if(!RegExp.$1) {s += (s.length>0 ? '&' : '?') + kvp;};
//again, do what you will here
document.location.search = s;
return s;
}
// end add_post functions
// begin search functions
// end search functions