/* begin Page */

/* Generated with Artisteer version 2.2.0.17376, file checksum is F3E49F6D. */

var s = new Array();
var h = new Array();

function galleryPhoto(DirOfImg) {

    document.getElementById('zoombig').src = DirOfImg;

//    document.images["zoom_big"].src = DirOfImg;
}

function selectProductID(box) {
    if (box.checked) {
        s[s.length] = box.value;
    }
    else {
        for (var i = 0; i < s.length; i++) {
            if (s[i] == box.value)
            { s[i] = ""; }
        }
    }
}

function UpdatePostAdmin() {
    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/UpdatePostAdmin",
        data: $.toJSON({ posts: s }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnUpdatePostAdminUpdated(res.d); }
    });

}

function OnUpdatePostAdminUpdated(result) {
    s.length = 0;
    document.location.href = result;
}

function selectProductHomeID(box) {
    if (box.checked) {
        h[h.length] = box.value;
    }
    else {
        for (var i = 0; i < h.length; i++) {
            if (h[i] == box.value)
            { h[i] = ""; }
        }
    }
}

function UpdatePostHome() {
    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/UpdateHomePost",
        data: $.toJSON({ posts: h }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnUpdatePostHomeUpdated(res.d); }
    });

}

function OnUpdatePostHomeUpdated(result) {
    h.length = 0;
    document.location.href = result;
}

var artEventHelper = {
	'bind': function(obj, evt, fn) {
		if (obj.addEventListener)
			obj.addEventListener(evt, fn, false);
		else if (obj.attachEvent)
			obj.attachEvent('on' + evt, fn);
		else
			obj['on' + evt] = fn;
	}
};

var userAgent = navigator.userAgent.toLowerCase();
var browser = {
	version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
	safari: /webkit/.test(userAgent) && !/chrome/.test(userAgent),
	chrome: /chrome/.test(userAgent),
	opera: /opera/.test(userAgent),
	msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
	mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};

var artLoadEvent = (function() {
	

	var list = [];

	var done = false;
	var ready = function() {
		if (done) return;
		done = true;
		for (var i = 0; i < list.length; i++)
			list[i]();
	};

	if (document.addEventListener && !browser.opera)
		document.addEventListener('DOMContentLoaded', ready, false);

	if (browser.msie && window == top) {
		(function() {
			try {
				document.documentElement.doScroll('left');
			} catch (e) {
				setTimeout(arguments.callee, 10);
				return;
			}
			ready();
		})();
	}

	if (browser.opera) {
		document.addEventListener('DOMContentLoaded', function() {
			for (var i = 0; i < document.styleSheets.length; i++) {
				if (document.styleSheets[i].disabled) {
					setTimeout(arguments.callee, 10);
					return;
				}
			}
			ready();
		}, false);
	}

	if (browser.safari) {
		var numStyles;
		(function() {
			if (document.readyState != 'loaded' && document.readyState != 'complete') {
				setTimeout(arguments.callee, 10);
				return;
			}
			if ('undefined' == typeof numStyles) {
				numStyles = document.getElementsByTagName('style').length;
				var links = document.getElementsByTagName('link');
				for (var i = 0; i < links.length; i++) {
					numStyles += (links[i].getAttribute('rel') == 'stylesheet') ? 1 : 0;
				}
				if (document.styleSheets.length != numStyles) {
					setTimeout(arguments.callee, 0);
					return;
				}
			}
			ready();
		})();
	}

	artEventHelper.bind(window, 'load', ready);

	return ({
		add: function(f) {
			list.push(f);
		}
	})
})();

(function() {
	// fix ie blinking
	var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
	try { if (!!m) { m('BackgroundImageCache', false, true); } }
	catch (oh) { };
})();

function xGetElementsByClassName(clsName, parentEle, tagName) {
	var elements = null;
	var found = [];
	var s = String.fromCharCode(92);
	var re = new RegExp('(?:^|' + s + 's+)' + clsName + '(?:$|' + s + 's+)');
	if (!parentEle) parentEle = document;
	if (!tagName) tagName = '*';
	elements = parentEle.getElementsByTagName(tagName);
	if (elements) {
		for (var i = 0; i < elements.length; ++i) {
			if (elements[i].className.search(re) != -1) {
				found[found.length] = elements[i];
			}
		}
	}
	return found;
}

