﻿function openPopup(url, w, h) {
	$("#popupwnd_content iframe").attr("src", url);
	$("#popupwnd_content").css({ "width": w, "height": h });

	var popup = $("#popupwnd");
	popup.css({ "left": $(document).width() / 2 - popup.width() / 2, "top": Math.max($(window).height() / 2 - popup.height() / 2, 0) + $(window).scrollTop() });

	$("#popupbg").show();
	$("#popupwnd").show();
}

function openOrderPolis(ResultId) {
	openPopupNew('/kasko/oformlenie-zakaza/?resultId=' + ResultId, 581, 390);
   }

function openOrderOsagoPolis(companyId, osagoParams, price) {
	openPopupNew('/osago/oformlenie-zakaza/?' + 'companyId=' + companyId + '&' + 'osagoParams=' + osagoParams + '&' + 'price=' + price, 581, 390);
   }

function openPopupNew(url, width, height) {
	$(".popup-content iframe").attr("src", url);
	$(".popup-content").css({ "width": width, "height": height });

	var popup = $(".popup-window");
	popup.css({ "left": $(document).width() / 2 - popup.width() / 2, "top": Math.max($(window).height() / 2 - popup.height() / 2, 0) + $(window).scrollTop() });

	$(".popup-window").show();
	$(".popup-background").show();
}

function openAuthPopup(targetUrl) {
	openPopup('/Pages/Popup/Login.aspx?TargetUrl=' + targetUrl, 720, 525);
}

function openAddCommentPopup(targetUrl, reviewObjectTypeId, reviewObjectId, currentLocation) {
	openPopup('/Pages/Popup/AddComment.aspx?TargetUrl=' + targetUrl +
	'&ReviewObjectTypeId=' + reviewObjectTypeId +
	'&ReviewObjectId=' + reviewObjectId	+
	'&CurrentLocation=' + currentLocation	
	, 720, 525);
}

function openAddReviewPopup(targetUrl, reviewObjectTypeId, reviewObjectId, companyName, currentLocation) {
	openPopup('/Pages/Popup/AddReview.aspx?TargetUrl=' + targetUrl +
	'&ReviewObjectTypeId=' + reviewObjectTypeId +
	'&ReviewObjectId=' + reviewObjectId +
	'&CompanyName=' + companyName +
	'&CurrentLocation=' + currentLocation	
	, 720, 605);
}

function openAddReplyPopup(targetUrl, reviewId, mode, id) {
	openPopup('/Pages/Popup/AddReply.aspx?TargetUrl=' + targetUrl +
	'&ReviewId=' + reviewId + '&mode=' + mode + '&Id=' + id
	, 720, 450);
}

function openAddUserReplyPopup(targetUrl, reviewId, mode, id) {
	openPopup('/Pages/Popup/AddUserReply.aspx?TargetUrl=' + targetUrl +
	'&ReviewId=' + reviewId + '&mode=' + mode + '&Id=' + id
	, 720, 570);
}

function openComplaintPopup(reviewId, reviewObjectTypeId, companyName) {
	openPopup('/Pages/Popup/Сomplaint.aspx?ReviewId=' + reviewId +
	'&ReviewObjectTypeId=' + reviewObjectTypeId +
	'&CompanyName=' + companyName
	, 720, 450);
}

function closePopup() {
	$("#popupbg").hide();
	$("#popupwnd").hide();
	return false;
}

