//Main JavaScript Document

$(document).ready(function(){
	
	$('#nav li').mouseenter(function(){
		$(this).addClass('current-item');
		}).mouseleave(function(){
			$(this).removeClass('current-item');
			});
	
	 //Placeholder 
	   jQuery('#TestId').placeHolder({
		 "text"           : "Enter test ID",
		 "active"         : "#000",
		 "placeholder"    : "#333"
	  });
	  
	  jQuery("#testID").placeHolder({
		 "text"           : "Enter test ID",
		 "active"         : "#000",
		 "placeholder"    : "#333"
	  });
	  
	   jQuery("#transcriptID").placeHolder({
		 "text"           : "Enter a Transcript #",
		 "active"         : "#434343",
		 "placeholder"    : "#434343"
	  }); 
	// Add classes and properties where needed
	$('.testimonial:last').addClass('last');
	//$('#content.homepage .main-content .homebox:nth-child(odd)').addClass('oddBlock');


	// Add more padding to last nav item to fill the remaining spce
	var menuBlockWidth = $('#menu').width();
	var itemsWidth = 0;
	
	$('#nav > li').each(function(){
		itemsWidth = itemsWidth + $(this).width() + 5;
	});

    var paddingForItem = menuBlockWidth-itemsWidth;
    var padding = (paddingForItem)/2;

	//$('#nav > li:last > a').css({'width': $('#nav > li:last > a').width() + paddingForItem ,'text-align':'center' });


	// Toggle Subtopic List
	
	$('#content ul.subtopics ul').hide();
	
	$('#content ul.subtopics a').click (function() {
		 
		 if($(this).html() == '+') {
		   $(this).html('-').parent().find('ul').toggle();
		 }
		 else {
		   $(this).html('+').parent().find('ul').toggle(); 
		 }
	});
	
	// Remove href attr for current pagination item
	
	$('.pagination a').each( function() {
	  if ($(this).hasClass('disable') || $(this).hasClass('current') ) {
		$(this).removeAttr('href');
	  }
	});




 






  	//Vertical and horisontal aligning for 
    $('#content.homepage ul.sidebarBtns li a span').vAlign();
	$('.our-customers .wrap ul').hAlign();
	$('.our-customers .wrap ul li').vAlign();
	
	$('.slider-info span.wrap').vAlign();
	
	
});

