﻿//Used for privacy policy popUp
function PrivacyPolicy()
{
	var LeftPosition = (screen.width) ? (screen.width-750)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-500)/2 : 0;
	var features = 'height='+500+',width='+750+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes';
	var url = '/privacypolicy.aspx';
	window.open(url,'privacypolicy',features);
}

//Validate Search Box in all Default & Landing pages
function ValidateSbox(srvId,region,cntry)
{
    var errMsg = '';
    var ddlRegion = document.getElementById(region);
               
    if (srvId == "6") 
    {
        var ddlCountry = document.getElementById(cntry);
        if (ddlRegion.value == "")
            errMsg += "\n- Region / City";
        if (ddlCountry.value == "")
            errMsg += "\n- Country";
    }
    else if (srvId == "7")
    {
        var ddlCountry = document.getElementById(cntry);
        if (ddlCountry.value == "")
            errMsg += "\n- Country";
        if (ddlRegion.value == "")
            errMsg += "\n- Region / City";
    }
    else
    {
        if (ddlRegion.value == "")
                errMsg += "\n- Region / City";
    }
    
    if(errMsg != '')
    {
        alert('The following fields are required:' + errMsg);
        return false;
    }
    else    
        return true;
}

//Used to do postback for service type dropdown of search box in default and landing pages
function DdlPostBack(ddlSrv)
{
    if  (document.getElementById(ddlSrv).value != "" && document.getElementById(ddlSrv).value != "Moving Companies" && document.getElementById(ddlSrv).value != "Residential Removals")
    {
        var redirectUrl = "";
        if (document.getElementById(ddlSrv).value == "Office Relocation")
            redirectUrl = "http://www.removalcompanies.co.nz/office-relocation.html";
        else if (document.getElementById(ddlSrv).value == "International Movers")
            redirectUrl = "http://www.removalcompanies.co.nz/international-movers.html";
            
        window.location.href = redirectUrl;
    }
    else if (document.getElementById(ddlSrv).value != "")
    {
        var currentUrl = window.location.pathname;
        if (currentUrl != "/" && currentUrl != "/moving-companies.html" && currentUrl != "/residential-removals.html")
        {
            var redirectUrl = "";
            if (document.getElementById(ddlSrv).value == "Moving Companies")
                redirectUrl = "http://www.removalcompanies.co.nz/moving-companies.html";
            else if (document.getElementById(ddlSrv).value == "Residential Removals")
                redirectUrl = "http://www.removalcompanies.co.nz/residential-removals.html";
            window.location.href = redirectUrl;
        }
    }
}