/**
 * Author: punctweb.com <mailto:office@punctweb.com>
 * Version: 0.1
 * Started: 08 Sep 2008 21:45
 * 
 * Copyright (c) 2008 punctweb.com All rights reserved
 */

var site_url = 'http://www.dezmembrezmasini.ro/wp-content/themes/dezmembrari/';

function hideShow(hide, show) {
    $(hide).hide();
    $(show).show();
}

function showMessage(block) {
    new Effect.Appear(block, {duration: 1});
    //new Effect.Fade(block, {duration: 1, delay: 10});
}

function hideAuthButton() {
    $('goAuth').hide();
    $('auth-loading').show();
}

function loadLocalities() {
    $('locality').hide();
    
    new Ajax.Updater('locality', site_url + 'ajax/getLocalities.php', {
        method: 'post',
        parameters: { 
            idCounty: $('county').value
        },
        onLoading: function() {
			$('loading_localities').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
			
			$('loading_localities').hide();
            $('locality').show();
		}
    });
}

function loadProfileLocalities() {
    $('prof_locality').hide();
    
    new Ajax.Updater('prof_locality', site_url + 'ajax/getLocalities.php', {
        method: 'post',
        parameters: { 
            idCounty: $('prof_county').value,
			profile: 'yes'
        },
        onLoading: function() {
			$('loading_localities').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
			
			$('loading_localities').hide();
            $('prof_locality').show();
		}
    });
}

function loadRegLocalities() {
    $('reg_locality').hide();
    
    new Ajax.Updater('reg_locality', site_url + 'ajax/getLocalities.php', {
        method: 'post',
        parameters: { 
            idCounty: $('reg_county').value
        },
        onLoading: function() {
			$('loading_localities').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
			
			$('loading_localities').hide();
            $('reg_locality').show();
		}
    });
}

function loadChilds() {
    $('part_1').hide();
    $('level_1_container').hide();
    $('level_2_container').hide();
    
    new Ajax.Updater('part_1', site_url + 'ajax/getParts.php', {
        method: 'post',
        parameters: { 
            idPart: $('part_new').value
        },
        onLoading: function() {
			$('loading_parts').show();
		},
        onComplete: function() {
			$('loading_parts').hide();
            $('level_1_container').show();
            $('part_1').show();
		}
    });
}

function loadChilds_1() {
    new Ajax.Updater('level_2_container', site_url + 'ajax/getParts.php', {
        method: 'post',
        parameters: { 
            level: '1',
            idPart: $('part_1').value
        },
        onLoading: function() {
			$('loading_parts_1').show();
		},
        onComplete: function(transport) {
			$('loading_parts_1').hide();
            
            if(transport.responseText != '') {
                $('level_2_container').show();
            }
		}
    });
}

function loadModels() {
    $('model_new').hide();
    
    new Ajax.Updater('model_new', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('brand_new').value
        },
        onLoading: function() {
			$('loading_models').show();
		},
        onComplete: function() {
			$('loading_models').hide();
            $('model_new').show();
		}
    });
}

function loadModels_cautare() {
    $('model_new').hide();
    
    new Ajax.Updater('model_new', site_url + 'ajax/getModelsCautare.php', {
        method: 'post',
        parameters: { 
            idBrand: $('brand_new').value
        },
        onLoading: function() {
			$('loading_models').show();
		},
        onComplete: function() {
			$('loading_models').hide();
            $('model_new').show();
		}
    });
}

function loadModels2() {
    $('model_new2').hide();
    
    new Ajax.Updater('model_new2', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('brand_new2').value
        },
        onLoading: function() {
			$('loading_models2').show();
		},
        onComplete: function() {
			$('loading_models2').hide();
            $('model_new2').show();
		}
    });
}

function loadModels2_cautare() {
    $('model_new2').hide();
    
    new Ajax.Updater('model_new2', site_url + 'ajax/getModelsCautare.php', {
        method: 'post',
        parameters: { 
            idBrand: $('brand_new2').value
        },
        onLoading: function() {
			$('loading_models2').show();
		},
        onComplete: function() {
			$('loading_models2').hide();
            $('model_new2').show();
		}
    });
}

function loadModels3() {
    $('model_new2').hide();
    
    new Ajax.Updater('model_new3', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('brand_new3').value
        },
        onLoading: function() {
			$('loading_models3').show();
		},
        onComplete: function() {
			$('loading_models3').hide();
            $('model_new3').show();
		}
    });
}

