(function($) {
$.fn.iecorners = function(target, options)
{
	return this.each(function()
	{
    var elm = this;
    var classID = 'ie-corner';
    if (!document.namespaces.v) {
      document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
    }
    elm.className = elm.className.concat(' ', classID);
    var arcSize = Math.min(parseInt(elm.currentStyle['-moz-border-radius'] ||
                                    elm.currentStyle['moz-border-radius'] ||
                                    elm.currentStyle['border-radius']) /
                           Math.min(elm.offsetWidth, elm.offsetHeight), 1);
    var strokeColor = elm.currentStyle.borderColor; var strokeWeight = elm.currentStyle.borderWidth; elm.style.border = 'none';
    var fillColor = elm.currentStyle.backgroundColor; var fillSrc = elm.currentStyle.backgroundImage.replace(/^url\("(.+)"\)$/, '$1'); elm.style.background = 'transparent';
    var margin = elm.currentStyle.margin; elm.style.margin = '0';
    var padding = elm.currentStyle.padding; elm.style.padding = '0';
    var styleFloat = elm.currentStyle.styleFloat; elm.style.styleFloat = 'none';
    var clear = elm.currentStyle.clear; elm.style.clear = 'none';
    var position = elm.currentStyle.position; elm.style.position = 'static';
    var left = elm.currentStyle.left; elm.style.left = '0';
    var right = elm.currentStyle.right; elm.style.right = '0';
    var top = elm.currentStyle.top; elm.style.top = '0';
    var bottom = elm.currentStyle.bottom; elm.style.bottom = '0';
    var width = elm.currentStyle.width; elm.style.width = '100%';
    var height = elm.currentStyle.height; elm.style.height = '100%';

    var oldhtml = elm.outerHTML;
    if (padding)
    {
    	oldhtml = '<div style="padding:' + padding + ';">' + oldhtml + '</div>';
    }
    var html = '<div class="' + classID + '" style="background: transparent; border: none; padding: 0; margin: ' + margin + '; float: ' + styleFloat + '; clear: ' + clear + '; position: ' + position + '; left: ' + left + '; right: ' + right + '; top: ' + top + '; bottom: ' + bottom + '; width: ' + width + '; height: ' + height + ';"><v:roundrect arcsize="' + arcSize + '" strokecolor="' + strokeColor + '" strokeweight="' + strokeWeight + '" style="behavior: url(#default#VML); display: inline-block; width: 99%; height: 99%; antialias: true; padding: ' + strokeWeight + 'px;"><v:fill color="' + fillColor + '" src="' + fillSrc + '" type="tile" style="behavior: url(#default#VML);" />' + oldhtml + '</v:roundrect></div>';
    elm.outerHTML = html;
	});
}
})(jQuery);

$(function()
{
	$('.roundcorners').iecorners();
});

function setRoundRectDiv(id) 
	{
	var obj = document.getElementById(id);	
	
  	if (obj) 
  		{	
    	if (typeof document.namespaces !='undefined' && typeof document.namespaces.v == 'undefined') 
    		{
      		document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
    
		    var arcSize = Math.min(parseInt(obj.currentStyle['-moz-border-radius'] ||
		                                    obj.currentStyle['moz-border-radius'] ||
		                                    obj.currentStyle['border-radius']) /
		                           Math.min(obj.offsetWidth, obj.offsetHeight), 1);
		    var strokeColor = obj.currentStyle.borderColor; var strokeWeight = obj.currentStyle.borderWidth; obj.style.border = 'none';
		    var fillColor = obj.currentStyle.backgroundColor; var fillSrc = obj.currentStyle.backgroundImage.replace(/^url\("(.+)"\)$/, '$1'); obj.style.background = 'transparent';
		    var margin = obj.currentStyle.margin; obj.style.margin = '0';
		    var styleFloat = obj.currentStyle.styleFloat; obj.style.styleFloat = 'none';
		    var clear = obj.currentStyle.clear; obj.style.clear = 'none';
		    var position = obj.currentStyle.position; obj.style.position = 'static';
		    var left = obj.currentStyle.left; obj.style.left = '0';
		    var right = obj.currentStyle.right; obj.style.right = '0';
		    var top = obj.currentStyle.top; obj.style.top = '0';
		    var bottom = obj.currentStyle.bottom; obj.style.bottom = '0';
		    var width = obj.currentStyle.width; obj.style.width = '100%';
		    var height = obj.currentStyle.height; obj.style.height = '100%';
		    
		    obj.outerHTML = '<div style="background: transparent; border: none; padding: 0; margin: ' + margin + '; float: ' + styleFloat + '; clear: ' + clear + '; position: ' + position + '; left: ' + left + '; right: ' + right + '; top: ' + top + '; bottom: ' + bottom + '; width: ' + width + '; height: ' + height + ';"><v:roundrect arcsize="' + arcSize + '" strokecolor="' + strokeColor + '" strokeweight="' + strokeWeight + '" style="behavior: url(#default#VML); display: inline-block; width: 99%; height: 99%; antialias: true; padding: ' + strokeWeight + 'px;"><v:fill color="' + fillColor + '" src="' + fillSrc + '" type="tile" style="behavior: url(#default#VML);" />' + obj.outerHTML + '</v:roundrect></div>';
	        }
  		}
	}
	