var styleUrlCached = null;
function GetStyleUrl() {
	if (null == styleUrlCached) {
		var ns;
		styleUrlCached = '';
		ns = document.getElementsByTagName('link');
		for (var i = 0; i < ns.length; i++) {
			var l = ns[i];
			if (l.href && /style\.css(\?.*)?$/.test(l.href)) {
				return styleUrlCached = l.href.replace(/style\.css(\?.*)?$/, '');
			}
		}

		ns = document.getElementsByTagName('style');
		for (var i = 0; i < ns.length; i++) {
			var matches = new RegExp('import\\s+"([^"]+\\/)style\\.css"').exec(ns[i].innerHTML);
			if (null != matches && matches.length > 0)
				return styleUrlCached = matches[1];
		}
	}
	return styleUrlCached;
}

function fixPNG(element) {
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
		var src;
		if (element.tagName == 'IMG') {
			if (/\.png$/.test(element.src)) {
				src = element.src;
				element.src = GetStyleUrl() + 'images/spacer.gif';
			}
		}
		else {
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
			if (src) {
				src = src[1];
				element.runtimeStyle.backgroundImage = 'none';
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "')";
	}
}

function artHasClass(el, cls) {
    return (el && el.className && (' ' + el.className + ' ').indexOf(' ' + cls + ' ') != -1);
}/* end Page */

/* begin Menu */
function Insert_Separators() {
	var menus = xGetElementsByClassName("art-menu", document);
	for (var i = 0; i < menus.length; i++) {
		var menu = menus[i];
		var childs = menu.childNodes;
		var listItems = [];
		for (var j = 0; j < childs.length; j++) {
			var el = childs[j];
			if (String(el.tagName).toLowerCase() == "li") listItems.push(el);
		}
		for (var j = 0; j < listItems.length - 1; j++) {
			var span = document.createElement('span');
			span.className = 'art-menu-separator';
			var li = document.createElement('li');
			li.appendChild(span);
			listItems[j].parentNode.insertBefore(li, listItems[j].nextSibling);
		}
	}
}
artLoadEvent.add(Insert_Separators);

function Menu_IE6Setup() {
	var isIE6 = navigator.userAgent.toLowerCase().indexOf("msie") != -1
    && navigator.userAgent.toLowerCase().indexOf("msie 7") == -1;
	if (!isIE6) return;
	var aTmp2, i, j, oLI, aUL, aA;
	var aTmp = xGetElementsByClassName("art-menu", document, "ul");
	for (i = 0; i < aTmp.length; i++) {
		aTmp2 = aTmp[i].getElementsByTagName("li");
		for (j = 0; j < aTmp2.length; j++) {
			oLI = aTmp2[j];
			aUL = oLI.getElementsByTagName("ul");
			if (aUL && aUL.length) {
				oLI.UL = aUL[0];
				aA = oLI.getElementsByTagName("a");
				if (aA && aA.length)
					oLI.A = aA[0];
				oLI.onmouseenter = function() {
					this.className += " art-menuhover";
					this.UL.className += " art-menuhoverUL";
					if (this.A) this.A.className += " art-menuhoverA";
				};
				oLI.onmouseleave = function() {
					this.className = this.className.replace(/art-menuhover/, "");
					this.UL.className = this.UL.className.replace(/art-menuhoverUL/, "");
					if (this.A) this.A.className = this.A.className.replace(/art-menuhoverA/, "");
				};
			}
		}
	}
}
artLoadEvent.add(Menu_IE6Setup);
/* end Menu */

/* begin Button */
function artButtonsSetupJsHover(className) {
	var tags = ["input", "a", "button"];
	for (var j = 0; j < tags.length; j++){
		var buttons = xGetElementsByClassName(className, document, tags[j]);
		for (var i = 0; i < buttons.length; i++) {
			var button = buttons[i];
			if (!button.tagName || !button.parentNode) return;
			if (!artHasClass(button.parentNode, 'art-button-wrapper')) {
				if (!artHasClass(button, 'art-button')) button.className += ' art-button';
				var wrapper = document.createElement('span');
				wrapper.className = "art-button-wrapper";
				if (artHasClass(button, 'active')) wrapper.className += ' active';
				var spanL = document.createElement('span');
				spanL.className = "l";
				spanL.innerHTML = " ";
				wrapper.appendChild(spanL);
				var spanR = document.createElement('span');
				spanR.className = "r";
				spanR.innerHTML = " ";
				wrapper.appendChild(spanR);
				button.parentNode.insertBefore(wrapper, button);
				wrapper.appendChild(button);
			}
			artEventHelper.bind(button, 'mouseover', function(e) {
				e = e || window.event;
				wrapper = (e.target || e.srcElement).parentNode;
				wrapper.className += " hover";
			});
			artEventHelper.bind(button, 'mouseout', function(e) {
				e = e || window.event;
				button = e.target || e.srcElement;
				wrapper = button.parentNode;
				wrapper.className = wrapper.className.replace(/hover/, "");
				if (!artHasClass(button, 'active')) wrapper.className = wrapper.className.replace(/active/, "");
			});
			artEventHelper.bind(button, 'mousedown', function(e) {
				e = e || window.event;
				button = e.target || e.srcElement;
				wrapper = button.parentNode;
				if (!artHasClass(button, 'active')) wrapper.className += " active";
			});
			artEventHelper.bind(button, 'mouseup', function(e) {
				e = e || window.event;
				button = e.target || e.srcElement;
				wrapper = button.parentNode;
				if (!artHasClass(button, 'active')) wrapper.className = wrapper.className.replace(/active/, "");
			});
		}
	}
}
artLoadEvent.add(function() { artButtonsSetupJsHover("art-button"); });
/* end Button */


function AddPost(city) {
    document.location.href = "../../" + city + "/post/add-post";
}



function showZoomExistUser() {
    openLayer('opac_layer');
    openLayer('opac_existuser');
    dimensionLayer('opac_existuser');
}

function showZoomRecoverOk() {
    openLayer('opac_layer');
    openLayer('opac_recoverok');
    dimensionLayer('opac_recoverok');
}

function showZoomSendMessageOk() {
    openLayer('opac_layer');
    openLayer('opac_sendmessageok');
    dimensionLayer('opac_sendmessageok');
}

function showZoomRecover() {
    openLayer('opac_layer');
    openLayer('opac_recover');
    dimensionLayer('opac_recover');
}

function showZoomSignup() {
    openLayer('opac_layer');
    openLayer('opac_signup');
    dimensionLayer('opac_signup');
}

function showZoomLogin() {
    openLayer('opac_layer');
    openLayer('opac_login');
    dimensionLayer('opac_login');
}

function showZoomAdvise() {
    openLayer('opac_layer');
    openLayer('opac_login_advise');
    dimensionLayer('opac_login_advise');
}

function showZoomSendMail() {
    openLayer('opac_layer');
    openLayer('opac_sendmail');
    dimensionLayer('opac_sendmail');
}

function showZoomAdminSendMail() {
    openLayer('opac_layer');
    openLayer('opac_adminmessage');
    dimensionLayer('opac_adminmessage');
}

function openLayer(name) {
  
    $('#' + name).css("display", "block");
}

function closeLayer(name) {
    $('#' + name).css("display", "none");
}

function dimensionLayer(nLay) {

    $(document).ready(function() {

        $('#opac_layer').css({ left: 0 });
        $('#opac_layer').animate({ opacity: 0.5 }, 0);

        var windowWidth = $(window).width();
        var windowHeight = $(window).height();
        var windowScroolTop = $(window).scrollTop();
        var divWidth = $('#' + nLay).width();
        var divHeight = $('#' + nLay).height();

        var totalWidth = windowWidth / 2 - divWidth / 2;
        var totalHeight = windowHeight / 2 - divHeight / 2 + windowScroolTop;

        $('#' + nLay).css({ 'margin-left': totalWidth });
        $('#' + nLay).css({ 'margin-top': totalHeight });

        $('#opac_layer').width($(document).width());
        $('#opac_layer').height($(document).height());

    });
}



function LoadSearchCombo(idStore) {

    if (idStore != 1333) {
        LoadCity(idStore);
        LoadRubric(idStore);
    }
    else {

        $('#ComboCity').html(unescape("<select disabled style='width:170px;' />"));
        $('#ComboRubric').html(unescape("<select disabled style='width:170px;' />"));
    }
}

function LoadSearchSubRubricCombo(idRubric) {

    if (idRubric != 1555) {
        LoadSubRubric(idRubric);
    }
    else {
        $('#ComboSubRubric').html(unescape("<select disabled style='width:170px;' />"));
    }
}

function LoadCity(idStore) {

    $.ajax({
        type: "POST",
        url: "/Services/WebSearch.asmx/LoadCity",
        data: $.toJSON({ Id: idStore }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnLoadCityUpdated(res.d); }
    });
}

function OnLoadCityUpdated(result) {
    $('#ComboCity').html(unescape(result));
}

function LoadRubric(idStore) {

    $.ajax({
        type: "POST",
        url: "/Services/WebSearch.asmx/LoadRubric",
        data: $.toJSON({ Id: idStore }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnLoadRubricUpdated(res.d); }
    });
}

function OnLoadRubricUpdated(result) {
    $('#ComboRubric').html(unescape(result));
}

function LoadSubRubric(idRubric) {

    $.ajax({
        type: "POST",
        url: "/Services/WebSearch.asmx/LoadSubRubric",
        data: $.toJSON({ Id: idRubric }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnLoadSubRubricUpdated(res.d); }
    });
}

function OnLoadSubRubricUpdated(result) {
    $('#ComboSubRubric').html(unescape(result));
}

function LoadSearsh() {

    $.ajax({
        type: "POST",
        url: "/Services/WebSearch.asmx/LoadSearsh",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) {OnAdviseUpdated(res.d); }
    });

}