function deleteAd(id) {
    if(confirm('Ai ales sa stergi acest anunt. Continuam ?')) {
        window.location = site_url + 'contul-meu/anunturi-proprii/deletead-' + id;
    }
}

function deleteAdAv(id) {
    if(confirm('Ai ales sa stergi acest anunt. Continuam ?')) {
        window.location = site_url + 'contul-meu/anunturi-avariate/deleteadav-' + id;
    }
}

function deleteAdAnv(id) {
    if(confirm('Ai ales sa stergi acest anunt. Continuam ?')) {
        window.location = site_url + 'contul-meu/anunturi-anvelope/deleteadanv-' + id;
    }
}

function deleteExpAd(id) {
    if(confirm('Ai ales sa stergi acest anunt. Continuam ?')) {
        window.location = site_url + 'contul-meu/expirate/deleteexpad-' + id;
    }
}

function deleteExpAdAv(id) {
    if(confirm('Ai ales sa stergi acest anunt. Continuam ?')) {
        window.location = site_url + 'contul-meu/anunturi-avariate/deleteexpadav-' + id;
    }
}

function deleteExpAdAnv(id) {
    if(confirm('Ai ales sa stergi acest anunt. Continuam ?')) {
        window.location = site_url + 'contul-meu/anunturi-anvelope/deleteexpadanvv-' + id;
    }
}

function mailTo(part_0, part_1) {
    window.location = 'mailto:' + part_0 + '@' + part_1 + '?subject=In legatura cu anuntul de la dezmembrezmasini.ro';
}

function rateAdPositive(id) {
    $('ad_positive').hide();
    
    new Ajax.Updater('ad_positive', site_url + 'ajax/rateAd.php', {
        method: 'post',
        parameters: { 
            idAd: id,
            rate: 'pro'
        },
        onLoading: function() {
			$('loading_ad_rating').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_ad_rating').hide();
            $('ad_positive').show();
		}
    });
}

function rateAdNegative(id) {
    $('ad_negative').hide();
    
    new Ajax.Updater('ad_negative', site_url + 'ajax/rateAd.php', {
        method: 'post',
        parameters: { 
            idAd: id,
            rate: 'cons'
        },
        onLoading: function() {
			$('loading_ad_rating').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_ad_rating').hide();
            $('ad_negative').show();
		}
    });
}

function rateUserPositive(id) {
    $('user_positive').hide();
    
    new Ajax.Updater('user_positive', site_url + 'ajax/rateUser.php', {
        method: 'post',
        parameters: { 
            idUser: id,
            rate: 'pro'
        },
        onLoading: function() {
			$('loading_user_rating').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_user_rating').hide();
            $('user_positive').show();
		}
    });
}

