// JavaScript Document
$(document).ready(function(){
	
	
	$('.error').hide();
    $(".submitButton").click(function() {
		// validate and process form here
		$('label').removeClass("curFocus");

  	  	var nameText = $("input#name").val();
  		if (nameText == "") {
        $("div#name_error").show();
        $("input#name").focus();
        return false;
      }
		var emailText = $("input#email").val();
  		if (emailText == "") {
        $("div#email_error").show();
        $("input#email").focus();
        return false;
      }
  		var programSelect = $("select#program").val();
  		if (programSelect == "-Select-") {
        $("div#program_error").show();
        $("select#program").focus();
        return false;
      }
		var schoolSelect = $("select#school").val();
  		if (schoolSelect == "-Select-") {
        $("div#school_error").show();
        $("select#school").focus();
        return false;
      }
		var gradDateText = $("input#gradDate").val();
  		if (gradDateText == "") {
        $("div#gradDate_error").show();
        $("input#gradDate").focus();
        return false;
      }
      
      
		
    });
	
//	$("input[@type=text], textarea, select").focus(function() {
//		 $('label').removeClass("curFocus");		 
//		$(this).parent('label').addClass("curFocus");
//	});
//	$("input[@type=text], textarea, select").blur(function() {
//		$(this).parent('label').removeClass("curFocus");
//	});
//	$("input[@type=radio]").click(function() {
//		$('label').removeClass("curFocus");		 
//		$('input[@type=radio]').parent('label').addClass("curFocus");
//	});
//	$("input[@type=checkbox]").click(function() {
//		$('label').removeClass("curFocus");	
//		$('input[@type=checkbox]').parent('label').addClass("curFocus");
//	});
	

});

function ShowHideSection(sectionName) {
    //alert(sectionName);
    var section = document.getElementById(sectionName);
    if (!section) {
        alert('element not found:' + sectionName);
        return;
    }
    var isDisplayed = section.style.display != "none";
    if (isDisplayed) {
        section.style.display = "none";
    }
    else {
        section.style.display = "block";
    }
   }

// Call this function if the initial state of the item is Open
   function DashboardHideShowSection(sectionName, iconImage) {
   	var section = document.getElementById(sectionName);
   	var collapseIcon = document.getElementById("collapse-" + iconImage);
   	var expandIcon = document.getElementById("expand-" + iconImage);
   	if (!section) {
   		alert('element not found:' + sectionName);
   		return;
   	}
   	if (section.style.display != "none") {
   		section.style.display = "none";
   		collapseIcon.style.display = "none";
   		expandIcon.style.display = "block";
   	} else {
    	section.style.display = "block";
    	collapseIcon.style.display = "block";
    	expandIcon.style.display = "none";
   	}
   }
// Call this function if the initial state of the item is Closed
   function DashboardShowHideSection(sectionName, iconImage) {
   	var section = document.getElementById(sectionName);
   	var collapseIcon = document.getElementById("collapse-" + iconImage);
   	var expandIcon = document.getElementById("expand-" + iconImage);
   	if (!section) {
   		alert('element not found:' + sectionName);
   		return;
   	}
   	if (section.style.display != "block") {
   		section.style.display = "block";
   		collapseIcon.style.display = "block";
   		expandIcon.style.display = "none";
   	} else {
   		section.style.display = "none";
   		collapseIcon.style.display = "none";
   		expandIcon.style.display = "block";
   	}
   }


function swapImage(idName)	{
	var onIDName = idName + "On";
	if(document.getElementById(idName)) {
		document.getElementById(idName).id = onIDName;
	} else {
		document.getElementById(onIDName).id = idName;
	}
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function deleteCookie(name) {
    document.cookie = name +
'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}


function setTabView() {
        // switch the tab view using a passed parameter from the url
        
        // get url of page
        var b = window.location;
        // convert location object to a string
        var c = eval(new String(b));
        // find substring after the hash mark
        var d = c.lastIndexOf('#');
        var thisView = "";
        if (d != -1) {
            thisView = c.substring(d + 1);
        }

        //When page loads
        $(".tab-content").hide(); //Hide all content
        // If no parameter is passed, show first panel by default
        if (thisView == "") {
            $("ul.tabs li:first").addClass("active").show(); //Activate first tab
            $(".tab-content:first").show();                  //Show first tab content
            // if there was a parameter passed, show the requested panel
        } else {
            $("ul.tabs li:has(a[href=#" + thisView + "])").addClass("active").show(); //Activate requested tab
            $("#" + thisView).show();                                                 //Show requested tab content
        }
        
        //On Click Event
        $("ul.tabs li").click(function() {

            $("ul.tabs li").removeClass("active"); //Remove any "active" class
            $(this).addClass("active"); //Add "active" class to selected tab
            $(".tab-content").hide(); //Hide all tab content

            var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
            $(activeTab).fadeIn(); //Fade in the active ID content
            return false;
        });

    }
