﻿/// <reference path="jquery-1.4.1-vsdoc.js" />
/// <reference path="jquery.fitTextToHeight.js" />

function showDivTabNav(obj1, obj2)
{
	if(document.getElementById){
		var el1 = document.getElementById(obj1);
		var el2 = document.getElementById(obj2);
		var ar1 = document.getElementsByTagName("div");
		var ar2 = document.getElementsByTagName("a");
		
		if(el1.style.display != "block"){
			for (var i=0; i<ar1.length; i++){
				if (ar1[i].className=="tabclass")
					ar1[i].style.display = "none";
			}
			el1.style.display = "block";
		}
		for (var i=0; i<ar2.length; i++){
			if (ar2[i].className=="tabsSelected")
				ar2[i].className = "";
		}
		el2.className = "tabsSelected";
	}
}

function showLinguist() {
    if (document.getElementById) {
        var el1 = document.getElementById("linguistDiv");
        el1.style.display = "block";
    }
}

function hideLinguist() {
    if (document.getElementById) {
        var el1 = document.getElementById("linguistDiv");
        el1.style.display = "none";
    }
}

function showCaseStudy(obj1, obj2) {
    if (document.getElementById) {
        var el1 = document.getElementById("caseStudy" + obj1);
        var el2 = document.getElementById("caseStudyLogo" + obj1);
        var ar1 = document.getElementsByTagName("div");

        document.getElementById("caseStudyLogo1").className = "";
        if (document.getElementById("caseStudyLogo2") != null) {
        	document.getElementById("caseStudyLogo2").className = "";
        }
        
        if (obj1 == "1")
        {
        	document.getElementById("caseStudyLogo1").className = "caseStudyLogo1" + obj2;
        	if (document.getElementById("caseStudyLogo2") != null) {
        		document.getElementById("caseStudyLogo2").className = "caseStudyLogo2" + obj2 + " caseStudyLogoTransparent";
        	}
        }

        if (obj1 == "2") {
        	document.getElementById("caseStudyLogo1").className = "caseStudyLogo1" + obj2 + " caseStudyLogoTransparent";
        	if (document.getElementById("caseStudyLogo2") != null) {
        		document.getElementById("caseStudyLogo2").className = "caseStudyLogo2" + obj2;
        	}
        }

        if (el1.style.display != "block") {
            for (var i = 0; i < ar1.length; i++) {
                if (ar1[i].className == "caseStudy")
                    ar1[i].style.display = "none";
            }
            el1.style.display = "block";
        }
    }
}

function showCaseStudyHome(obj1, obj2) {
    if (document.getElementById) {
        var el1 = document.getElementById("caseStudy" + obj1);
        var el2 = document.getElementById("caseStudyLogoHome" + obj1);
        var ar1 = document.getElementsByTagName("div");

        document.getElementById("caseStudyLogoHome1").className = "";
        document.getElementById("caseStudyLogoHome2").className = "";

        if (obj1 == "1") {
            document.getElementById("caseStudyLogoHome1").className = "caseStudyLogoHome1" + obj2;
            document.getElementById("caseStudyLogoHome2").className = "caseStudyLogoHome2" + obj2 + " caseStudyLogoTransparent";
        }

        if (obj1 == "2") {
            document.getElementById("caseStudyLogoHome1").className = "caseStudyLogoHome1" + obj2 + " caseStudyLogoTransparent";
            document.getElementById("caseStudyLogoHome2").className = "caseStudyLogoHome2" + obj2;
        }

        if (el1.style.display != "block") {
            for (var i = 0; i < ar1.length; i++) {
                if (ar1[i].className == "caseStudy")
                    ar1[i].style.display = "none";
            }
            el1.style.display = "block";
        }
    }

}

function openForms(dividerid,count) {

    for (var i = 1; i <= count; i++) {
        //declare
        var dividertag = document.getElementById("tbw_MainContent_EnquiryForms_formBox" + i);
        var forma = document.getElementById("formLink" + i);
        var formselected = document.getElementById("formLink" + dividerid);

        //if dividerid = i then show
        if (dividerid == i && formselected.className != "arrowopen") {
            dividertag.style.display = "block";
            forma.className = "arrowopen";
        }
        else 
        {
            //reset all
            dividertag.style.display = "none";
            forma.className = "arrowclosed";        
        }        
    }
}