function LoadLogIn() {

    $.ajax({
    type: "POST",
    url: "/Services/LoginWb.asmx/LoadLogin",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(res) { OnLogInUpdated(res.d); }
    });

}

function OnAdviseUpdated(result) {
    $('#DivLogin').html(unescape(result));
    document.getElementById('DivLogin').style.display = "block";
    showZoomAdvise();
}

function OnLogInUpdated(result) {
    $('#DivLogin').html(unescape(result));
    document.getElementById('DivLogin').style.display = "block";
    showZoomLogin();
}

function LoadSignup() {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/LoadSignup",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnSignupInUpdated(res.d); }
    });

}

function OnSignupInUpdated(result) {
    $('#DivLogin').html(unescape(result));
    document.getElementById('DivLogin').style.display = "block";
    showZoomSignup();
}


function LoadRecover() {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/LoadRecover",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnRecoverInUpdated(res.d); }
    });

}

function OnRecoverInUpdated(result) {
    $('#DivLogin').html(unescape(result));
    document.getElementById('DivLogin').style.display = "block";
    showZoomRecover();
}

function RecoverUser() {

    var Mail = $('#FormMail').val();

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/RecoverUser",
        data: $.toJSON({ mail: Mail}),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnRecoverUserUpdated(res.d); }
    });

}