// Javascript functions
var notShown=true;
function moreLess () {
if (notShown) {
document.getElementById('invisible').style.display="block";
document.getElementById('readMore').innerHTML = "<a href='javascript:void(0)' style='font-weight:bold; text-decoration:none; color:#073d4f;' class='btn-more' onclick='javascrit: moreLess();'>&laquo; less</a>";
notShown=false;
}
else {
document.getElementById('invisible').style.display="none";
document.getElementById('readMore').innerHTML="<a href='javascript:void(0)' style='font-weight:bold; text-decoration:none; color:#073d4f;' class='btn-more' onclick='javascrit: moreLess();'>more &raquo;</a>";
notShown=true;
}
}
function popupDiploma(id)
{
window.open('http://www.eskill.com/certified/diploma/diploma'+id+'.html', 'dummy','dependent,height=669,width=900');
}
function slideSwitch() {
var $txtactive = $('table.new_spotline .txtArea p.spottxt.active');
var $authoractive = $('table.new_spotline .authorArea p.author.active');
var $nextTxt = $txtactive.next().length ? $txtactive.next()
: $('table.new_spotline .txtArea p.spottxt:first');
var $nextAuth = $authoractive.next().length ? $authoractive.next()
: $('table.new_spotline .authorArea p.author:first');
$nextTxt.addClass('active');
$nextAuth.addClass('active');
$txtactive.removeClass('active');
$authoractive.removeClass('active');
}
function tabs() {
$('.tabs-holder .questionMain').hide();
$('.tabs-holder .questionHead').click(
function(event) {
event.preventDefault();
if($(this).hasClass('current')){
$(this).removeClass('current');
$(this).next().slideUp();
}
else {
$(this).addClass('current');
$(this).next().slideDown('normal');
};
})
}
function toggle(val){
document.getElementById("maintxt").style.visibility=val;
}
function popupUsage()
{
window.open('terms_usage.html', 'dummy',
'status,resizable,scrollbars=yes,height=470,width=600');
}
function popupPrivacy()
{
window.open('privacy_policy.html', 'dummy',
'status,resizable,scrollbars=yes,height=470,width=600');
}
var openedWin = null;
var wpercent = 100;
function launch(){
var args = launch.arguments
var url = args[0]
var width = args[1]
var height = args[2]
if (!url || !width || !height) {
alert("Error");
} else {
var scr_w = screen.availWidth
var scr_h = screen.availHeight
var target_w = 0
var target_h = 0
wpercent = 100
if(width >= scr_w || height >= scr_h){
p = 100;
if (height >= scr_h)
{
p = (scr_h * .9) / height;
}
else
{
p = (scr_w * .9) / width;
}
width = Math.round(p * width);
height = Math.round(p * height);
wpercent = Math.round(p * 100);
}
_launch(url, width, height, args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
}
}
function _launch(){
closeChild()
var args = _launch.arguments
var url = args[0]
var width = args[1]
var height = args[2]
var resizable = args[3] ? "yes" : "no"
var scrollbars = args[4] ? "yes" : "no"
var toolbar = args[5] ? "yes" : "no"
var menubar = args[6] ? "yes" : "no"
var status = args[7] ? "yes" : "no"
var address = args[8] ? "yes" : "no"
var directories = args[9] ? "yes" : "no"
var NewX = Math.max(0, Math.floor((screen.availWidth-(width+8))/2));
var NewY = Math.max(0, Math.floor((screen.availHeight-(height+27))/2));
var params = ''
params += "width="+width // 1
params += ",height="+height // 2
params += ",screenx="+NewX
params += ",screeny="+NewY
params += ",left="+NewX
params += ",top="+NewY
params += ",resizable="+resizable // 3
params += ",scrollbars="+scrollbars // 4
params += ",toolbar="+toolbar // 5
params += ",menubar="+menubar // 6
params += ",status="+status // 7
params += ",location="+address // 8
params += ",directories="+directories // 9
openedWin = window.open(url, "demodashboard", params);
}
function closeChild () {
if (openedWin != null) {
if (!openedWin.closed) {
openedWin.close();
}
}
}
onunload = closeChild;
function viewReportLocalized(format, reportName, reportParam, locale)
{
window.open('http://report.eskill.com/birt/run?__report='+reportName+'.rptdesign&__locale='+locale+'&__format='+format+reportParam,
'dummy', 'dependent,status,resizable,scrollbars=yes,height=600,width=800');
}
function viewReport(format, reportName, reportParam)
{
window.open('http://report.eskill.com/birt/run?__report='+reportName+'.rptdesign&__format='+format+reportParam,
'dummy', 'dependent,status,resizable,scrollbars=yes,height=600,width=800');
}
/***********************************************************************/
// Vertical Align function
 $.fn.vAlign = function() {
        return this.each(function(i){
        var ah = $(this).height();
        var ph = $(this).parent().height();
        var mh = (ph - ah) / 2;
        $(this).css('margin-top', mh);
        });
 };
 
 
 // Horizontally Align function
$.fn.hAlign = function() {
	return this.each(function(i){
	var ah = $(this).width();
	var ph = $(this).parent().width();
	var mh = (ph - ah) / 2;
	$(this).css('margin-left', mh);
	});
};

//agree to terms
function removeDisabled() {
	document.getElementById("submit").removeAttribute("disabled")
    
}

// show additional information if don't agree

function showDiv(div_id) {
    var browserType;

    if (document.layers) {browserType = "nn4"}
    if (document.all) {browserType = "ie"}
    if (window.navigator.userAgent.toLowerCase().match("gecko")) {
        browserType= "gecko"
    }
    if (browserType == "gecko" )
        document.poppedLayer =
        eval('document.getElementById(div_id)');
    else if (browserType == "ie")
        document.poppedLayer =
        eval('document.getElementById(div_id)');
    else
        document.poppedLayer =
        eval('document.layers[div_id]');
    document.poppedLayer.style.visibility = "visible";
}

// refresh visibility of form buttons

function refreshAgree(agreeTerm1){
	if(agreeTerm1 == 'Y'){
		document.accountPurchaseForm.agreeTerms.value = true;
		document.accountPurchaseForm.submit.disabled = false;
		document.accountPurchaseForm.agree.disabled = true;
		/*showDiv('agreeDisabled');
		hideDiv('agreeEnabled');*/
		removeDisabled();
	}
	else{
		document.accountPurchaseForm.agreeTerms.value = false;
		document.accountPurchaseForm.submit.disabled = true;
		document.accountPurchaseForm.agree.disabled = false;
		/*hideDiv('agreeDisabled');
		showDiv('agreeEnabled');*/
	}
} 

// close popup button

function closeWindow(){
	for (var i=0; i < document.agreeForm.agreeOption.length; i++){
		if (document.agreeForm.agreeOption[i].checked){
			self.opener.refreshAgree(document.agreeForm.agreeOption[i].value);
		}
	}
	self.close();
}

// show additional information if don't agree

function dontAgree(){
	showDiv('dontAgreeMessage');
} 


/*
jQuery Placeholder Plugin
Author: Eymen Gunay
Web: http://www.egunay.com/
*/
(function( $ ){
$.fn.placeHolder = function(options) {
var eo = this;
var settings = {
'text' : 'Placeholder',
'placeholder' : '#999',
'active' : '#000'
};
return this.each(function() {
if ( options ) {
$.extend( settings, options );
}
eo.val(settings.text);
eo.css("color", settings.placeholder);
eo.focus(function() {
if(eo.val() == settings.text) {
eo.css("color", settings.active);
eo.val("");
}
});
eo.focusout(function() {
$("#search_box img").css("display","none");
if(eo.val() == "" || eo.val() == settings.text) {
eo.val(settings.text);
eo.css("color", settings.placeholder);
}
});
});
};
})( jQuery );
