// JavaScript Document
	function getDivByID(layerID) {
		if (document.getElementById) {
			// this is the way the standards work
			return document.getElementById(layerID);
		} else if (document.all) {
			// this is the way old msie versions work
			return document.all[layerID];
		} else if (document.layers){
			// this is the way nn4 works
			return document.layers[layerID];
		}
		return null;
	}
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	function ltrim(stringToTrim) {
		return stringToTrim.replace(/^\s+/,"");
	}
	function rtrim(stringToTrim) {
		return stringToTrim.replace(/\s+$/,"");
	}
	function isAlphaNumeric(val){
		if (val.match(/^[a-zA-Z0-9]+$/)){
			return true;
		}else{
			return false;
		} 
	}
	function fncCheckEmailFormat(strEmail){
		emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
		if(!emailpat.test(strEmail)) return false; else return true;
	}
	function __fncGetXMLHttpRequest(){
		var http_request = false;
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType('text/html');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) {
			return false;
		}
		return http_request;
	}
	function __fncLoadFullBookSetDetails(bookSet){
		if(getDivByID('divSetDetails'+bookSet).style.display=='block'){
			getDivByID('divSetDetails'+bookSet).style.display='none';
			return;
		}else{getDivByID('divSetDetails'+bookSet).style.display='block'}
		xmlHttp = __fncGetXMLHttpRequest();
		xmlHttp.onreadystatechange=function() {
			if(xmlHttp.readyState==4){
				if (xmlHttp.status == 200) {
					getDivByID('divSetDetails'+bookSet).innerHTML=xmlHttp.responseText;
				}
			}
		}
		xmlHttp.open("GET","./Ajax/__Text.Book.Set.Details.php?set="+bookSet,true);
		xmlHttp.send(null);
	}
	function isAlpha(val){
		if (val.match(/^[a-z A-Z]+$/)){
			return true;
		}else{
			return false;
		} 
	}
	function isAccademic(val){
		if (val.match(/^[1-9]{1}\d{3}\-[1-9]{1}\d{3}$/)){
			return true;
		}else{
				return false;
		} 
	}
	
	//print 
	function popup() { 
	  //var contentHTML = document.getElementById('PrintContent').innerHTML;
	  //var winPopup = writeConsole();
	
	 var con = '<div id=\"placeHolder\" align=\"center\">'+ contentHTML +'</div>';
	 top.consoleRef=window.open('','placeHolder',
	  'width=850,height=800'
	   +',left=500'
	   +',top=300'
	   +',menubar=0'
	   +',toolbar=0'
	   +',status=0'
	   +',scrollbars=1'
	   +',resizable=1')
	 top.consoleRef.document.writeln(
	  '<html><head><style type="text/css"> td{ font-family:Arial, Helvetica, sans-serif; font-size:11px;} th{ font-family:Arial, Helvetica, sans-serif; font-size:11px;}</style><title>Content Pop-Up</title><script type=\"text/javascript\" language=\"JavaScript\">var timerDelay; function showIt(){document.getElementById(\'placeHolder\').innerHTML = window.opener.contentHTML; timerDelay = window.setTimeout(\"window.print()\",1000);}<\/script></head>'
	   +'<body onLoad="showIt()">'
	   +con
	   +'</body></html>'
	 )
	 top.consoleRef.document.close()
	}
		
	function release() {
	  var contentReleaseHTML = document.getElementById('PrintReleas').innerHTML;
	  //var winPopup = writeConsole();
	  
	 var con = '<div id=\"placeRelease\" align=\"center\">'+ contentReleaseHTML +'</div>';
	 top.consoleRef=window.open('','placeRelease',
	  'width=800,height=800'
	   +',left=500'
	   +',top=300'
	   +',menubar=0'
	   +',toolbar=0'
	   +',status=0'
	   +',scrollbars=0'
	   +',resizable=1')
	 top.consoleRef.document.writeln(
	  '<html><head><style type="text/css"> td{ font-family:Arial, Helvetica, sans-serif; font-size:11px;} th{ font-family:Arial, Helvetica, sans-serif; font-size:11px;}</style><title>Content Pop-Up</title><script type=\"text/javascript\" language=\"JavaScript\">var timerDelay; function showIt(){timerDelay = window.setTimeout(\"window.print()\",1000);}<\/script></head>'
	   +'<body onLoad="showIt()">'
	   +con
	   +'</body></html>'
	 )
	 top.consoleRef.document.close()
	}
		function displayCalendar(inputField,format,buttonObj,displayTime,timeInput)
		{
			if(displayTime)calendarDisplayTime=true; else calendarDisplayTime = false;
			if(inputField.value.length>0){
				
				if(!format.match(/^[0-9]*?$/gi)){
					var items = inputField.value.split(/[^0-9]/gi);
					var positionArray = new Array();
					positionArray['m'] = format.indexOf('mm');
					if(positionArray['m']==-1)positionArray['m'] = format.indexOf('m');
					positionArray['d'] = format.indexOf('dd');
					if(positionArray['d']==-1)positionArray['d'] = format.indexOf('d');
					positionArray['y'] = format.indexOf('yyyy');
					positionArray['h'] = format.indexOf('hh');
					positionArray['i'] = format.indexOf('ii');
					
					var positionArrayNumeric = Array();
					positionArrayNumeric[0] = positionArray['m'];
					positionArrayNumeric[1] = positionArray['d'];
					positionArrayNumeric[2] = positionArray['y'];
					positionArrayNumeric[3] = positionArray['h'];
					positionArrayNumeric[4] = positionArray['i'];
					
					
					positionArrayNumeric = positionArrayNumeric.sort(calendarSortItems);
					var itemIndex = -1;
					currentHour = '00';
					currentMinute = '00';
					for(var no=0;no<positionArrayNumeric.length;no++){
						if(positionArrayNumeric[no]==-1)continue;
						itemIndex++;
						if(positionArrayNumeric[no]==positionArray['m']){
							currentMonth = items[itemIndex]-1;
							continue;
						}
						if(positionArrayNumeric[no]==positionArray['y']){
							currentYear = items[itemIndex];
							continue;
						}	
						if(positionArrayNumeric[no]==positionArray['d']){
							tmpDay = items[itemIndex];
							continue;
						}	
						if(positionArrayNumeric[no]==positionArray['h']){
							currentHour = items[itemIndex];
							continue;
						}	
						if(positionArrayNumeric[no]==positionArray['i']){
							currentMinute = items[itemIndex];
							continue;
						}	
					}
		
					currentMonth = currentMonth / 1;
					tmpDay = tmpDay / 1;
				}else{		
					var monthPos = format.indexOf('mm');
					currentMonth = inputField.value.substr(monthPos,2)/1 -1;	
					var yearPos = format.indexOf('yyyy');
					currentYear = inputField.value.substr(yearPos,4);		
					var dayPos = format.indexOf('dd');
					tmpDay = inputField.value.substr(dayPos,2);		
					
					var hourPos = format.indexOf('hh');
					if(hourPos>=0){
						tmpHour = inputField.value.substr(hourPos,2);	
						currentHour = tmpHour;
					}else{
						currentHour = '00';
					}
					var minutePos = format.indexOf('ii');
					if(minutePos>=0){
						tmpMinute = inputField.value.substr(minutePos,2);	
						currentMinute = tmpMinute;
					}else{
						currentMinute = '00';
					}	
				}
			}else{
				var d = new Date();
				currentMonth = d.getMonth();
				currentYear = d.getFullYear();
				currentHour = '08';
				currentMinute = '00';
				tmpDay = d.getDate();
			}
			
			inputYear = currentYear;
			inputMonth = currentMonth;
			inputDay = tmpDay/1;
			
			
			if(!calendarDiv){
				initCalendar();			
			}else{
				if(calendarDiv.style.display=='block'){
					closeCalendar();
					return false;
				}
				writeCalendarContent();
			}	
			returnFormat = format;
			returnDateTo = inputField;
			positionCalendar(buttonObj);
			calendarDiv.style.visibility = 'visible';	
			calendarDiv.style.display = 'block';	
			if(iframeObj){
				iframeObj.style.display = '';
				iframeObj.style.height = '140px';
				iframeObj.style.width = '195px';
						iframeObj2.style.display = '';
				iframeObj2.style.height = '140px';
				iframeObj2.style.width = '195px';
			}
			
			setTimeProperties();	
			updateYearDiv();
			updateMonthDiv();
			updateMinuteDiv();
			updateHourDiv();
			
		}
