﻿function showPlaceholder(id, bEnable) 
{
    if (blnDisplay) {
        document.getElementById(id).className = 'cVisible';
    }
    else {
        document.getElementById(id).className = 'cNotVisible';    
    }
}

function companyProfileRegistrationNext(iCounterCore, iCounterMarket) {
    var CorBusIDs = "";
    var MarSecIDs = "";

    for (var x = 0; x < iCounterCore; x++) {
        var varChkCore = document.getElementById('core' + x);
        var varCorBus = document.getElementById('corbusid' + x);
        var checked = varChkCore.checked;
        var value = varCorBus.value;
        if (checked == true) {
            CorBusIDs += value + ',';
        }
    }
    for (var x2 = 0; x2 < iCounterMarket; x2++) {
        var varChkMar = document.getElementById('market' + x2);
        var varMarSec = document.getElementById('marsecid' + x2);
        var checked = varChkMar.checked;
        var value = varMarSec.value;
        if (checked == true) {
            MarSecIDs += value + ',';
        }
    }
    document.forms["aspnetForm"].hdnCoreBusinesses.value = CorBusIDs;
    document.forms["aspnetForm"].hdnMarketSectors.value = MarSecIDs;
    document.forms["aspnetForm"].hdnRequest.value = "save";
    document.forms["aspnetForm"].submit();
}

function companyProfileRegistrationSaveChanges(iCounterCore, iCounterMarket)
{
    var CorBusIDs = "";
    var MarSecIDs = "";

    for (var x = 0; x < iCounterCore; x++) {
        var varChkCore = document.getElementById('core' + x);
        var varCorBus = document.getElementById('corbusid' + x);
        var checked = varChkCore.checked;
        var value = varCorBus.value;
        if (checked == true) {
            CorBusIDs += value + ',';
        }
    }
    for (var x2 = 0; x2 < iCounterMarket; x2++) {
        var varChkMar = document.getElementById('market' + x2);
        var varMarSec = document.getElementById('marsecid' + x2);
        var checked = varChkMar.checked;
        var value = varMarSec.value;
        if (checked == true) {
            MarSecIDs += value + ',';
        }
    }
    document.forms["aspnetForm"].hdnCoreBusinesses.value = CorBusIDs;
    document.forms["aspnetForm"].hdnMarketSectors.value = MarSecIDs;
    document.forms["aspnetForm"].hdnRequest.value = "savechanges";
    document.forms["aspnetForm"].submit();
}


function companyProfileRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function companyProfileRegistrationSkip() {
    document.forms["aspnetForm"].hdnRequest.value = "skip";
    document.forms["aspnetForm"].submit();
}


function modeRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function modeRegistrationSkip() {
    document.forms["aspnetForm"].hdnRequest.value = "skip";
    document.forms["aspnetForm"].submit();
}

function modeRegistrationNext() {
    document.forms["aspnetForm"].hdnRequest.value = "next";
    document.forms["aspnetForm"].submit();
}



function SaveSite(id) {
    var site = "";
//    var input = document.getElementById('siteCode' + id);
//    site = id + ";" + input.value;
//    input = document.getElementById('siteName' + id);
//    site = site += ";" + input.value;
//    input = document.getElementById('siteAddr1' + id);
//    site = site += ";" + input.value;
//    input = document.getElementById('siteAddr2' + id);
//    site = site += ";" + input.value;
    var input = document.getElementById('siteTown' + id);
    site = id + ";" + input.value;
//    input = document.getElementById('siteCounty' + id);
//    site = site += ";" + input.value;
    input = document.getElementById('sitePostcode' + id);
    site = site += ";" + input.value;
    var dropdownIndex = document.getElementById('select' + id).selectedIndex;
    site = site += ";" + document.getElementById('select' + id)[dropdownIndex].value;
//    input = document.getElementById('siteTel' + id);
//    site = site += ";" + input.value;
//    input = document.getElementById('siteFax' + id);
//    site = site += ";" + input.value;
//    input = document.getElementById('siteEmail' + id);
//    site = site += ";" + input.value;
//    input = document.getElementById('siteWebsite' + id);
//    site = site += ";" + input.value;
//    input = document.getElementById('siteWarehouseSize' + id);
//    site = site += ";" + input.value;

    document.forms["aspnetForm"].hdnSite.value = site;
    document.forms["aspnetForm"].hdnRequest.value = "save";
    document.forms["aspnetForm"].submit();
}

