﻿//Used for privacy policy pop up
function PrivacyPolicy()
{	
	var url;
	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'		
	url = '/privacy-policy.aspx';
	window.open(url,'privacyPolicy',features);
}
//Validate Search Box in all Default & Landing pages
function ValidateSbox(srvId,pCode,cntry)
{
    var errMsg = '';
    var txtPostCode = document.getElementById(pCode);
    
    if (srvId != "7") 
        if (txtPostCode.value == "")
            errMsg += "\n- Postcode";
               
    if (srvId == "6") 
    {
        var ddlCountry = document.getElementById(cntry);
        if (ddlCountry.value == "")
            errMsg += "\n- Country";
    }
    else if (srvId == "7")
    {
        var ddlCountry = document.getElementById(cntry);
        if (ddlCountry.value == "")
            errMsg += "\n- Country";
        if (txtPostCode.value == "")
            errMsg += "\n- Postcode";
    }
 
    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 != "Removal Companies" && document.getElementById(ddlSrv).value != "Residential Removals")
    {
        var redirectUrl = "";
        if (document.getElementById(ddlSrv).value == "Business Removals")
            redirectUrl = "http://www.ukremovalquotes.co.uk/business-removals.html";
        else if (document.getElementById(ddlSrv).value == "International Removals")
            redirectUrl = "http://www.ukremovalquotes.co.uk/international-removals.html";
            
        window.location.href = redirectUrl;
    }
    else if (document.getElementById(ddlSrv).value != "")
    {
        var currentUrl = window.location.pathname;
        if (currentUrl != "/" && currentUrl != "/removal-companies.html" && currentUrl != "/residential-removals.html")
        {
            var redirectUrl = "";
            if (document.getElementById(ddlSrv).value == "Removal Companies")
                redirectUrl = "http://www.ukremovalquotes.co.uk/removal-companies.html";
            else if (document.getElementById(ddlSrv).value == "Residential Removals")
                redirectUrl = "http://www.ukremovalquotes.co.uk/residential-removals.html";
            window.location.href = redirectUrl;
        }
    }
}
//Used for Iframe Javascript
function IFrmDdlPostBack(ddlSrv)
{
    if  (document.getElementById(ddlSrv).value != "" && document.getElementById(ddlSrv).value != "Removal Companies" && document.getElementById(ddlSrv).value != "Residential Removals")
    {
        var redirectUrl = "";
        if (document.getElementById(ddlSrv).value == "Business Removals")
            redirectUrl = "http://www.ukremovalquotes.co.uk/business-removals.html";
        else if (document.getElementById(ddlSrv).value == "International Removals")
            redirectUrl = "http://www.ukremovalquotes.co.uk/international-removals.html";
            
        parent.document.location.href = redirectUrl;
    }
    else if (document.getElementById(ddlSrv).value != "")
    {
        var currentUrl = window.location.pathname;
        if (currentUrl != "/" && currentUrl != "/removal-companies.html" && currentUrl != "/residential-removals.html")
        {
            var redirectUrl = "";
            if (document.getElementById(ddlSrv).value == "Removal Companies")
                redirectUrl = "http://www.ukremovalquotes.co.uk/removal-companies.html";
            else if (document.getElementById(ddlSrv).value == "Residential Removals")
                redirectUrl = "http://www.ukremovalquotes.co.uk/residential-removals.html";
            parent.document.location.href = redirectUrl;
        }
    }
}
