/*
Vail Property Brokerage
common javascript functionality

Copyright 2007, Karl Glasgow. All Rights Reserved.
Modification, repackaging, sale or distribution requires
explicit written permission from Karl Glasgow.
*/

function Get_Cookie(name) 
{
   var start = document.cookie.indexOf(name + "="); 
   var len = (start + name.length + 1);
   if ((!start) && (name != document.cookie.substring(0, name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";", len); 
   if (end == -1) end = document.cookie.length; 
   return (unescape(document.cookie.substring(len, end)));
} 

function Set_Cookie(name, value, expires, path, domain, secure) 
{ 
    var cookieString = (name + "=" + escape(value) + ((expires) ? ";expires=" + expires.toGMTString() : "") + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : ""));
    document.cookie = cookieString; 
} 

function Delete_Cookie(name, path, domain) 
{ 
	if (Get_Cookie(name)) 
	{
		document.cookie = (name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-70 00:00:01 GMT"); 
	}
}

function AudioWrapper(url) 
{
	
}

function ShowPrivacyPolicy() 
{
	var winPolicy = window.open('privacyPolicy.php', 'PrivacyPolicy', 'scrollbars=yes,resizable=yes,width=800,height=600');
}

function CenterDiv(divId, width, height) 
{
	var div = document.getElementById(divId);
	alert(window.screen.width + ', ' + parseInt(div.innerWidth));
	alert(window.screen.height + ', ' + parseInt(div.offsetHeight));
	var x = (window.screen.width / 2) - (parseInt(div.innerWidth) / 2);
	var y = (window.screen.height / 2) - (parseInt(div.offsetHeight) / 2);              
	div.style.top = y;
	div.style.left = x;
	div.style.display = 'block';
}

function getBrowserHeight() 
{
    var intH = 0;
    var intW = 0;

    if(typeof window.innerWidth  == 'number') 
    {
        intH = window.innerHeight;
        intW = window.innerWidth;
    } 
    else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
    {
        intH = document.documentElement.clientHeight;
        intW = document.documentElement.clientWidth;
    }
    else if(document.body && (document.body.clientWidth || document.body.clientHeight)) 
    {
		intH = document.body.clientHeight;
		intW = document.body.clientWidth;
    }

    return {width: parseInt(intW), height: parseInt(intH)};
}

function CenterDiv(divId, width, height) 
{
    var div = document.getElementById(divId);    
    var browser = getBrowserHeight();

    div.style.left = parseInt((browser.width - width) / 2);
    div.style.top = parseInt((browser.height - height) / 2);
    
    div.style.display = 'block';
}

var win = null;
function CenteredWindow(url, name, w, h, scrollbars, resizable) 
{
	LeftPosition = (screen.width) ? ((screen.width - w) / 2) : 0;
	TopPosition = (screen.height) ? ((screen.height - h) / 2) : 0;
	settings = ('height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',menubar=no,location=no,status=no,scrollbars=' + scrollbars + ',resizable=' + resizable);
	//alert(url + ', ' + name + ', ' + settings);
	win = window.open(url, name, settings);
}