function SaveEquipment(id, count) {

    var equipment = "";
    var qty = "";
    var notes = "";
    var equid = "";

    for (i = 0; i < count; i++) {
        qty = document.getElementById('qty_' + id + '_' + i);
        notes = document.getElementById('notes_' + id + '_' + i);
        equid = qty.getAttribute('equID');

        if (qty.value == "") {
            qty.value = "0";
        }

        equipment += qty.value + "_notes_" + notes.value + "_id_" + equid + ";";
    }

    document.forms["aspnetForm"].hdnRequest.value = "save";
    document.forms["aspnetForm"].hdnEquipment.value = equipment;
    document.forms["aspnetForm"].submit();
}

function SaveChangesEquipment(id, count) {

    var equipment = "";
    var qty = "";
    var notes = "";
    var equid = "";

    for (i = 0; i < count; i++) {
        qty = document.getElementById('qty_' + id + '_' + i);
        notes = document.getElementById('notes_' + id + '_' + i);
        equid = qty.getAttribute('equID');

        if (qty.value == "") {
            qty.value = "0";
        }

        equipment += qty.value + "_notes_" + notes.value + "_id_" + equid + ";";
    }

    document.forms["aspnetForm"].hdnRequest.value = "savechanges";
    document.forms["aspnetForm"].hdnEquipment.value = equipment;
    document.forms["aspnetForm"].submit();
}


function DeleteSite(id) {
    var answer = confirm("Are you sure you wish to delete this site?")
    if (answer) {
        document.forms["aspnetForm"].hdnSite.value = id;
        document.forms["aspnetForm"].hdnRequest.value = "delete";
        document.forms["aspnetForm"].submit();
    }
    else {

    }
}

function DeleteDocument(id) {
    document.forms["aspnetForm"].hdnId.value = id;
    document.forms["aspnetForm"].hdnRequest.value = "delete";
    document.forms["aspnetForm"].submit();
}

function siteRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function siteRegistrationSkip() {
    document.forms["aspnetForm"].hdnRequest.value = "skip";
    document.forms["aspnetForm"].submit();
}

function siteRegistrationNext() {
    document.forms["aspnetForm"].hdnRequest.value = "next";
    document.forms["aspnetForm"].submit();
}

function siteRegistrationSavechanges() {
    document.forms["aspnetForm"].hdnRequest.value = "savechanges";
    document.forms["aspnetForm"].submit();
}



function siteRegistrationAdd() {
    document.forms["aspnetForm"].hdnRequest.value = "add";
    document.forms["aspnetForm"].submit();
}



function contactRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function contactRegistrationSkip() {
    document.forms["aspnetForm"].hdnRequest.value = "skip";
    document.forms["aspnetForm"].submit();
}

function contactRegistrationNext(count) {
    var contacts = "";

    for (i = 0; i < count; i++) {
        id = document.getElementById('hdnid' + i).value;
        name = document.getElementById('name' + i).value;
        title = document.getElementById('title' + i).value;
        tel = document.getElementById('tel' + i).value;
        fax = document.getElementById('fax' + i).value;
        email = document.getElementById('email' + i).value;
        mobile = document.getElementById('mobile' + i).value;

        var dropdownIndex = document.getElementById('select' + i).selectedIndex;
        regcongrpid = document.getElementById('select' + i)[dropdownIndex].value;
        if (name != "") {
            contacts += id + "_" + name + "_" + title + "_" + tel + "_" + fax + "_" + email + "_" + mobile + "_" + regcongrpid + ";";
        }
    }
    document.forms["aspnetForm"].hdnRequest.value = "next";
    document.forms["aspnetForm"].hdnContacts.value = contacts;
    document.forms["aspnetForm"].submit();
}

function contactRegistrationSaveChanges(count) {
    var contacts = "";

    for (i = 0; i < count; i++) {
        id = document.getElementById('hdnid' + i).value;
        name = document.getElementById('name' + i).value;
        title = document.getElementById('title' + i).value;
        tel = document.getElementById('tel' + i).value;
        fax = document.getElementById('fax' + i).value;
        email = document.getElementById('email' + i).value;
        mobile = document.getElementById('mobile' + i).value;

        var dropdownIndex = document.getElementById('select' + i).selectedIndex;
        regcongrpid = document.getElementById('select' + i)[dropdownIndex].value;
        if (name != "") {
            contacts += id + "_" + name + "_" + title + "_" + tel + "_" + fax + "_" + email + "_" + mobile + "_" + regcongrpid + ";";
        }
    }
    document.forms["aspnetForm"].hdnRequest.value = "savechanges";
    document.forms["aspnetForm"].hdnContacts.value = contacts;
    document.forms["aspnetForm"].submit();
}