function OnRecoverUserUpdated(result) {
    if (result == "NoOk") {

        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/ValidRecoverUser",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { ValidRecoverUserUpdated(res.d); }
        });
    }
    else {
        closeLayer('opac_layer');
        closeLayer('opac_recover');
        $('#DivLogin').html(unescape(result));
        document.getElementById('DivLogin').style.display = "block";
        showZoomRecoverOk();
    }
}

function ValidRecoverUserUpdated(result) {

    $('#validRecover').html(result);

}

var Username;
function LoadUser() {

    Username = $('#FormLogin').val();
    var Password = $('#FormPassword').val();
    
    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/LoadUser",
        data: $.toJSON({ login: Username, password: Password }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnLoadUserInUpdated(res.d); }
    });

}


function OnLoadUserInUpdated(result) {
    if (result == "NoOk") {

        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/ValidUser",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { ValidUserUpdated(res.d); }
        });
    }
    else {
        closeLayer('opac_layer');
        closeLayer('opac_login');
        $('#LoginSetup').html(result);
    }  
}

function ValidUserUpdated(result) {

    $('#validuser').html(result);

}

function onSignOut() {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/onSignOut",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnSignOutUpdated(res.d); }
    });

}

function OnSignOutUpdated(result) {
    document.location.href = result;
}