function rateUserNegative(id) {
    $('user_negative').hide();
    
    new Ajax.Updater('user_negative', site_url + 'ajax/rateUser.php', {
        method: 'post',
        parameters: { 
            idUser: id,
            rate: 'cons'
        },
        onLoading: function() {
			$('loading_user_rating').show();
		},
        onComplete: function(transport) {
			/*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_user_rating').hide();
            $('user_negative').show();
		}
    });
}


function deleteContact(id) {
    if(confirm('Ai ales sa stergi acest contact. Continuam ?')) {
        var senddata = new Ajax.Request(site_url + 'ajax/deleteContact.php', 
        { 
            method: 'post', 
            parameters: {idcontact: id},
            onSuccess: function(transport) {
				//var response = transport.responseText || "nici un raspuns";
                //alert(response);
			},
            onComplete: function(transport) {
                new Effect.SlideUp(id, {duration: 0.5});
			}
        });
    }
}

function showParkEvid() {
    if($('parkday').style.display == '') {
        new Effect.Fade('parkday', {duration: 0.5});
    }
    
    if($('parkevid').style.display == 'none') {
        $('fPark').hide();
        new Effect.Appear('parkevid', {duration: 0.5});
    } else {
        new Effect.Fade('parkevid', {duration: 0.5});
        $('fPark').show();
    }
}

function showParkDay() {
    if($('parkevid').style.display == '') {
        new Effect.Fade('parkevid', {duration: 0.5});
    }
    
    if($('parkday').style.display == 'none') {
        $('fPark').hide();
        new Effect.Appear('parkday', {duration: 0.5});
    } else {
        new Effect.Fade('parkday', {duration: 0.5});
        $('fPark').show();
    }
}


function showPayForm(id) {
    window.location = site_url + 'showcontactdata/' + id;
}

function showPayFormAv(id) {
    window.location = site_url + 'showcontactdataav/' + id;
}

function loadSrcModels() {
    $('src-model').hide();
    
    new Ajax.Updater('src-model', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('src-brand').value
        },
        onLoading: function() {
			$('src_loading_models').show();
		},
        onComplete: function() {
			$('src_loading_models').hide();
            $('src-model').show();
		}
    });
}

function loadSrcModelsSimple() {
    $('src-model-simple').hide();
    
    new Ajax.Updater('src-model-simple', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('src-brand-simple').value
        },
        onLoading: function() {
			$('src_loading_models-simple').show();
		},
        onComplete: function() {
			$('src_loading_models-simple').hide();
            $('src-model-simple').show();
		}
    });
}

function loadSrcModelsAvSimple() {
    $('src-model-simple').hide();
    
    new Ajax.Updater('src-model-simple', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('src-brand-simple').value
        },
        onLoading: function() {
            $('src_loading_models-simple').show();
        },
        onComplete: function() {
            $('src_loading_models-simple').hide();
            $('src-model-simple').show();
        },
		insertion: 'bottom'
    });
}

function loadSrcModelsAvAdv() {
    $('src-model-adv').hide();
    
    new Ajax.Updater('src-model-adv', site_url + 'ajax/getModels.php', {
        method: 'post',
        parameters: { 
            idBrand: $('src-brand-adv').value
        },
        onLoading: function() {
            $('src_loading_models-adv').show();
        },
        onComplete: function() {
            $('src_loading_models-adv').hide();
            $('src-model-adv').show();
        },
        insertion: 'bottom'
    });
}

function generateSrcCode() {
    $('src-boxwidth').innerHTML = $('src-box-width').value;
    $('src-boxbgcolor').innerHTML = $('src-box-background').value;
    $('src-boxbordercolor').innerHTML = $('src-box-border').value;
    $('src-boxfontcolor').innerHTML = $('src-box-text').value;
    $('src-boxlinkcolor').innerHTML = $('src-box-link').value;
    
    showMessage("src-success");
}

function generateCode() {
    $('boxwidth').innerHTML = $('box-width').value;
    $('boxbgcolor').innerHTML = $('box-background').value;
    $('boxbordercolor').innerHTML = $('box-border').value;
    $('boxfontcolor').innerHTML = $('box-text').value;
    $('boxlinkcolor').innerHTML = $('box-link').value;
    
    $('count-option').innerHTML = $('count').value;
    
    $('image-option').innerHTML = $('show-image').checked === true ? 'true' : 'false';
    
    showMessage("success");
}

function setMandatoryImage(action) {
    switch(action) {
        case "yes":
            $('image_1').addClassName('required');
            $('image-mandatory').show();
            break;
        case "no":
            $('image_1').removeClassName('required');
            $('image-mandatory').hide();
            break;
    }
}

function deleteImage(image, id) {
    if (confirm('Ai ales sa stergi aceasta imagine. Continuam ?')) {
        var senddata = new Ajax.Request(site_url + 'ajax/deleteImage.php', {
            method: 'post',
            parameters: {
                img: image,
                idad: id
            },
            onSuccess: function(transport){
            //var response = transport.responseText || "nici un raspuns";
            //alert(response);
            },
            onComplete: function(transport){
                //var response = transport.responseText || "nici un raspuns";
                //alert(response);
                window.location.reload(true);
            }
        });
    }
}

function deleteImageAv(image, id) {
    if (confirm('Ai ales sa stergi aceasta imagine. Continuam ?')) {
        var senddata = new Ajax.Request(site_url + 'ajax/deleteImageAv.php', {
            method: 'post',
            parameters: {
                img: image,
                idad: id
            },
            onSuccess: function(transport){
            //var response = transport.responseText || "nici un raspuns";
            //alert(response);
            },
            onComplete: function(transport){
                //var response = transport.responseText || "nici un raspuns";
                //alert(response);
                window.location.reload(true);
            }
        });
    }
}

function deleteImageAnv(image, id) {
    if (confirm('Ai ales sa stergi aceasta imagine. Continuam ?')) {
        var senddata = new Ajax.Request(site_url + 'ajax/deleteImageAnv.php', {
            method: 'post',
            parameters: {
                img: image,
                idad: id
            },
            onSuccess: function(transport){
            //var response = transport.responseText || "nici un raspuns";
            //alert(response);
            },
            onComplete: function(transport){
                //var response = transport.responseText || "nici un raspuns";
                //alert(response);
                window.location.reload(true);
            }
        });
    }
}

function setNewId(new_id, old_id) {
	var senddata = new Ajax.Request(site_url + 'ajax/updatePartCat.php', {
        method: 'post',
        parameters: {
            newid: new_id,
            oldid: old_id
        },
        onSuccess: function(transport){
        //var response = transport.responseText || "nici un raspuns";
        //alert(response);
        },
        onComplete: function(transport){
            var response = transport.responseText || "";
            
			$('new_id_' + old_id).innerHTML = new_id;
            $('new_name_' + old_id).innerHTML = response;
        }
    });
}

function relocate(where) {
    window.location = site_url + where;
}

function relocateAv(where) {
    window.location = site_url_av + where;
}

function relocatePark(where) {
    window.location = where;
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function rateAdAvPositive(id) {
    $('ad_positive').hide();
    
    new Ajax.Updater('ad_positive', site_url + 'ajax/rateAdAv.php', {
        method: 'post',
        parameters: { 
            idAd: id,
            rate: 'pro'
        },
        onLoading: function() {
            $('loading_ad_rating').show();
        },
        onComplete: function(transport) {
            /*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_ad_rating').hide();
            $('ad_positive').show();
        }
    });
}

function rateAdAvNegative(id) {
    $('ad_negative').hide();
    
    new Ajax.Updater('ad_negative', site_url + 'ajax/rateAdAv.php', {
        method: 'post',
        parameters: { 
            idAd: id,
            rate: 'cons'
        },
        onLoading: function() {
            $('loading_ad_rating').show();
        },
        onComplete: function(transport) {
            /*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_ad_rating').hide();
            $('ad_negative').show();
        }
    });
}

function rateAdAnvPositive(id) {
    $('ad_positive').hide();
    
    new Ajax.Updater('ad_positive', site_url + 'ajax/rateAdAnv.php', {
        method: 'post',
        parameters: { 
            idAd: id,
            rate: 'pro'
        },
        onLoading: function() {
            $('loading_ad_rating').show();
        },
        onComplete: function(transport) {
            /*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_ad_rating').hide();
            $('ad_positive').show();
        }
    });
}

function rateAdAnvNegative(id) {
    $('ad_negative').hide();
    
    new Ajax.Updater('ad_negative', site_url + 'ajax/rateAdAnv.php', {
        method: 'post',
        parameters: { 
            idAd: id,
            rate: 'cons'
        },
        onLoading: function() {
            $('loading_ad_rating').show();
        },
        onComplete: function(transport) {
            /*var response = transport.responseText || "nici un raspuns";
            alert(response);*/
            $('loading_ad_rating').hide();
            $('ad_negative').show();
        }
    });
}

