// JavaScript Document

function CyprusGuide()
{
    window.open('cyprus_guide.php', 'CyprusGuide', 'width=640px,height=480px,scrollbars=1');
}

function BuyingGuide()
{
    window.open('buying_guide.php', 'BuyingGuide', 'width=640px,height=480px,scrollbars=1');
}

function tac(sWhich)
{
	sURL = "tac_" + sWhich + ".php";
    window.open(sURL, 'TermsAndConditions', 'width=640px,height=480px,scrollbars=1');
}

function CyprusMap()
{
    window.open('cyprus_map.html', 'CyprusMap', 'width=509px,height=247px,scrollbars=0');
}

function ShowThumbnail(sRelImgPath, sCat, sThumbFile)
{
    iWidth = 177;
    iHeight = 54;
    sParams = "width=" + iWidth + "px,height=" + iHeight + "px";
    sParams = sParams + ",name=showthumb,scrollbars=0";
    sURL = "photo.html?folder=" + sRelImgPath + "&cat=" + sCat + "&photo=" + sThumbFile;
    window.open(sURL, 'Photo', sParams);
}

function ShowPhotos(sRelImgPath, sCat, sID, sThumbFile)
{
    iWidth = 377;
    iHeight = 254;
    sParams = "width=" + iWidth + "px,height=" + iHeight + "px";
    sParams = sParams + ",name=showphotos,scrollbars=0";
    sURL = "photos.php?folder=" + sRelImgPath + "&cat=" + sCat + "&id=" + sID + "&photo=" + sThumbFile;
    window.open(sURL, 'Photos', sParams);
}

function ShowVideo(sRelImgPath, sCat, sVideoFile)
{
    iWidth = 360;
    iHeight = 380;
    sParams = "width=" + iWidth + "px,height=" + iHeight + "px";
    sParams = sParams + ",scrollbars=0,status=0,titlebar=0,toolbar=0";
	if (navigator.appName == "Netscape")
	{
    	sURL = sRelImgPath + "/" + sCat + "/" + sVideoFile;
	}
	else
	{
    	sURL = "video.php?folder=" + sRelImgPath + "&cat=" + sCat + "&video=" + sVideoFile;
	}
    window.open(sURL, 'Video', sParams);
}

function ShowVideoTest(sRelImgPath, sCat, sVideoFile)
{
    iWidth = 360;
    iHeight = 380;
    sParams = "width=" + iWidth + "px,height=" + iHeight + "px";
    sParams = sParams + ",scrollbars=0,status=0,titlebar=0,toolbar=0";
	if (navigator.appName == "Netscape")
	{
    	sURL = sRelImgPath + "/" + sCat + "/" + sVideoFile;
	}
	else
	{
    	sURL = "videotest.php?folder=" + sRelImgPath + "&cat=" + sCat + "&video=" + sVideoFile;
	}
    window.open(sURL, 'Video', sParams);
}

function ShowPriceList(sCat, sID)
{
	sURL = "price_list.php?cat=" + sCat + "&id=" + sID;
	window.open(sURL, 'PriceList', 'width=480px,height=360px,scrollbars=1');
}

function ShowAvailability(sCat, sID)
{
	sURL = "availability.php?cat=" + sCat + "&id=" + sID;
	window.open(sURL, 'Availability', 'width=480px,height=360px,scrollbars=1');
}

function SetFeatured(sUser, sPass, sCat, sCodeControl, sPromoControl, sBoxControl)
{
	sCode = sCodeControl.value;
	sPromo = sPromoControl.value;
	sBox = sBoxControl.value;
	sURL = "featset.php" + "?user=" + sUser + "&pass=" + sPass + "&cat=" + sCat + "&code=" + sCode + "&promo=" + sPromo + "&box=" + sBox;
	if (sCat != "")
	{
		window.open(sURL, 'SetFeatured', 'width=240px,height=200px,scrollbars=0');
		return false;
	}
	else
	{
		return true;
	}
}

function SetFeatures(sUser, sPass, sCat)
{
	sURL = "setfeatures.php" + "?user=" + sUser + "&pass=" + sPass + "&cat=" + sCat;
	if (sCat != "")
	{
		window.open(sURL, 'SetFeatures', 'width=600px,height=400px,scrollbars=0');
		return false;
	}
	else
	{
		return true;
	}
}

function SetOnOffer(sUser, sPass, sCat, sId, sVal)
{
	sURL = "setonoffer.php" + "?user=" + sUser + "&pass=" + sPass + "&cat=" + sCat + "&id=" + sId + "&val=" + sVal;
	if (sCat != "")
	{
		window.open(sURL, 'SetOnOffer', 'width=240px,height=100px,scrollbars=0');
		sElemId = "idOffer" + sId;
		if (sVal == "Y")
		{
			sHtml = "<strong>Yes</strong>";
		}
		else
		{
			sHtml = "&nbsp;";
		}
		document.getElementById(sElemId).innerHTML = sHtml;
		return false;
	}
	else
	{
		return true;
	}
}

function CheckPrices(frmForm)
{
    with (frmForm)
    {
		iFromValue = PriceFrom.value;
		iToValue = PriceTo.value;
		bFrom = false;
		bTo = false;
		if (iFromValue != "" && iFromValue != null)
		{
			bFrom = true;
		}
		if (iToValue != "" && iToValue != null)
		{
			bTo = true;
		}
		bFromOK = true;
		bToOK = true;
		if (bFrom == true)
		{
			iTestValue = parseInt(iFromValue);
			if (iFromValue < 0 || iFromValue > 99999 || iFromValue != iTestValue)
			{
				bFromOK = false;
				alert("Please enter a valid Price.");
				PriceFrom.focus();
				return false;
			}
		}
        if (bTo == true && bFromOK == true)
		{
			iTestValue = parseInt(iToValue);
			if (iToValue < 0 || iToValue > 99999 || iToValue != iTestValue)
			{
				bToOK = false;
				alert("Please enter a valid Price.");
				PriceTo.focus();
				return false;
			}
		}
		if (bFrom == true && bFromOK == true && bTo == true && bToOK == true)
		{
			if (iFromValue > iToValue)
			{
				alert("Please enter a valid range.");
				PriceFrom.focus();
				return false;
			}
		}
    }
}

function ChangeLocation(varPage)
{
	varPageURL = 'http://www.property-management-cyprus.com/' + varPage + '.php';
	varRegionID = document.getElementById('RegionID').value;
	if (varRegionID != '{ANY}')
	{
		varPageURL = varPageURL + '?RegionID=' + varRegionID;
	}
	window.location.replace(varPageURL);
}