function setRoundRectDivByClass(_class) 
	{
	$('.'+_class).each(function(){
	
		obj = this;
		
		if (document.namespaces)
			{
		    if (!document.namespaces.v) {
		      document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
		    }
		}
    	
    	if (obj.currentStyle)
    		{
		    var arcSize = Math.min(parseInt(obj.currentStyle['-moz-border-radius'] ||
		                                    obj.currentStyle['moz-border-radius'] ||
		                                    obj.currentStyle['border-radius']) /
		                           Math.min(obj.offsetWidth, obj.offsetHeight), 1);
		    var strokeColor = obj.currentStyle.borderColor; var strokeWeight = obj.currentStyle.borderWidth; obj.style.border = 'none';
		    var fillColor = obj.currentStyle.backgroundColor; var fillSrc = obj.currentStyle.backgroundImage.replace(/^url\("(.+)"\)$/, '$1'); obj.style.background = 'transparent';
		    var margin = obj.currentStyle.margin; obj.style.margin = '0';
		    var styleFloat = obj.currentStyle.styleFloat; obj.style.styleFloat = 'none';
		    var clear = obj.currentStyle.clear; obj.style.clear = 'none';
		    var position = obj.currentStyle.position; obj.style.position = 'static';
		    var left = obj.currentStyle.left; obj.style.left = '0';
		    var right = obj.currentStyle.right; obj.style.right = '0';
		    var top = obj.currentStyle.top; obj.style.top = '0';
		    var bottom = obj.currentStyle.bottom; obj.style.bottom = '0';
		    var width = obj.currentStyle.width; obj.style.width = '100%';
		    var height = obj.currentStyle.height; obj.style.height = '100%';
		    
		    obj.outerHTML = '<div style="background: transparent; border: none; padding: 0; margin: ' + margin + '; float: ' + styleFloat + '; clear: ' + clear + '; position: ' + position + '; left: ' + left + '; right: ' + right + '; top: ' + top + '; bottom: ' + bottom + '; width: ' + width + '; height: ' + height + ';"><v:roundrect arcsize="' + arcSize + '" strokecolor="' + strokeColor + '" strokeweight="' + strokeWeight + '" style="behavior: url(#default#VML); display: inline-block; width: 99%; height: 99%; antialias: true; padding: ' + strokeWeight + 'px;"><v:fill color="' + fillColor + '" src="' + fillSrc + '" type="tile" style="behavior: url(#default#VML);" />' + obj.outerHTML + '</v:roundrect></div>';
    		}
		});  		
	}	

var show_win = 0;
function showForm(num, contentText)
	{
	if (typeof num == 'undefined') num = 1;
	if (typeof contentText == 'undefined') contentText = '';

 	$.get("/ajax/win/"+num+"/", function(data){ 
		var back = $('<div id="back_win">'); 
		back.css('background', 'black');
		back.css('position', 'absolute');
		back.css('top',0).css('left',0);
		back.width($(document).width());
		back.height($(document).height());
		back.css('z-index',10000);
		back.css('opacity', 0.6);
		back.click(function(){
				closeForm();	
			});
		
		var x = $(window).width()/2 - 964/2;
		var y = $(document).scrollTop()+50;///2 - 594/2;
		

		var win = $('<div id="samo_win">');
		win.css('width',964);		
		win.css('left',x).css('top',y);
		win.css('z-index',10001);
		win.css('position', 'absolute');
		win.html(data);
		
		show_win = 1;

		//$(document.body).css('overflow','hidden');
		$(document.body).append(back);
		$(document.body).append(win);
		
		Cufon.replace('.form_title', { fontFamily: 'RotondaC' });

		$('#comm_form_call').ready(function(){
			$('#comm_form_call').val(contentText);
		})
		
		if ($.browser.msie && $.browser.version=='6.0')
			{
			DD_belatedPNG.fix('.png');
			}
		});
	}

function closeForm()
	{
	$('#back_win').remove();
	$('#samo_win').remove();
	
	show_win = 0;
	
	//$(document.body).css('overflow','auto');
	}	
	
$(document.body).keydown(function(e){
	if (show_win)
		{
		if (e.keyCode == 27)
			{
			closeForm();
			}
		}
})