function toggleForms(Element) {
    var openClass = $(Element).children("#openclass").val();
    var closedClass = $(Element).children("#closedclass").val();
    var Parent = $(Element).parents(".formboxGrad\\S*");
    $("#formBoxContent").find("a." + openClass).removeClass(openClass).addClass(closedClass).children("#*formBox*").css("display", "none");
    if ($(Element).hasClass(closedClass)) {
        // toggle the form open
        $(Element).removeClass(closedClass);
        $(Element).addClass(openClass);
        $(Element).parents(".formboxContent").children("div").css({ "display": "block", "width": "307" }).hide().slideDown();
        Parent.removeClass("formboxGradient");
        Parent.addClass("formboxGradientFull");
    }
    else {
        // toggle the form closed
        $(Element).removeClass(openClass);
        $(Element).addClass(closedClass);
        $(Element).parents(".formboxContent").children("div").slideUp();
        Parent.removeClass("formboxGradientFull");
        Parent.addClass("formboxGradient");
    }
}



function addMoreWorkExp() {
    for (var i = 0; i < 10; i++) {
        //declare
        var divtag = document.getElementById("tbw_MainContent_workExpWrapper" + i);

        //if dividerid = i then show
        if (divtag.style.display == "none") {
            divtag.style.display = "block";
            if (i == 9) {
                document.getElementById("workExpMore").style.display = "none";
            }
            break;
        }
    }
}

function addMoreEducation() {
    for (var i = 0; i < 10; i++) {
        //declare
        var divtag = document.getElementById("tbw_MainContent_educationWrapper" + i);

        //if dividerid = i then show
        if (divtag.style.display == "none") {
            divtag.style.display = "block";
            if (i == 9) {
                document.getElementById("educationMore").style.display = "none";
            }
            break;
        }
    }
}
/*
$(document).ready(function () {
    // need to resize the menu
    var menu = $("#subNav").children("ul");
    var childCount = menu.children().length;
    var width = parseInt((menu.attr("clientWidth") - childCount) / childCount);
    var offset = (menu.attr("clientWidth") - childCount) - (width * childCount);
    menu.children().css("width", width);
    menu.children(".last").css("width", width + offset);
}); */

$(document).ready(function () {

    $(".formboxContent > h2").fitToHeight();
    //    $(".formboxContent > h2 a").css("overflow", "auto");
    //    $(".formboxContent > h2").css("overflow", "auto");
    //    $(".formboxContent > h2").each(function (index) {
    //        if ($(this).children("a").attr("scrollHeight") > $(this).outerHeight()) {
    //            var size = $(this).css("font-size");
    //            var targetHeight = $(this).outerHeight() + 3;
    //            var scrollHeight = $(this).children("a").attr("scrollHeight");
    //            var fontSize = parseInt($(this).css("font-size"));
    //            while (scrollHeight > targetHeight) {
    //                fontSize -= 1;
    //                $(this).css("font-size", fontSize)
    //                scrollHeight = $(this).children("a").attr("scrollHeight");
    //                if (fontSize <= 24) {
    //                    break;
    //                }
    //            }
    //        }
    //        if ($(this).attr("scrollHeight") > $(this).outerHeight()) {
    //            var size = $(this).css("font-size");
    //            var targetHeight = $(this).outerHeight() + 3;
    //            var scrollHeight = $(this).attr("scrollHeight");
    //            var fontSize = parseInt($(this).css("font-size"));
    //            while (scrollHeight > targetHeight) {
    //                fontSize -= 1;
    //                $(this).css("font-size", fontSize)
    //                scrollHeight = $(this).attr("scrollHeight");
    //                if (fontSize <= 22) {
    //                    break;
    //                }
    //            }
    //        }
    //    });
    //    $(".formboxContent > h2 a").css("overflow", "visible");
    //    $(".formboxContent > h2").css("overflow", "visible");
});    


