﻿/// <reference path="jquery-help.js" />
$(document).ready(function() {
var s = "1s4h9o2p6@7s8p0r9i8n7g6s5t4a3r2.1c2o3m4.5u6a7".replace(/\d/g, "");
$("#aEmail").html(s);
$("#aEmail").attr("href","mailto:" + s);
});

function ShowImg(obj, img) {
    $(obj).attr("src", img.src);
    $(obj).attr("width", img.width);
    $(obj).attr("height", img.height);
}

function ChangeImg(obj, src, wrapper) {
	if (wrapper != "")
		$(wrapper).css("height", $(obj).attr("height"));
	$(obj).attr("src", "/img/ajax-loader.gif");
	$(obj).attr("width", "16");
	$(obj).attr("height", "16");
    var img = new Image();
    img.src = src;
    if (!img.complete) {
        $(img).load(function() {
        ShowImg(obj, img);
        if (wrapper != "")
        	$(wrapper).css("height", "");
        });
    }
    else {
    	ShowImg(obj, img);
    	if (wrapper != "")
    		$(wrapper).css("height", "");
    }
}

function CheckDigit(e) {
    if ((e.shiftKey && e.keyCode == 45) || e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
        return false;
    }
}

function ShowDialog(id, obj, divHeight) {
    var w = $("#" + id).width();
    var h = (divHeight == null) ? $("#" + id).height() : divHeight;
    var pos = $(obj).offset();
    var l = (pos.left + w < $(window).width()) ? pos.left + 15 : pos.left - w - 15;
    var t = (pos.top + h < $(window).height()) ? pos.top + 15 : pos.top - h - 15;
    $("#" + id).css({left:l, top:t});
   }

function popup(url, width, height) {
   	var left = (screen.width - width) / 2;
   	var top = (screen.height - height) / 2;
   	var params = 'width=' + width + ', height=' + height;
   	params += ', top=' + top + ', left=' + left;
   	params += ', directories=no';
   	params += ', location=no';
   	params += ', menubar=no';
   	params += ', resizable=no';
   	params += ', scrollbars=no';
   	params += ', status=no';
   	params += ', toolbar=no';
   	newwin = window.open(url, 'windowname5', params);
   	if (window.focus) { newwin.focus() }
   	return false;
   }

   function Ajax(url, data, func) {
   	$.ajax({
   		type: "POST",
   		url: url,
   		data: "{ data : " + $.toJSON(data) + "}",
   		contentType: "application/json; charset=utf-8",
   		dataType: "json",
   		success: func
   	});
   }


////IE Png
try {
document.execCommand("BackgroundImageCache", false, true);
} catch (e) {

}
   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 = "./i/e.gif";
   			}
   		} else {
   			src = element.currentStyle.backgroundImage
					.match(/url\("(.+\.png)"\)/i)
   			if (src) {
   				src = src[1];
   				element.runtimeStyle.backgroundImage = "none";
   			}
   		}

   		var re_scale_mode = /iesizing\-(\w+)/;
   		var m = re_scale_mode.exec(element.className);

   		var scale_mode = (m) ? m[1] : 'crop';

   		if (src)
   			element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
					+ src + "',sizingMethod='" + scale_mode + "')";
   	}
   }

//эмуляция Min-width и max-width для IE6
function minMaxWidth(id) {
	var id_in = id;
	if (navigator.userAgent.toLowerCase().indexOf("msie 6") == -1) return;
	$(document).ready(function() {
	minwidth = parseInt(document.getElementById(id_in).currentStyle['min-width'].replace('px', ''));
	maxwidth = parseInt(document.getElementById(id_in).currentStyle['max-width'].replace('px', ''));
	res();
	 });
	window.attachEvent('onresize', res);
	var minwidth = 0;
	var maxwidth = 0;
	function res() {
	document.getElementById(id_in).style.width =
	document.documentElement.clientWidth - 25 < minwidth ? minwidth + "px" :
	  (document.documentElement.clientWidth - 25 > maxwidth ? maxwidth + "px" : "");
	}

}
minMaxWidth("main_layout");
minMaxWidth("footer");

