﻿// JScript File

function OpenWindowCentered(urlString) {
//alert("sadgv");
WindowOpenHelper(urlString, 'Mortgage', 'width=400,height=300,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbars=no', true);
}

function OpenPolicyWindowCentered(urlString) {   
    WindowOpenHelper(urlString, 'PrivacyPolicy', 'width=779,height=400,location=no,menubar=no,resizable=no,scrollbars=yes,status=yes,toolbars=no', true);
}

function OpenSampleLeadsCentered(urlString) {
    
    WindowOpenHelper(urlString, 'Leads', 'width=700,height=300,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbars=no', true);
}

    function GetScreenWidth() {
	return window.screen.availWidth;
}

function GetScreenHeight() {
	return window.screen.availHeight;
}

// BEGIN - Attribute helper
function GetAttributeValue(attribList, attribName, firstDelim, secondDelim) {
	var attribNameLowerCase = attribName.toLowerCase();
	if (attribList) {
		var attribArr = attribList.split(firstDelim);
		for (var i = 0, loopCnt = attribArr.length; i < loopCnt; i++) {
			var nameValueArr = attribArr[i].split(secondDelim);
			for (var j = 0, loopCnt2 = nameValueArr.length; j < loopCnt2; j++) {
				if (nameValueArr[0].toLowerCase().replace(/\s/g, '') == attribNameLowerCase && loopCnt2 > 1) {
					return nameValueArr[1];
				}
			}
		}
	}
}

function WindowOpenHelper(sURL, sName, sFeatures, centerWindow) {
	var windowLeft = '';
	var windowTop = '';
	if (centerWindow) {
		var windowWidth = GetAttributeValue(sFeatures, 'width', ',', '=');
		windowLeft = (typeof(windowWidth) != 'undefined') ? ',left=' + ((GetScreenWidth() - windowWidth) / 2) : '';

		var windowHeight = GetAttributeValue(sFeatures, 'height', ',', '=');
		windowTop = (typeof(windowHeight) != 'undefined') ? ',top=' + ((GetScreenHeight() - windowHeight) / 2) : '';
	}
	window.open(sURL, sName, sFeatures + windowLeft + windowTop);
}