function LoadLoginHeader() {
    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/LoadLoginHeader",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { LoadLoginHeaderUpdated(res.d); }
    });
}


function LoadLoginHeaderUpdated(result) {

    $('#LoginSetup').html(result);

}

function SendMessegeAdmin() {

    var Username = $('#FormName').val();
    var UserMail = $('#FormMail').val();
    var SendText = $('#txtSendText').val();
    var FormTema = $('#oFormTema').val();
    
    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/ValidateMessage",
        data: $.toJSON({ username: Username, mail: UserMail, text: SendText }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnValidateAdminMessageUpdated(res.d, Username, UserMail,FormTema, SendText); }
    });

}

function OnValidateAdminMessageUpdated(result, Username, UserMail,FormTema, SendText) {

    if (result.toString().length == 0) {
        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/SaveAdminMessage",
            data: $.toJSON({ username: Username, mail: UserMail, text: SendText, IdFormTema: FormTema }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSaveAdminMessageUpdated(res.d); }
        });
    }
    else {

        $('#validMessage').html(unescape(result));
    }
}

function OnSaveAdminMessageUpdated(result) {
    closeLayer('opac_sendmail');
    $('#DivLogin').html(unescape(result));
    showZoomSendMessageOk();
}

function SendMessege() {

    var Username = $('#FormName').val();
    var UserMail = $('#FormMail').val();
    var SendText = $('#txtSendText').val();

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/ValidateMessage",
        data: $.toJSON({ username: Username, mail: UserMail, text: SendText }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnValidateMessageUpdated(res.d, Username, UserMail, SendText); }
    });

}


function OnValidateMessageUpdated(result, Username, UserMail, SendText) {

    if (result.toString().length == 0) {
        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/SaveMessage",
            data: $.toJSON({ username: Username, mail: UserMail, text: SendText, postID: PostID }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSaveMessageUpdated(res.d); }
        });
    }
    else {

        $('#validMessage').html(unescape(result));
    }
}

function OnSaveMessageUpdated(result) {
    closeLayer('opac_sendmail');
    $('#DivLogin').html(unescape(result));
    showZoomSendMessageOk();
}

function SaveUser() {

    Username = $('#SaveLogin').val();
    var Password1 = $('#SavePassword1').val();
    var Password2 = $('#SavePassword2').val();
    var Mail = $('#SaveMail').val();

        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/IfUserExists",
            data: $.toJSON({ login: Username }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnValidateUpdated(res.d, Password1, Password2, Mail); }
        });

}

function OnValidateUpdated(result, Password1, Password2, Mail) {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/IfUserMailExists",
        data: $.toJSON({ mail: Mail }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnValidateUpdatedFin(res.d, result, Password1, Password2, Mail); }
    });

}

function OnValidateUpdatedFin(resultmail, resultuser, Password1, Password2, Mail) {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/Validate",
        data: $.toJSON({ exist: resultuser,existmail:resultmail,login: Username, password1: Password1, password2: Password2, mail: Mail }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnExistsUpdated(res.d, Password1, Mail); }
    });
    
}

function OnExistsUpdated(result,Password1,Mail) {

    if (result.toString().length  == 0) {       
        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/SaveUser",
            data: $.toJSON({ login: Username, password: Password1, mail: Mail }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSaveUserUpdated(res.d); }
        });
   }
   else {

       $('#valid').html(unescape(result));
       document.getElementById('btnLogin').style.display = "block";
   }
}


function OnSaveUserUpdated(result) {
    
    closeLayer('opac_layer');
    closeLayer('opac_signup');
    $('#LoginSetup').html(result);
}


function IsLoginOn() {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/IsLoginOn",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { IsLoginOnUpdated(res.d); }
    });

}

