// JavaScript Document
/*function alignFooter(){
     var win_height = $(window).height();
     var footer_height = $("div.footer-color").height();
     
	 $("div.footer-color").css("top", win_height - footer_height); } 
	 
	 $(document).ready(alignFooter); 
	 
	 $(window).resize(alignFooter);*/


function print_function()
{     
	var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
	disp_setting+="scrollbars=yes,width=800, height=400, left=100, top=100";
	var content_value = document.getElementById("printarea").innerHTML;
	var content_title = document.getElementById("document-title").innerHTML;
	var main_title = document.getElementById("head-title").innerHTML;
/*	var final_title;
	if (main_title.value == ''){
		final_title = main_title+': '+content_title;
		} 
		else{
			final_title = content_title;
			}*/
	var docprint=window.open("","",disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head><title>LEA, Lebanese Epidemiological Association </title>');
	docprint.document.write('<link rel="stylesheet" type="text/css" href="styles/lea.css" media="screen" /><link rel="stylesheet" type="text/css" href="styles/lea-new.css" media="screen" /><style>.print-exclude{display:none;}</style></head><body onLoad="javascript:self.print(); self.close();">');
	docprint.document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div class="header"><img src="images/logo.gif" /></div></td></tr><tr><td style="padding:10px; background-color:#fff;font-family:Georgia, "Times New Roman", Times, serif;"><h4 style="padding:0; margin:0">'+main_title+'</h4><h3>'+content_title+'</h3></td></tr><tr><td style="padding:10px; background-color:#fff;" class="main-content">'+content_value+'</td></tr></table>');
	docprint.document.write('</body></html>');
	docprint.document.close(); 
 	docprint.focus();
}

var max_font_size = 16;
var min_font_size = 10;

$(function(){
	$('.controls a').click(function(){
		var ourText = $('.main-content, .main-content td').not(".more a");
		var currFontSize = ourText.css('fontSize');
		var finalNum = parseFloat(currFontSize, 12);
		var stringEnding = currFontSize.slice(-2);
		if(this.id == 'large') {
			if(finalNum < max_font_size) finalNum += 2;
		}
		else if (this.id == 'small'){
			if(finalNum > min_font_size) finalNum -=2;
		}
		ourText.css('fontSize', finalNum + stringEnding);
	});
});
/****************************************************** footer alignment ***************************************************/
<!--
		/*function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
		function setFooter() {
			if (document.getElementById) {
				var windowHeight = getWindowHeight();
				if (windowHeight > 0) {
					var contentHeight = document.getElementById('content').offsetHeight;
					var footerElement = document.getElementById('footer');
					var footerHeight  = footerElement.offsetHeight;
					if (windowHeight - (contentHeight + footerHeight) >= 0) {
						footerElement.style.position = 'relative';
						footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
					}
					else {
						footerElement.style.position = 'static';
					}
				}
			}
		}
		window.onload = function() {
			setFooter();
		}
		window.onresize = function() {
			setFooter();
		}*/
		//-->
/****************************************************** footer alignment ***************************************************/

var si;
$(document).ready(function(){
	$("#slideMail").hide();
	$("a#mailBtn").click(function () {
		if ($("#slideMail").is(":hidden")) {
		$("#slideMail").slideDown("slow");
		} else {
		$("#slideMail").slideUp();
		}
	});
	$("#closeMail").click(function(){
		$("#slideMail").slideUp();							   
	});
/****************************Selectbox********************/
$(".small-input select").parent().css(['background:none', 'margin:0', 'padding:0']);

/****************************Selectbox********************/

	
	/* ------- SUBMENU --------- */
	$("ul.submenu").css('display','none');
	$("a.sub").hover(function() {	
			$(this).next().slideDown("slow");
	}, function(){
			si = setTimeout(function(){ $("ul.submenu").slideUp("slow"); }, 500); 
	});
	$("ul.submenu").hover(function() {		
			clearInterval(si);
			//$(this).show();
	}, function(){
			$(this).slideUp("slow");
	});
	
	if($.browser.msie && parseInt($.browser.version+"")<8){
		$("ul.submenu").css("top", 22);
	}

});

function ValidateUsername(source, args) {
    if (MM_findObj("ControlHeader1_txtUsername").value == "" || MM_findObj("ControlHeader1_txtUsername").value == "Username" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateSTFName(source, args) {
    if (MM_findObj("ControlTools1_txtname").value == "" || MM_findObj("ControlTools1_txtname").value == "Your name" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateSTFFName(source, args) {
    if (MM_findObj("ControlTools1_txtFName").value == "" || MM_findObj("ControlTools1_txtFName").value == "Your friend name" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidatestfEmail(source, args) {
    if (MM_findObj("ControlTools1_txtEmail").value == "" || MM_findObj("ControlTools1_txtEmail").value == "Your email" )
        args.IsValid = false;
    else
      {  if (IsValidEmailAddress(MM_findObj("ControlTools1_txtEmail").value) == true)
            args.IsValid = true;
         else
            args.IsValid = false;
       }
       
}

function ValidatestfFEmail(source, args) {
    if (MM_findObj("ControlTools1_txtFEmail").value == "" || MM_findObj("ControlTools1_txtFEmail").value == "Your friend email" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateUsername2(source, args) {
    if (MM_findObj("txtUsername2").value == "" || MM_findObj("txtUsername2").value == "Username" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidatePassword(source, args) {
    if (MM_findObj("ControlHeader1_txtPass").value == "" || MM_findObj("ControlHeader1_txtPass").value == "Password" )
        args.IsValid = false;
    else
        args.IsValid = true;
}



function ValidatePassword2(source, args) {
    if (MM_findObj("txtPass2").value == "" || MM_findObj("txtPass2").value == "Password" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateCode(source, args) {
    if (MM_findObj("ControlEventRegistration1_txtCode").value == "" || MM_findObj("ControlEventRegistration1_txtCode").value == "Code" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function MM_findObj(n, d) {
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}


function ValidateName(source, args) {
    if (MM_findObj("txtName").value == "" || MM_findObj("txtName").value == "Name*" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateAbstract(source, args) {
    if (MM_findObj("RadUploadAbstractfile0").value == "" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateComments(source, args) {
    if (MM_findObj("txtComments").value == "" || MM_findObj("txtComments").value == "Write your comments here*" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidatePhone(source, args) {
    if (MM_findObj("txtPhone").value == "" || MM_findObj("txtPhone").value == "Phone" )
        args.IsValid = false;
    else
        args.IsValid = true;
}


function ValidateOrganization(source, args) {
    if (MM_findObj("txtOrganization").value == "" || MM_findObj("txtOrganization").value == "Organization" )
        args.IsValid = false;
    else
        args.IsValid = true;
}


function ValidateAddress(source, args) {
    if (MM_findObj("txtAddress").value == "" || MM_findObj("txtAddress").value == "Address" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidatePosition(source, args) {
    if (MM_findObj("txtPosition").value == "" || MM_findObj("txtPosition").value == "Position" )
        args.IsValid = false;
    else
        args.IsValid = true;
}


function ValidateEvent(source, args) {
    if (MM_findObj("ControlEventRegistration1_ddlEvents").value == "0" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

function ValidateOldPassword(source, args) {
    if (MM_findObj("txtOldPass").value == "" || MM_findObj("txtOldPass").value == "Old Password" )
        args.IsValid = false;
    else
        args.IsValid = true;
}


function ValidateNewPass(source, args) {
    if (MM_findObj("txtNewPass").value == "" || MM_findObj("txtNewPass").value == "New Password" )
        args.IsValid = false;
    else
        args.IsValid = true;
}


function ValidatePassConf(source, args) {
    if (MM_findObj("txtConfirmPass").value == "" || MM_findObj("txtConfirmPass").value == "Confirm New Password" )
        args.IsValid = false;
    else
        args.IsValid = true;
}

/* --------------------------------- CUSTOMISED DROPDOWN LIST -------------------------------- */
/****************************************************New website******************************************/
// JavaScript Document

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/************************************************Slider**********************************************/

/************************************************Slider**********************************************/
/****************************************************New website******************************************/
/********************************accordion**************************************/
$(document).ready(function(){
	$(".acccontpad").hide();
	$(".acccontpad:first").show();
	$(".accaclass:first").addClass('openarrow');
	
	if($.browser.msie && parseInt($.browser.version+"") <= 7 ){
		$("input[type=checkbox]").css('margin',0)	
		$("input[type=checkbox]").css('margin-right',5)	
	};
});

function showacc(secthead,sectcontent){
	$(secthead).slideToggle('slow');
	$(sectcontent).toggleClass('openarrow');
}
/**********************************************************************/

function IsValidEmailAddress(txt){
	if(txt !=""){ 
		var goodEmail = txt.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
		if (goodEmail){
			return true;
		} else {
			return false;
		}
	}
}