function contactRegistrationAdd(count) {
    var contacts = "";

    for (i = 0; i < count; i++) {
        id = document.getElementById('hdnid' + i).value;
        name = document.getElementById('name' + i).value;
        title = document.getElementById('title' + i).value;
        tel = document.getElementById('tel' + i).value;
        fax = document.getElementById('fax' + i).value;
        email = document.getElementById('email' + i).value;
        mobile = document.getElementById('mobile' + i).value;

        var dropdownIndex = document.getElementById('select' + i).selectedIndex;
        regcongrpid = document.getElementById('select' + i)[dropdownIndex].value;
        if (name != "") {
            contacts += id + "_" + name + "_" + title + "_" + tel + "_" + fax + "_" + email + "_" + mobile + "_" + regcongrpid + ";";
        }
    }
    document.forms["aspnetForm"].hdnRequest.value = "add";
    document.forms["aspnetForm"].hdnContacts.value = contacts;
    document.forms["aspnetForm"].submit();
}


function contactRegistrationDelete(RegConID, id) {

    document.forms["aspnetForm"].hdnRequest.value = "delete";
    document.forms["aspnetForm"].hdnContacts.value = RegConID;
    document.forms["aspnetForm"].submit();
}


function contactNew(id) {
}

function contactValidate(id) {
    name = document.getElementById('name' + id).value;
    title = document.getElementById('title' + id).value;
    tel = document.getElementById('tel' + id).value;
    fax = document.getElementById('fax' + id).value;
    email = document.getElementById('email' + id).value;
    mobile = document.getElementById('mobile' + id).value;

    var labelName = document.getElementById('lblName' + id);
    var labelTel = document.getElementById('lblTel' + id);

    if (name == "" || tel == "") {
        labelName.setAttribute("className", "labelError");
        labelTel.setAttribute("className", "labelError");
    }
    else {
        labelName.setAttribute("className", "labelLeft");
        labelTel.setAttribute("className", "labelLeft");
    }
}

function DeleteLane(id) {
    document.forms["aspnetForm"].hdnRequest.value = "delete";
    document.forms["aspnetForm"].hdnId.value = id;
    document.forms["aspnetForm"].submit();
}

function laneRegistrationNext() {
    document.forms["aspnetForm"].hdnRequest.value = "next";
    document.forms["aspnetForm"].submit();
}

function laneRegistrationSaveChanges() {
    document.forms["aspnetForm"].hdnRequest.value = "savechanges";
    document.forms["aspnetForm"].submit();
}

function laneRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function laneRegistrationSkip() {
    document.forms["aspnetForm"].hdnRequest.value = "skip";
    document.forms["aspnetForm"].submit();
}

function domesticLaneRegistrationNext() {
    document.forms["aspnetForm"].hdnRequest.value = "next";
    document.forms["aspnetForm"].submit();
}

function domesticLaneRegistrationSaveChanges() {
    document.forms["aspnetForm"].hdnRequest.value = "savechanges";
    document.forms["aspnetForm"].submit();
}

function domesticLaneRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function domesticLaneRegistrationSkip() {
    document.forms["aspnetForm"].hdnRequest.value = "skip";
    document.forms["aspnetForm"].submit();
}


function DeleteRegionLane(id) {
    document.forms["aspnetForm"].hdnRequest.value = "delete";
    document.forms["aspnetForm"].hdnId.value = id;
    document.forms["aspnetForm"].submit();
}

function welcomeRegistrationBack() {
    document.forms["aspnetForm"].hdnRequest.value = "back";
    document.forms["aspnetForm"].submit();
}

function DisplayGroup(id, blnDisplay) {
    if (blnDisplay) {   
        document.getElementById(id).className = 'cVisible';
        document.getElementById(id).className = 'cVisible';

        //        //show the correct group button
        //        document.getElementById(id + 'HideLink').className = 'cVisible';
        //        document.getElementById(id + 'DisplayLink').className = 'cNotVisible';
    }
    else {
    
    }
}


function toggle(strID) {
    if (document.getElementById(strID).className == 'cVisible') {

        document.getElementById(strID).className = 'cNotVisible';
    } else {
    document.getElementById(strID).className = 'cVisible';
    }
}