function IsLoginOnUpdated(result) {
    if (!result)
        LoadLogIn();
 }


 var PostID;
 function SendPostMail(_PostID) {

     PostID = _PostID;
     $.ajax({
         type: "POST",
         url: "/Services/LoginWb.asmx/SendPostMail",
         data: "{}",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { OnSendPostMailUpdated(res.d); }
     });

 }

 function OnSendPostMailUpdated(result) {
     $('#DivLogin').html(unescape(result));
     document.getElementById('DivLogin').style.display = "block";
     showZoomSendMail();
 }

 function SendAdminMail() {

     $.ajax({
         type: "POST",
         url: "/Services/LoginWb.asmx/SendAdminMail",
         data: "{}",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { OnSendPostAdminMailUpdated(res.d); }
     });

 }

 function OnSendPostAdminMailUpdated(result) {
     $('#DivLogin').html(unescape(result));
     document.getElementById('DivLogin').style.display = "block";
     showZoomAdminSendMail();
 }


 function DeletePostAdmin(IdPost) {
     $.ajax({
         type: "POST",
         url: "/Services/LoginWb.asmx/DeletePostAdmin",
         data: $.toJSON({ idpost: IdPost }),
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { OnDeletePostAdminUpdated(res.d); }
     });

 }

 function OnDeletePostAdminUpdated(result) {
     document.location.href = result;
 }
 
 function DeletePost(IdPost) {
     $.ajax({
         type: "POST",
         url: "/Services/LoginWb.asmx/DeletePost",
         data: $.toJSON({ idpost: IdPost }),
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { OnDeletePostUpdated(res.d); }
     });

 }

 function GoToFilterResult(root, urlresult) {
     if (urlresult != null)
         window.location.href = root + "?reg=" + urlresult;
 }
 
 function OnDeletePostUpdated(result) {
     document.location.href = result;
 }

 function DeletePostAdmin(IdPost) {
     $.ajax({
         type: "POST",
         url: "/Services/LoginWb.asmx/DeletePostAdmin",
         data: $.toJSON({ idpost: IdPost }),
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { OnDeletePostUpdated(res.d); }
     });

 }


 function LoadTop20Home() {
     $.ajax({
         type: "POST",
         url: "/Services/TopProducts.asmx/Top20Home",
         data: "{}",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { LoadTop20HomeUpdated(res.d); }
     });
 }


 function LoadTop20HomeUpdated(result) {

     $('#Top20Home').html(result);
 }


 function LoadTop20City(Id) {
     $.ajax({
         type: "POST",
         url: "/Services/TopProducts.asmx/Top20City",
         data: $.toJSON({ IdStore: Id }),
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function(res) { LoadTop20CityUpdated(res.d); }
     });
 }


 function LoadTop20CityUpdated(result) {

     $('#Top20City').html(result);
 }

 function PromoBlock(orderInList, OrderPromo, divfin) {
     this.orderInList = orderInList;
     this.OrderPromo = OrderPromo;
     this.divfin = divfin;
 }
 
 var superruperpromobool = true;
 var divpromo = "";
 var arraypromoblock = new Array(24);
 var orderInListPromo, OrderPromoPromo;

 function AddPromoBlock(OrderPromo, postId, orderInList, div) {

     if (superruperpromobool) {
         divpromo = div;
         orderInListPromo = orderInList;
         OrderPromoPromo = OrderPromo;


         var elem = orderInListPromo * 3 - OrderPromoPromo;

         if (arraypromoblock[elem] != null) {
             $('#' + divpromo).html(arraypromoblock[elem].divfin);
         }
         else {

             superruperpromobool = false;
             $('#' + divpromo).html("<div class='loadpromo'><img alt='loading...' src='images/loadingBig.gif'  /><div>");
             $.ajax({
                type: "POST",
                url: "/Services/HomePage.asmx/AddPromoBlock",
                data: $.toJSON({ PostID: postId, orderInList: orderInList}),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(res) { OnPromoBlockUpdated(unescape(res.d)); }
             });
         }

     }

 }

 function OnPromoBlockUpdated(result) {
     if (!superruperpromobool) {
         superruperpromobool = true;
         $('#' + divpromo).html(result);
         var elem = orderInListPromo * 3 - OrderPromoPromo;
         arraypromoblock[elem] = new PromoBlock(orderInListPromo, OrderPromoPromo, result)
     }
 }
 
 
function  checkEmail(email) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email)) {
        return false;
    }
    else
    { 
      return true ;
    }
}

