// Dropdown for login

//temporarily commented out until we use the login code. 
//$(document).ready(function(){
//	var containerHeight = $("#dropdownContainer").height();
//	$("#dropdownContainer").css({ marginTop:-containerHeight });
//	//$("#dropdownContainer").hide();
//	$(".loginTab").click(function(){
//	  //$("#dropdownContainer").slideToggle(1000);
//		if(parseInt($("#dropdownContainer").css('marginTop')) == 0){
//			$("#dropdownContainer").animate({marginTop: -containerHeight}, 1000);
//		}else{
//			$("#dropdownContainer").animate({marginTop: 0}, 1000);
//		}
//	});
//});

function initSearch(searchBox) {
    if (searchBox.value == 'search') {
        searchBox.value = ''
        searchBox.style.fontStyle = 'normal'
    }
    else
        updateSearchBox(searchBox)
}

function updateSearchBox(searchBox) {
    if (searchBox.value == '') {
        searchBox.value = 'search'
        searchBox.style.fontStyle = 'italic'
    }
}

function getMoreInfoFormData() {
    var fname = document.getElementById("txtFName").value
    var lname = document.getElementById("txtLName").value
    var title = document.getElementById("txtTitle").value
    var email = document.getElementById("txtEmail").value
    var phone = document.getElementById("txtPhone").value
    var company = document.getElementById("txtCompany").value
    var hearAbout = document.getElementById("cboHearAbout").value
    var comments = document.getElementById("txtComments").value
    var page = self.location
    
    return "FName="+fname+"&LName="+lname+"&Title="+title+"&Email="+email+"&Phone="+phone+"&Company="+company+"&HearAbout="+hearAbout+"&Page="+page+"&Comments="+comments
}


function moreInfoFormIsValid() {
    var fname = document.getElementById("txtFName")
    var lname = document.getElementById("txtLName")
    var company = document.getElementById("txtCompany")
    var email = document.getElementById("txtEmail")
    
    if ((fname.value > '') &&
       (lname.value > '') &&
       (company.value > '') &&
       (email.value > '') &&
       (validEmail(email.value)))
       return true
    else
    {
        if (fname.value == '')
            fname.style.borderColor = 'red'
        else
            fname.style.borderColor = '#666'
            
        if (lname.value == '')
            lname.style.borderColor = 'red'
        else
            lname.style.borderColor = '#666'
        
        if (company.value == '')
            company.style.borderColor = 'red'
        else
            company.style.borderColor = '#666'
            
        if (email.value == '')
            email.style.borderColor = 'red'
        else
            email.style.borderColor = '#666'
            
        if (!validEmail(email.value))
            email.style.borderColor = 'red'
        else
            email.style.borderColor = '#666'
        
        alert("Please provide valid answers for the fields in red.")
        
        return false
    }
}

function validEmail(src) {
    var emailReg = "^[\\w-_\.+]*[\\w-_\.]\@([\\w]+\\.)+[\\w]+[\\w]$";
    var regex = new RegExp(emailReg);
    
    return regex.test(src);
}

function initMoreInfoForm() {
    var fname = document.getElementById("txtFName")
    var lname = document.getElementById("txtLName")
    var company = document.getElementById("txtCompany")
    var email = document.getElementById("txtEmail")
    var title = document.getElementById("txtTitle")
    var phone = document.getElementById("txtPhone")
    var comments = document.getElementById("txtComments")
    var hearAbout = document.getElementById("cboHearAbout")
    
    fname.style.borderColor = '#666'
    fname.value = ''
    
    lname.style.borderColor = '#666'
    lname.value = ''
    
    company.style.borderColor = '#666'
    company.value = ''
    
    email.style.borderColor = '#666'
    email.value = ''
    
    hearAbout.value = ''    
    title.value = ''
    phone.value = ''
    comments.value = ''
}

function closeMoreInfo() {
    //toggleSlideshow(false)
    myLightWindow.deactivate()
}

function searchSite(path) {
    window.location.href = path
}

function sumbitMoreInfo()
{
    if (moreInfoFormIsValid())
    {
        var url = new String(self.location)
       
        if (url.toLowerCase().indexOf("video-room.aspx") > 0)
            url = 'More-Information.aspx' 
        else
            url = '../More-Information.aspx' 

        document.getElementById("processing").style.display = ""
        document.getElementById("question").style.display = "none"
        
        jQuery.ajax({ 
            url: url,
            type: 'POST', 
            cache: false,
            async: true,
            data: getMoreInfoFormData(), 
            complete: function() { 
                document.getElementById("complete").style.display = ""
                document.getElementById("processing").style.display = "none"
                
                // unblock when remote call returns 
                setTimeout('closeMoreInfo()', 5000)
            } 
        });
    }
}


jQuery(document).ready(function(){
  jQuery("#lightwin").bind("click", function() {
    toggleSlideshow(true);
  });
})

function toggleSlideshow(hide) {
    if (document.getElementById("slideshowContainer"))
    {
        if(hide) {
            document.getElementById("slideshowContainer").style.display = "none";
            document.getElementById("slideshowBlank").style.display = "";
        }
        else {
            document.getElementById("slideshowContainer").style.display = "";
            document.getElementById("slideshowBlank").style.display = "none";
        }
    }
}