function toggleTextOut(e, txtval) {
    if (e.value == "") e.value = txtval;

}
function toggleTextIn(e, txtval) {
    if (e.value == txtval) e.value = "";
    else e.select();
}

jQuery(document).ready(function() {
$("#login #dvPassword input").click(function() {
												 
        $(this).removeClass('password');
    });
	
	 $("#login #dvPassword input").focus(function() {
												 
        $(this).removeClass('password');
    });

    $("#login #dvPassword input").blur(function() {
												 
        var len = this.value.length;
        if ((len) == 0) {
            $(this).addClass('password');
        }
	
    });
    
    
      
    $("#find-job").hide();
    $('label.error').hide();
    jQuery("#toggle").click(function() {

        jQuery(this).toggleClass("collapse");
        jQuery("#find-job").toggle("slow");
    });

    getResize();
    addGalleryClass();
    faqAccordion();

});

function addGalleryClass() {
    var count = $('ul.group li').length;
    for (i = 0; i < count; i++) {
        if (i % 3 == 2) {
            $('ul.group li').eq(i).addClass('last');

        }
    }

    var count = $('ul.careers-list li').length;
    for (i = 0; i < count; i++) {
        if (i % 4 == 3) {
            $('ul.careers-list li').eq(i).addClass('last');

        }
    }

    var count = $('ul.features-list li').length;
    for (i = 0; i < count; i++) {
        if (i % 3 == 2) {
            $('ul.features-list li').eq(i).addClass('last');

        }
    }

}

/* populating multi select */

function getResize() {
    if ($("#col-right").length > 0) {
        $("#col-left").addClass('less-width');
    }
}

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
function addOption(theSel, theText, theValue) {
    var newOpt = new Option(theText, theValue);
    var selLength = theSel.length;
    theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex) {
    var selLength = theSel.length;
    if (selLength > 0) {
        theSel.options[theIndex] = null;
    }
}

function moveOptions(theSelFrom, theSelTo) {
    var selLength = theSelFrom.length;
    var selectedText = new Array();
    var selectedValues = new Array();
    var selectedCount = 0;
    var cou1 = 0;
    var adflag = 0;
    var i;
    for (i = selLength - 1; i >= 0; i--) {
        if (theSelFrom.options[i].selected) {
            for (j = 0; j < theSelTo.length; j++) {
                cou1 = 1;
                if (theSelTo.options[j].text == theSelFrom.options[i].text) {
                    cou1 = 0
                }
            }

            if (cou1 == 1) {
                selectedText[selectedCount] = theSelFrom.options[i].text;
                selectedValues[selectedCount] = theSelFrom.options[i].value;
                selectedCount++;
            }
        }
    }

    if (theSelTo.length > 0) {
		  for (i = selectedCount - 1; i >= 0; i--) {
            adflag = 0;
            for (j = 0; j < theSelTo.length; j++) {
                if (selectedText[i] == theSelTo.options[j].text && adflag == 0) {
                    adflag = 1
                }
            }
            if (adflag == 0) {
                addOption(theSelTo, selectedText[i], selectedValues[i]);
            }
        }
    } else {
		
        for (i = selectedCount - 1; i >= 0; i--) {
            addOption(theSelTo, selectedText[i - 1], selectedValues[i]);
        }
    }

    //if(NS4) history.go(0);
}

function moveOptions1(theSelFrom, theSelTo) {
    var selLength = theSelFrom.length;
    var selectedText = new Array();
    var selectedValues = new Array();
    var selectedCount = 0;
    var i;

    for (i = selLength - 1; i >= 0; i--) {
        if (theSelFrom.options[i].selected) {
            selectedText[selectedCount] = theSelFrom.options[i].text;
            selectedValues[selectedCount] = theSelFrom.options[i].value;
            deleteOption(theSelFrom, i);
            selectedCount++;
        }
    }
    //if(NS4) history.go(0);
}
//Function for Collapsing and Expanding the Links
function faqAccordion() {
    $('ul.faq-list li p').hide();
    $('ul.faq-list li h5').click(function() {
        $(this).toggleClass('open');
        $(this).parent('li').children('p').toggle('slow');
        $(this).parent('li').toggleClass('current');
    });
}

function validateJobVacancy(form) {
    if (form.txtKeyword.value == '') {
        showErrorMessage(form.txtKeyword, 'Please enter keyword');
        return (false);
    }

    if (form.cmbLocation.value == 'Choose') {
        showErrorMessage(form.cmbLocation, 'Please select');
        return (false);
    }

    if (form.cmbCompany.value == 'Choose') {
        showErrorMessage(form.cmbCompany, 'Please select');
        return (false);
    }

    if (form.cmbDepartment.value == 'Choose') {
        showErrorMessage(form.cmbDepartment, 'Please select');
        return (false);
    }

}

function ValidateForm(form) {
    //$('label.error').hide();
    if (form.txtFirstname.value == '') {
        showMessage(form.txtFirstname, 'Please enter name');
        return (false);
    }

    if (form.txtTextField.value == '') {
        showMessage(form.txtTextField, 'Please enter keyword');
        return (false);
    }

    if (form.select3.value == 'select') {
        showMessage(form.select3, 'Please select');
        return (false);
    }

    return (false);
}

function showMessage(field, msg) {
    $(field).parent('td').prev('td').find('label.error').html(msg).show('slow');
    field.focus();
}

function showErrorMessage(field, msg) {
    $(field).parent().parent().find('label.error').hide();
    $(field).parent('li').find('label.error').html(msg).show('slow');
    field.focus();
}

function IsValidEmail(value) {
    var emailFilter = /^.+@.+\..{2,3}$/;
    return (emailFilter.test(value));
}
function IsNumber(value) {
    var numberFilter = /^\d{6,10}$/;
    return (numberFilter.test(value));
}
function tweakHeading() {

    $("ul.features-list").find("li").each(function(i) {
        if ($(this).children('h4').text().length > 23) {
            $(this).addClass('less-padding');
        }

    });

    $("ul.careers-list").find("li").each(function(i) {

        if ($(this).children('h4').text().length > 23) {
            $(this).addClass('less-padding');
        }

    });

}

function PrintThisPage(id1,id2, printId) {

    
    var content = document.getElementById(printId);
    if (content == null) return;
    if (window.top == null) return;
    var html = window.top.GetData(id1);   
    if(id2!="")
    {
        html = html + "<br>";
        html = html + window.top.GetData(id2);
    }
    html = DisableHyperlinks(html);
    content.innerHTML = html;
}


function GetData(id) {
    var content = document.getElementById(id);
    if (content == null) return ("");
    return (content.innerHTML);
}

function DisableHyperlinks(html) {    
    return (html.replace(/href\s*=\s*\"*[^\">]*"/ig, "href=\"#\""));    
}

function toggleStep4() {

    $('#chkReceiveAlert').click(function() {
        $("#toggle-step").toggle();
        $("#btnCreateAccount").toggle();

    });
}

function enthClass(){
	var j=0;
	$(".company-listing li").each(function(i){
		if((j % 3)== 0 ){
			$('.company-listing li:nth-child('+j+')').addClass('last');
		}
		j=j+1;
		$('.company-listing li:last-child('+j+')').addClass('last');
	});
	$(".depart-list li").each(function(i){
		if((j % 3)== 0 ){
			$('.depart-list li:nth-child('+j+')').addClass('last');
		}
		j=j+1;
		$('.depart-list li:last-child('+j+')').addClass('last');
	});
	
}