function UpdateUserDate() {
    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/UpdateUserDate",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnUpdateUserDate(res.d); }
    });

}

function OnUpdateUserDate(result) {
    alert(result);
}


function LoadUP(postId) {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/LoadUP",
        data: $.toJSON({ postId: postId }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnLogInUpdated(res.d); }
    });

}


function LoadMessageUp(postId) {

    $.ajax({
        type: "POST",
        url: "/Services/LoginWb.asmx/LoadMessageUp",
        data: $.toJSON({ postId: postId }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnLoadMessageUpUpdated(res.d); }
    });

}


function OnLoadMessageUpUpdated(result) {
    if (result) {
        document.location.href = "../account";
    }
    else {
        $.ajax({
            type: "POST",
            url: "/Services/LoginWb.asmx/MessageUpResult",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnLogInUpdated(res.d); }
        });
    }
}


function setCookie(name, value, expires, path, domain, secure) {
    
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");

}

function getCookie(name) {
    var cookie = " " + document.cookie;
    var search = " " + name + "=";
    var setStr = null;
    var offset = 0;
    var end = 0;
    if (cookie.length > 0) {
        offset = cookie.indexOf(search);
        if (offset != -1) {
            offset += search.length;
            end = cookie.indexOf(";", offset)
            if (end == -1) {
                end = cookie.length;
            }
            setStr = unescape(cookie.substring(offset, end));
        }
    }
    return (setStr);
}


function CheckFavarites(idPost) {

    var ListFave = new Array();
    var liststrt="";
    
    var classname = document.getElementById('Save_' + idPost).className;
    if (classname == "FaveOn") {
        document.getElementById('Save_' + idPost).className = "FaveOf";
        var list = getCookie('SaveFave');

        if (list != null) {
            ListFave = list.split(",");

            for (var i = 0; i < ListFave.length - 1; i++) {
                if (idPost == ListFave[i]) ListFave.splice(i, 1);
            }

            for (var i = 0; i < ListFave.length - 1; i++) {
                liststrt = liststrt + ListFave[i] + ",";
            }

            setCookie('SaveFave', liststrt, "Mon, 01-Jan-2020 00:00:00 GMT", "/");
        }
       
    }
    else {
        
        document.getElementById('Save_' + idPost).className = "FaveOn";
        var list = getCookie('SaveFave');
        if (list != null) {
            ListFave = list.split(",");

            for (var i = 0; i < ListFave.length - 1; i++) {
                if (idPost == ListFave[i]) ListFave.splice(i, 1);
            }

            for (var i = 0; i < ListFave.length - 1; i++) {
                liststrt = liststrt + ListFave[i] + ",";
            }

            liststrt = liststrt + idPost + ",";

            setCookie('SaveFave', liststrt, "Mon, 01-Jan-2020 00:00:00 GMT", "/");

        }
        else {
            liststrt = idPost + ",";
            setCookie('SaveFave', liststrt, "Mon, 01-Jan-2020 00:00:00 GMT", "/");
        }

    }

}

function DeleteCookie() {
    setCookie('SaveFave', null, "", "/", "", "");
}


function LoadFaveMinus(postId) {

    CheckFavaritesPost(postId);
    
    $('#DivFave').html("<img  src='/images/indicator.gif'  />");
    $.ajax({
        type: "POST",
        url: "/Services/TopProducts.asmx/FaveMinus",
        data: $.toJSON({ postId: postId }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnFaveUpdated(res.d); }
    });

}


function LoadFaveAdd(postId) {

    CheckOffFavaritesPost(postId);
    
    $('#DivFave').html("<img  src='/images/indicator.gif'  />");
    $.ajax({
        type: "POST",
        url: "/Services/TopProducts.asmx/LoadFaveAdd",
        data: $.toJSON({ postId: postId }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnFaveUpdated(res.d); }
    });

}