function showEvidForm(id) {
	$('ad-evid-' + id).toggle();
}

function showDayForm(id) {
    $('ad-day-' + id).toggle();
}

startList = function() {
	if (document.all && document.getElementById) {
		if(document.getElementById("cssdropdown")) {
		cssdropdownRoot = document.getElementById("cssdropdown");
		
		for (x = 0; x < cssdropdownRoot.childNodes.length; x++) {
			node = cssdropdownRoot.childNodes[x];
			if (node.nodeName == "LI") {
				node.onmouseover = function(){
					this.className += " over";
				}
				node.onmouseout = function(){
					this.className = this.className.replace(" over", "");
				}
			}
		}
		}
	}
}

if (window.attachEvent)
    window.attachEvent("onload", startList)
else
    window.onload=startList;
/* (c)AdOcean 2003-2010 */
if(typeof ado!=="object"){ado={};ado.config=ado.preview=ado.placement=ado.master=ado.slave=function(){};}
ado.config({mode: "old", xml: false, characterEncoding: true});
ado.preview({enabled: true, emiter: "digital4ro.adocean.pl", id: "F1EF.KsS7ZBqo6.68Y3bErO1n.ZK6D.ORD.sVwCP.TD.l7"});

/* (c)AdOcean 2003-2010, MASTER: www.dezmembrezmasini.ro.Content */
ado.master({id: 'bpfm6HYq0fNXEJsmvNSHBvcHov3QkZITapLpxV6fUyf.H7', server: 'digital4ro.adocean.pl' });

function applyRadius(id) {
	var senddata = new Ajax.Request(site_url_anv + 'ajax/setTireFilter.php', {
        method: 'post',
        parameters: {
            filterid: id
        },
        onSuccess: function(transport){
        //var response = transport.responseText || "nici un raspuns";
        //alert(response);
        },
        onComplete: function(transport){
            window.location.reload(true);
        }
    });
}
