jQuery(window).bind("load resize", function() {
	var bodyW = jQuery('.page');
	var visualW = jQuery('body').width();
	if (visualW > 1000) {
		bodyW.addClass('widescreen');
	} else {
		bodyW.removeClass('widescreen');
	}
});

function mailClose ()
{
	var fade = document.getElementById ( 'fade' );
	var mail = document.getElementById ( 'contact_us_container' );
	fade.style.visibility = 'hidden';
	mail.style.visibility = 'hidden';
}

function showContactUs()
{
	var fade = document.getElementById ( 'fade' );
	var mail = document.getElementById ( 'contact_us_container' );
	fade.style.visibility = 'visible';
	fade.style.opacity = 0.6;
	fade.style.filter = 'alpha(opacity=' + 50 + ')';
	
	mail.style.visibility = 'visible';
	
	$('contact_us_container').innerHTML = 'Loading...';	
	new Ajax.Request ('/contacts/contact_us.php',
		{
			method: 'get',
			encoding: 'utf-8',
			asynchronous: false,
			onSuccess: function(transport) {
				$('contact_us_container').innerHTML = transport.responseText;
			}
		}
		);
}

function showDesignerForSeason(seasonId)
{
        //alert(seasonId);
	jQuery('#container_designer_for_season').html('Loading...');	
	jQuery.ajax({
	    url: '/fashion/designer_list_for_season.php?seasonId='+seasonId,
	    success: function(data) {
		jQuery('#container_designer_for_season').html(data);
	    }
	});
}
function showDesignerForCity(cityId)
{
        //alert(seasonId);
	jQuery('#container_designer_for_city').html('Loading...');	
	jQuery.ajax({
	    url: '/fashion/designer_list_for_city.php?cityId='+cityId,
	    success: function(data) {
		jQuery('#container_designer_for_city').html(data);
	    }
	});
	
}
function showMonthForIssue(issueId) {
        //alert(issueId);
	jQuery('#container_month_for_issue').html('Loading...');	
	jQuery.ajax({
	    url: '/magazine/get_month.php?issueId='+issueId,
	    success: function(data) {
		jQuery('#container_month_for_issue').html(data);
	    }
	});
        
}

function closeMonthForIssue() {
	jQuery('#container_month_for_issue').html('');	
}

function showSimilar(tag) {
	jQuery('#container_similar').html('Loading...');	
	jQuery.ajax({
	    url: '/test/get_list_similar.php?tags='+tag,
	    success: function(data) {
		jQuery('#container_similar').html(data);
	    }
	});
}

function popup(url)
{
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';

 newwin=window.open(url,'windowname4', params);
 if (window.focus) {newwin.focus()}
 return false;
}

function showSlideShow(url)
{
    jQuery('#SlideShowBg').show();
    jQuery('#SlideShowDiv').show();
/*    var wHeight = document.viewport.getHeight();
    var wWidth = document.viewport.getWidth();*/

    var wHeight = jQuery(window).height();
    var wWidth = jQuery(window).width();
//     alert(wWidth+'x'+wHeight);
//    var y = wHeight / 2 - 340;

    var y = wHeight / 2 - 340 + 75;
    y = y < 10 ? 10 : y;
    var x = wWidth / 2 - 460;
    x = x < 10 ? 10 : x;
    jQuery('#SlideShowDiv').css('top', y+'px');
    jQuery('#SlideShowDiv').css('left', x+'px');
    jQuery('#ImagePopup').attr('src',url);
}

function SlideShowClose()
{
    try {
	jQuery('#SlideShowBg').hide();
	jQuery('#SlideShowDiv').hide();
	jQuery('#ImagePopup').attr('src','/images/1.gif');
    } catch(e) {;}
}

function CheckSlideShow4Close()
{
    //alert($('ImagePopup').src);
    var src =jQuery('#ImagePopup').attr('src');
	if(src!==undefined)
    if (src.indexOf("play=close") > 0) 
    {
	SlideShowClose(); 
    }
}

function CheckSlideShowKeyESC()
{
    if (r.keyCode == Event.KEY_ESC) 
    {
	SlideShowClose();
    }

}
function delMessage(id) {
        //alert(id);
	jQuery.ajax({
	    url: '/user/delForumMessage.php?id='+id,
	    success: function(data) {
		jQuery('#container_res_'+id).html(data);
	    }
	});
}
function contraMessage(id, article_id, is_blog) { //="N" EA   Это не работает
        //alert(id);
	jQuery.ajax({
	    url: '/user/complaintForumMessage.php?id='+id+'&article_id='+article_id+'&is_blog='+is_blog,
	    success: function(data) {
		jQuery('#container_res_'+id).html(data);
	    }
	});
}

function addBookmark(article_id) {
	jQuery.ajax({
	       url: '/u/add_bookmark.php?article_id='+article_id,
	       success: function(data) {
		       jQuery('#container_res_bookmark').html(data).slideDown(1000).fadeOut(3000);
	       }
	});
}
function addRoute(shop_id) {
	jQuery.ajax({
	       url: '/special/fno/shops/add_route.php?shop_id='+shop_id,
	       success: function(data) {
		       jQuery('#container_res_route').html(data).slideDown(1000).fadeOut(3000);
	       }
	});
}