function CheckFavaritesPost(idPost) {

   var ListFave = new Array();
   var liststrt="";
   var list = getCookie('SaveFave');

   if (list != null) {
       ListFave = list.split(",");

       for (var i = 0; i < ListFave.length - 1; i++) {
           if (idPost == ListFave[i]) ListFave.splice(i, 1);
       }

       for (var i = 0; i < ListFave.length - 1; i++) {
           liststrt = liststrt + ListFave[i] + ",";
       }

       liststrt = liststrt + idPost + ",";

       setCookie('SaveFave', liststrt, "Mon, 01-Jan-2020 00:00:00 GMT", "/");

   }
   else {
       liststrt = idPost + ",";
       setCookie('SaveFave', liststrt, "Mon, 01-Jan-2020 00:00:00 GMT", "/");
   }
}

function CheckOffFavaritesPost(idPost) {

   var ListFave = new Array();
   var liststrt="";
   var list = getCookie('SaveFave');

   if (list != null) {
       ListFave = list.split(",");

       for (var i = 0; i < ListFave.length - 1; i++) {
           if (idPost == ListFave[i]) ListFave.splice(i, 1);
       }

       for (var i = 0; i < ListFave.length - 1; i++) {
           liststrt = liststrt + ListFave[i] + ",";
       }

       setCookie('SaveFave', liststrt, "Mon, 01-Jan-2020 00:00:00 GMT", "/");
   }
}

function OnFaveUpdated(result) {

    $('#DivFave').html(result);
}


function AdviceSearch(query, query3, query4, query5, query6) {

  
    if (query.value == '' & query3.value != 1333 & query4.value == 1444 & query5.value == 1555) {
    // на  хом страны
        $.ajax({
            type: "POST",
            url: "/Services/WebSearch.asmx/GoHome",
            data: $.toJSON({ IdStore: query3.value }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSignOutUpdated(res.d); }
        });

        return false;
    }
    else if (query.value == '' & query3.value != 1333 & query4.value != 1444 & query5.value == 1555) {
    // на  хом страны
        $.ajax({
            type: "POST",
            url: "/Services/WebSearch.asmx/GoHome",
            data: $.toJSON({ IdStore: query3.value }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSignOutUpdated(res.d); }
        });

        return false;
    }
    else if (query.value == '' & query3.value != 1333 & query4.value == 1444 & query5.value != 1555 & query6.value == 1655) {
      // на  рубрику
        $.ajax({
            type: "POST",
            url: "/Services/WebSearch.asmx/GoRubric",
            data: $.toJSON({ IdStore: query3.value, IdRubric: query5.value }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSignOutUpdated(res.d); }
        });

        return false;
    }
    else if (query.value == '' & query3.value != 1333 & query4.value != 1444 & query5.value != 1555 & query6.value == 1655) {
    //        // на  рубрику с городом

    $.ajax({
        type: "POST",
        url: "/Services/WebSearch.asmx/GoRubricCity",
        data: $.toJSON({ IdStore: query3.value, IdRubric: query5.value, IdCity: query4.value }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnSignOutUpdated(res.d); }
    });
    
    
        return false;
    }
    else if (query.value == '' & query3.value != 1333 & query4.value == 1444 & query5.value != 1555 & query6.value != 1655) {
        // на  субрубрику
        $.ajax({
            type: "POST",
            url: "/Services/WebSearch.asmx/GoSubRubric",
            data: $.toJSON({ IdStore: query3.value, IdRubric: query5.value, IdSubRubric: query6.value }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(res) { OnSignOutUpdated(res.d); }
        });

        return false;
    }
    else if (query.value == '' & query3.value != 1333 & query4.value != 1444 & query5.value != 1555 & query6.value != 1655) {
//       // на  субрубрику с городом

    $.ajax({
        type: "POST",
        url: "/Services/WebSearch.asmx/GoSubRubricCity",
        data: $.toJSON({ IdStore: query3.value, IdRubric: query5.value, IdCity: query4.value, IdSubRubric: query6.value }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(res) { OnSignOutUpdated(res.d); }
    });
    
        return false;
   }
    
}




function MessageBanOn() {

    $.ajax({
    type: "POST",
    url: "/Services/LoginWb.asmx/MessageBanOn",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(res) { OnMessageBanOnUpdated(res.d); }
    });

}

function OnMessageBanOnUpdated(result) {
    $('#DivLogin').html(unescape(result));
    document.getElementById('DivLogin').style.display = "block";
    showZoomSendMail();
}