$(function() {
	$("#dialog").dialog({
	    autoOpen: false,
		bgiframe: true,
		width: 590,
		height: 'auto',
		modal: true,
		resizable: false,
		title: "Pictures"
	});
	
});
function showPictures(imgId){
    var arrImages = document.getElementById(imgId).value.split(',');
    
    $(".pictures").html('');
    
    for (i=0; i<5; i++)
    {
        if (arrImages[i] != undefined && arrImages[i] != "")
        {
            $(".pictures").append('<table width="100%"><tr><td style="text-align:center"><img id="img'+i+'" src="" width="450px" border="0"></td></tr><tr><td style="text-align:center">&raquo;&nbsp;<a id="a'+i+'" href="" target="_blank" >display fullsize</a>&nbsp;&raquo;&nbsp;<a id="d'+i+'" href="">download fullsize</a></td></tr></table>');
            document.getElementById('img' + i).src = arrImages[i];
            document.getElementById('a' + i).href = arrImages[i];
            document.getElementById('d' + i).href = "download.php?getfile="+arrImages[i];
        }
    }
    $('#dialog').dialog('open');
}
function changepw(){
    
    $(".pictures").html('');
    var str = "<div style='margin-top: 10px;'>";
    str += '<form name="formChangePw" id="formChangePw" method="post" action="/change_pw.php" >';
    str += '<dl>';
    str += '<dt><label>Current password</label></dt>';
    str += '<dd><input type="password" name="currentpw" id="currentpw" value=""></dd>';
    str += '<dt><label>New password</label></dt>';
    str += '<dd><input type="password" id="pw1" name="pw1" value="" ></dd>';
    str += '<dt><label>Confirm password</label></dt>';
    str += '<dd><input type="password" id="pw2" name="pw2" value="" ></dd>';
    str += '<dt>&nbsp;</dt>';
    str += '<dd><input type="button" value="submit" onclick="sendNewPw(\'formChangePw\')" ></dd>';
    str += '</dl>';
    str += '</form>';
    str += '</div>';
    
    $(".pictures").append(str);
    $('#dialog').dialog('option', 'title','Change password' );
    $('#dialog').dialog('open');
}
function sendNewPw(formname){
   
    var fields = $("form[name="+formname+"] input").serializeArray();
    
    
    if ( document.getElementById('currentpw').value == "")
    {
        alert('You have to fill in your current password!')
        return false;
    }
    if ( document.getElementById('pw1').value == "")
    {
        alert('You have to fill in a new password!')
        return false;
    }
    if ( document.getElementById('pw2').value == "")
    {
        alert('You have to fill in the password check field!')
        return false;
    }
    if ( document.getElementById('pw1').value != document.getElementById('pw2').value)
    {
        alert('The new passwords doesn`t match the check password!')
        return false;
    }else{
        var pw1 = document.getElementById('pw1').value;
        if (pw1 .length < 6){
            alert('The new passwords must contain at least 6 characters!')
            return false;
        }
    }
 
//    var form = document.getElementById('formChangePw');    
//    form.action="/change_pw.php";
//    form.submit();
		
	$.ajax({
		url : "/change_pw.php",
		type : "POST",
		data : fields,
		dataType: "text",
		success : function(msg){ 
		    if (msg == ''){
		        
		        alert('Password has been changed successfully'); 
		        $('#dialog').dialog('close');
		    }
		    else
		    {
		        alert(msg); 
		        //alert('Could not change password. Try again'); 
		    }
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) { $("form[name="+formname+"]").html(errorThrown); }
	});
}
function showProject(id){
    var project = JsonProjects[id];
    $(".pictures").html('');
    var header = "<div style='margin-top: 10px;border-bottom: 1px solid #666;'>";
    header += '<p style="padding-bottom: 5px;padding:top: 5px;">Project starts at '+project['startdate']+' until '+project['enddate'] + '</p></div>';
    
    var images = "<div style='margin-top: 20px;border-top: 1px solid #666;padding-top: 10px'>";
    if (project['photo'] != ""){
        images += '<img src="'+project['photo']+'" width="80px" style="float:left;margin-right: 5px">';    
    }
    if (project['photo2'] != ""){
        images += '<img src="'+project['photo2']+'" width="80px" style="float:left;margin-right: 5px">';    
    }
    if (project['photo3'] != ""){
        images += '<img src="'+project['photo3']+'" width="80px" style="float:left;margin-right: 5px">';    
    }
    if (project['photo4'] != ""){
        images += '<img src="'+project['photo4']+'" width="80px" style="float:left;margin-right: 5px">';    
    }
    if (project['photo5'] != ""){
        images += '<img src="'+project['photo5']+'" width="80px" style="float:left;margin-right: 5px">';    
    }
    images += '</div>';

    //var description = project['projectdescription'].replace('<p>', '');    
    var description  = '<p style="padding-top: 5px;">';    
        description += '<img src="'+project['photo']+'" width="200px" style="float:left;margin-right: 5px">';
        description += '<p>'+project['projectdescription']+'</p>';    
    
    $(".pictures").append(header + description+ images);

    $('#dialog').dialog('option', 'title',project['projectcode'] );
    $('#dialog').dialog('open');
}
function showPrint(jsonObj) {
	eval('var json='+jsonObj);
    
    $(".pictures").html('');
    var printthis = '<div id="preview"><form id="formEmail" name="formEmail" method="post" ><br><ul><li><a href="#" onclick="zPrint(printen)"><img src="/pics/icon/printer.png"></a></li>';
    printthis += '<li>&raquo;&nbsp;or email to:</li>';
    printthis += '<li><input type="text" id="email" name="email" size="85" value="'+json['mail']+'" ></li>';
    printthis += '<li><input type="hidden" id="project_id" value="'+json['project_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="c_id" value="'+json['customer_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="task_id" value="'+json['task_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="p" value="'+json['p']+'" ></li>';
    printthis += '<li><a href="#" onclick="emailsend()" ><img src="/pics/icon/email_go.png"></a></li>';
    printthis += '</ul><br/></form>';
    printthis += '<iframe name="printen" id="printen" src="print_email.php?print=1&project_id='+json['project_id']+'&customer_id='+json['customer_id']+'&task_id='+json['task_id']+'&p='+json['p']+'" width="800px"; height="500px;"></iframe></div>';
    
    $(".pictures").append(printthis);
    $('#dialog').dialog('option', 'width', 850 );
    $('#dialog').dialog('option', 'title','Printing &amp; E-mail Project' );
    $('#dialog').dialog('open');
    
}


function showPrintSamples(jsonObj)
{
	eval('var json='+jsonObj);
    
    $(".pictures").html('');
    var printthis = '<div id="preview"><form id="formEmail" name="formEmail" method="post" ><br><ul><li><a href="#" onclick="zPrint(printen)"><img src="/pics/icon/printer.png"></a></li>';
    printthis += '<li>&raquo;&nbsp;or email to:</li>';
    printthis += '<li><input type="text" id="email" name="email" size="85" value="'+json['mail']+'" ></li>';
    printthis += '<li><input type="hidden" id="project_id" value="'+json['project_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="c.id" value="'+json['customer_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="samples_id" value="'+json['samples_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="p" value="'+json['p']+'" ></li>';
    printthis += '<li><a href="#" onclick="emailsamples()" ><img src="/pics/icon/email_go.png"></a></li>';
    printthis += '</ul><br/></form>';
    printthis += '<iframe name="printen" id="printen" src="print_email_samples.php?print=1&project_id='+json['project_id']+'&customer_id='+json['customer_id']+'&samples_id='+json['samples_id']+'&p='+json['p']+'" width="800" height="500"></iframe></div>';
    
    $(".pictures").append(printthis);
    $('#dialog').dialog('option', 'width', 850 );
    $('#dialog').dialog('option', 'title','Printing &amp; E-mail Samples' );
    $('#dialog').dialog('open');
}

function showPDFSamples(jsonObj)
{
	eval('var json='+jsonObj);
    
    $(".pictures").html('');
    var printthis = '<div id="preview"><form id="formEmail" name="formEmail" method="post" ><br><ul><li><a href="#" onclick="zPrint(printen)"><img src="/pics/icon/printer.png"></a></li>';
    printthis += '<li>&raquo;&nbsp;or email to:</li>';
    printthis += '<li><input type="text" id="email" name="email" size="85" value="'+json['mail']+'" ></li>';
    printthis += '<li><input type="hidden" id="project_id" value="'+json['project_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="c_id" value="'+json['customer_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="samples_id" value="'+json['samples_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="p" value="'+json['p']+'" ></li>';
    printthis += '<li><a href="#" onclick="emailsamples()" ><img src="/pics/icon/email_go.png"></a></li>';
    printthis += '</ul><br/></form>';
    printthis += '<iframe name="printen" id="printen" src="pdf_samples.php?print=1&project_id='+json['project_id']+'&customer_id='+json['customer_id']+'&samples_id='+json['samples_id']+'&p='+json['p']+'" width="800" height="500"></iframe></div>';
    
    $(".pictures").append(printthis);
    $('#dialog').dialog('option', 'width', 850 );
    $('#dialog').dialog('option', 'title','Printing &amp; E-mail Samples' );
    $('#dialog').dialog('open');
}


function displayTasks(jsonObj){

	eval('var json='+jsonObj);
	
    $(".pictures").html('');
    var printthis = '<div id="preview"><form id="formEmail" name="formEmail" method="post" ><br><ul><li><a href="#" onclick="zPrint(printen)"><img src="/pics/icon/printer.png"></a></li>';
    printthis += '<li>&raquo;&nbsp;or email to:</li>';
    printthis += '<li><input type="text" id="email" name="email" size="100" value="'+json['mail']+'" ></li>';
    printthis += '<li><input type="hidden" id="user_id" value="'+json['user_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="customer_id" value="'+json['customer_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="p" value="'+json['p']+'" ></li>';
    printthis += '<li><a href="#" onclick="emailtasks('+jsonObj+')" ><img src="/pics/icon/email_go.png"></a></li>';
    printthis += '</ul><br/></form>';
    printthis += '<iframe name="printen" id="printen" src="display_tasks.php?print=1&user_id='+json['user_id']+'&p='+json['p']+'&customer_id='+json['customer_id']+'" width="800" height="500"></iframe></div>';
    
    $(".pictures").append(printthis);
    
    $('#dialog').dialog('option', 'width', 850 );
    $('#dialog').dialog('option', 'title','Display tasks' );
    $('#dialog').dialog('open');
   
}

function displaySamples(jsonObj){

	eval('var json='+jsonObj);
	
    $(".pictures").html('');
    var printthis = '<div id="preview"><form id="formEmail" name="formEmail" method="post" ><br><ul><li></li>';
    printthis += '<li> Email to:</li>';
    printthis += '<li><input type="text" id="email" name="email" size="100" value="'+json['mail']+'" ></li>';
    printthis += '<li><input type="hidden" id="project_id" value="'+json['project_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="user_id" value="'+json['user_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="customer_id" value="'+json['customer_id']+'" ></li>';
    printthis += '<li><input type="hidden" id="p" value="'+json['p']+'" ></li>';
    printthis += '<li><input type="hidden" id="samples_id" value="'+json['samples_id']+'" ></li>';
    printthis += '<li><a href="#" onclick="emailsamples()" ><img src="/pics/icon/email_go.png"></a></li>';
    printthis += '</ul><br/></form>';
    printthis += '<div class="frame"></div>';
//    printthis += '<iframe name="printen" id="printen" src="display_samples.php?print=1&project_id='+json['project_id']+'&user_id='+json['user_id']+'&p='+json['p']+'&customer_id='+json['customer_id']+'" width="800px"; height="500px;"></iframe></div>';
    
    $(".pictures").append(printthis);
    $(".pictures .frame").load('display_samples.php?print=1&project_id='+json['project_id']+'&user_id='+json['user_id']+'&p='+json['p']+'&customer_id='+json['customer_id']+'&samples_id='+json['samples_id']+'');
    $('#dialog').dialog('option', 'width', 850 );
   // $('#dialog').dialog('option', 'height', 600 );
    $('#dialog').dialog('option', 'title','Display Samples' );
    $('#dialog').dialog('open');
    return false;  
}


function emailtasks()
{
    var mail = document.getElementById('email').value;
    var user_id = document.getElementById('user_id').value;
    var customer_id = document.getElementById('customer_id').value;
    var p = document.getElementById('p').value;
    
    
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(mail))
    {
        var form = document.getElementById('formEmail');
        form.action='/display_tasks.php?i=1&user_id='+user_id+'&p='+p+'&customer_id='+customer_id;
        form.submit();
        sendemail('formEmail','/display_tasks.php');
    }
    else
    {
        alert("Please input a valid email address!")
        return false;
    }
	
}
function zPrint(oTgt){
    oTgt.focus();
    oTgt.print();
}

function emailsend()
{
    var mail = document.getElementById('email').value;
    var project_id = document.getElementById('project_id').value;
    var customer_id = document.getElementById('c_id').value;
    var task_id = document.getElementById('task_id').value;
    var p = document.getElementById('p').value;
    
   // alert(mail + " " + customer_id + " " + project_id + " " + task_id + " " + p);
    
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(mail))
    {
        var form = document.getElementById('formEmail');
        form.action="/print_email.php?i=1&p="+p+"&customer_id="+customer_id+"&project_id="+project_id+"&task_id="+task_id;
        form.submit();
        sendemail('formEmail','/print_email.php');
	
    }
    else
    {
        alert("Please input a valid email address!")
        return false;
    }
  
}

function emailsamples()
{
    var mail = document.getElementById('email').value;
    var project_id = document.getElementById('project_id').value;
    var samples_id = document.getElementById('samples_id').value;
    var p = document.getElementById('p').value;
    
    //alert(mail + " " + customer_id + " " + project_id + " " + task_id + " " + p);
    
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(mail))
    {
        var form = document.getElementById('formEmail');
        form.action="/print_email_samples.php?i=1&p="+p+"&project_id="+project_id+"&samples_id="+samples_id;
        form.submit();
        sendemail('formEmail','/print_email_samples.php');
	
    }
    else
    {
        alert("Please input a valid email address!")
        return false;
    }
  
}

function sendemail(formname,f){
   
    var fields = $("form[name="+formname+"] input").serializeArray();
		
	$.ajax({
		url : f,
		type : "POST",
		data : fields,
		dataType: "text",
		success : function(msg){ 
		    alert('Email sent successfully'); 
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) { $("form[name="+formname+"]").html(errorThrown); }
	});
	
	return;
}




//--------------------------------------------------//
$('document').ready(function(){
	$('.recordContent table').each(function(index,item){
		if($(item).find('thead').length && $(item).find('tbody').length){
			$(item).dataTable({
				"bPaginate": false,
				"bLengthChange": false,
				"bFilter": false,
				"bSort": true,
				"bInfo": false,
				"bAutoWidth": false });
			
		}
	});
	
	
});
var _d = document;
/* Utility functions */
function addEvent(obj, evType, fn) {
  /* adds an eventListener for browsers which support it Written by Scott Andrew */
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent) {
	var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else { return false; }
}
function getWindowXY() {
  var windowX = 0, windowY = 0;
  if (self.innerHeight) {
	// all except Explorer
	windowX = self.innerWidth;
	windowY = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {
	// Explorer 6 Strict Mode
	windowX = document.documentElement.clientWidth;
	windowY = document.documentElement.clientHeight;
  } else if (document.body) {
	// other Explorers
	windowX = document.body.clientWidth;
	windowY = document.body.clientHeight;
  }
  return [ windowX, windowY ];
}
function getKey(e){
	var keycode;
	if (e == null) { // ie
		keycode = event.keyCode;
	}else if (typeof(e) == 'object') {
		keycode = e.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	return keycode;
}
// submits the given form when the enter key is hit
function enter_form(formname, evt) {
	var ekeycode = getKey(evt);
	if (ekeycode == 27)	window.close();
	else if (ekeycode == 13)	{
		if(window.opener) window.opener.timedreload();
		submitform(formname);
	}
}
function submitform(obj) {
	document.getElementById(obj).submit();
}
//----------------------swapDescription functions-------------------------------//
function swapDescriptionColumns(){
	
	
	switch($('input[name="swap"]:checked').val()){
		case '0':
			if($('.textarea[name="description"]').val()!=''){
			
				var question = confirm('If you continue all columns will be lost');
			}else{
				var question = true;
			}
			
			if(question){
			$('.columnItems').remove();
			$('.textarea[name="description"]').show().val('');
			}else{
				$('input[name="swap"]').filter('[value=1]').attr('checked',true);
			}
			
			break;
		case '1':
			addColumns();
			
			break;
	}
}
function addColumns(){
	var descriptionItem = $('.textarea[name="description"]');

	
	$(descriptionItem).before('<ul class="columnItems"></ul>');
	$('.columnItems').append('<li><input type="text" value="Item" DISABLED><input type="text" value="Color" DISABLED><input type="text" value="Quantity" DISABLED></li>');
	$(descriptionItem).hide();
	
	if($(descriptionItem).val().indexOf('[{"itemid":') == 0){
		var jsonItems = eval($(descriptionItem).val());
		$.each(jsonItems,function(index,item){
			$('.columnItems').append('<li class="columnItem"><input type="text" value="'+item.itemid+'" class="column_item"><input type="text" class="column_color" value="'+item.color+'" ><input type="text" class="column_quantity" value="'+item.quantity+'" ></li>');
		});
	}
	

	$('.columnItems').append('<li class="columnItem"><input type="text" class="column_item"><input type="text" class="column_color"><input type="text" class="column_quantity"></li>');
	
}
$('document').ready(function(){
	if($('input[name="swap"]:checked').val() == '1'){
		addColumns();
	}
	
	$('.columnItem input').live('change',function(){
		var columnItems = new Array();
		
		if($('.columnItem').last().find('.column_item').val()!=''){
			$('.columnItems').append('<li class="columnItem"><input type="text" class="column_item"><input type="text" class="column_color"><input type="text" class="column_quantity"></li>');
		}
			
		
		$('.columnItem').each(function(index,item){
			if($(item).find('.column_item').val()!= '' || $(item).find('.column_color').val()!='' || $(item).find('.column_quantity').val()!=''){
				var columnItem = new Object();
				columnItem.itemid =		$(item).find('.column_item').val();
				columnItem.color =		$(item).find('.column_color').val();
				columnItem.quantity =	$(item).find('.column_quantity').val();
				
				columnItems.push(columnItem);
			}
		});
		$('.textarea[name="description"]').val(JSON.stringify(columnItems));
		
	});
});
//---------------------------------------------------------------------------//

// reloads the page after a timeout
function timedreload() {
	var reload = function() {location.reload()}
	setTimeout(reload, 1000);
}
// This script is to maximize or minimize this system
function min_max(todo) {
	var displayValue, marginValue;
	if (!_d.getElementById) return false;
	if (todo=='max') {
		displayValue = 'none';
		marginValue = hideInfo(); //'0';
		if (_d.getElementById('minimize')) _d.getElementById('minimize').style.display = 'block';
		if (_d.getElementById('maximize')) _d.getElementById('maximize').style.display = 'none';
		hideInfo();
	} else {
		displayValue = 'block';
		if (_d.getElementById('pageBlock'))	{
			marginValue = _d.getElementById('pageBlock').style.marginLeft;
		} else {
			marginValue = hideInfo(); //'200px';
		}
		marginValue = hideInfo();
		if (_d.getElementById('minimize')) _d.getElementById('minimize').style.display = 'none';
		if (_d.getElementById('maximize')) _d.getElementById('maximize').style.display = 'block';
		hideInfo();
	}
	if (_d.getElementById('titleBlock')) _d.getElementById('header').style.display = displayValue;
	if (_d.getElementById('sysmenuBlock')) _d.getElementById('sysmenuBlock').style.display = displayValue;
	if (_d.getElementById('infoBlock'))	_d.getElementById('infoBlock').style.display = displayValue;
	if (_d.getElementById('footerBlock')) _d.getElementById('footerBlock').style.display = displayValue;
	if (_d.getElementById('pageBlock'))	_d.getElementById('pageBlock').style.marginLeft = marginValue;
	return void(0);
}

// This script is to maximize or minimize this system
function hideInfo() {
	if (!_d.getElementById) return false;
	var marginValue, info = _d.getElementById('infoBlock');
	if (!info) return false;
	if (info.style.display == 'none') {
		marginValue = '200px';
		info.style.display = 'block';
	} else {
		info.style.display = 'none';
		marginValue = '0';
	}
	/*if (_d.getElementById('pageBlock'))	_d.getElementById('pageBlock').style.marginLeft = marginValue;*/
	return marginValue; //void(0);
}

var newwindow = '';
function openWindow(url, name, w, h, menubar, scroll){
	var centerX, centerY, windowLeft, windowTop;
	if(document.getElementById) {
		centerX = parseInt(screen.width / 2);
		centerY = parseInt(screen.height / 2);
	} else {
		centerX = parseInt(screen.availWidth / 2);
		centerY = parseInt(screen.availHeight / 2);
	}
	windowLeft = centerX - parseInt(w/2);
	windowTop = centerY - parseInt(h/2);
	var parameters  = 'toolbar=no,location=no,resizable=yes,menubar=' + menubar;
	parameters += ',width=' + w + ',height=' + h + ',top=' + windowTop + ',left=' + windowLeft;
	if(scroll != null) parameters += ',scrollbars=yes';
	if (!newwindow.closed && newwindow.location) {
  		newwindow.location.href = url;
 	} else {
 		newwindow = window.open(url, name, parameters);
  		if(!newwindow.opener) newwindow.opener = self;
 	}
	if (window.focus) {newwindow.focus()}
	return false;
}
var popup = '';
function openPopup(url, name, w, h, menubar, scroll){
	var centerX, centerY, windowLeft, windowTop;
	if(document.getElementById) {
		centerX = parseInt(screen.width / 2);
		centerY = parseInt(screen.height / 2);
	} else {
		centerX = parseInt(screen.availWidth / 2);
		centerY = parseInt(screen.availHeight / 2);
	}
	windowLeft = centerX - parseInt(w/2);
	windowTop = centerY - parseInt(h/2);
	var parameters  = 'toolbar=no,location=no,resizable=yes,menubar=' + menubar;
	parameters += ',width=' + w + ',height=' + h + ',top=' + windowTop + ',left=' + windowLeft;
	if(scroll != null) parameters += ',scrollbars=yes';
	if (!popup.closed && popup.location) {
  		popup.location.href = url;
 	} else {
 		popup = window.open(url, name, parameters);
  		if(!popup.opener) popup.opener = self;
 	}
	if (window.focus) {popup.focus()}
	return false;
}

// This script is to auto tab to the next field
function autoTab(currentField, form, size) {
	if (currentField.value.length == size) {
		for (x=0; x<form.elements.length; x++) {
			if (form.elements[x].name == currentField.name) {
				form.elements[x+1].focus();
				break;
			}
		}
	}
}

// This script is give each second the date and time
function setTimeDate() {
	var t=new Date();
	var y = t.getFullYear();
	var m = ''+(t.getMonth()+1);
	if (m.length==1) m='0'+m;
	var d = ''+t.getDate();
	if (d.length==1) d='0'+d;
	var h = ''+t.getHours();
	if (h.length==1) h='0'+h;
	var n = ''+t.getMinutes();
	if (n.length==1) n='0'+n;
	var s = ''+t.getSeconds();
	if (s.length==1) s='0'+s;
	var td = d+"-"+m+"-"+y+" "+h+":"+n+":"+s;
	document.getElementById('datetime').innerHTML=td;
	window.setTimeout("setTimeDate();",1000);
}

function cssjsrecord(id) {
	var node, nodeClass, cN, i;
	var returnvalue = true;
	var parent = document.getElementById(id);
	if (parent) {
		var nodes = parent.getElementsByTagName('tr');
		if(nodes) {
			for (i = 0; i < nodes.length; i++) {
				node = nodes[i];
				if(node.className=='rTp' || node.className=='rTn') {
					// onmouseover function
					node.onmouseover = function (e) {
						cN = this.className;
						this.className = cN+'hover';
						return void(0);
					};
					node.onmouseout = function (e) {
						cN = this.className;
						this.className = cN.substring(0, cN.lastIndexOf('hover'));
						return void(0);
					};
				}
			}
		}
	} else {
		returnvalue = false;
	}
	return returnvalue;
}

function set_efCMSsize() {
	var windowSize = getWindowXY();
	var elmB = document.getElementById('body');
	var elmN = document.getElementById('folderList');
	var elmC = document.getElementById('contentBlock');
	var windowH = windowSize[1] - 44;
	if(elmB) elmB.style.height = windowH+'px';
	if(elmN) elmN.style.height = windowH+'px';
	if(elmC){
		windowH = windowSize[1] - 168;
		//elmC.style.height = windowH+'px';
	}
}
//addEvent(window, 'load', set_efCMSsize);
//addEvent(window, 'resize', set_efCMSsize);
