var loc  = window.location.href;
var arr = loc.split('?');
var nav = 0;
if (arr.length > 1 && arr[1].search(/nav=1/) >= 0) nav = 1;
var biz_url = "/htm-webaxy";
var windowHeight;
var msgsHeight;

GetHeight();

function GetHeight()
{
        if (self.innerHeight)
        {
                windowHeight = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                windowHeight = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                windowHeight = document.body.clientHeight;
        }

}

//------------- click Admin -----------------
function getCookieHash(cookieName) {
	var search = cookieName + "=";
	var valueOffset = 0;
	var valueEnd = 0;
	var cookieValue='';
	var cookie = document.cookie;
	var cookieHash= new Object();
	valueOffset = cookie.indexOf(search);
	if (valueOffset != -1){// if cookie exists 
		valueOffset += search.length;// set index of beginning of value
		valueEnd = cookie.indexOf(";", valueOffset);// set index of end of cookie value
		if (valueEnd == -1) {valueEnd = cookie.length;}
		cookieValue = unescape(cookie.substring(valueOffset, valueEnd));
	}
	if(cookieValue !=''){
		arrTmp=cookieValue.split('&');
		for(var i=0; i<arrTmp.length; i+=2){cookieHash[arrTmp[i]]=arrTmp[i+1]?arrTmp[i+1]:'';}
		return cookieHash;
	}
	else{	return '';}
}

var editAlow = "", alowToEdit = 0;
if(window.bizID){
	var webaxyCookie=getCookieHash('webaxylogin_'+bizID);
	if (webaxyCookie['clickadmin']=='1'){alowToEdit = 1;}
}
//---------------------------------------------------

var mydate = new Date();
var year=mydate.getYear();
if (year < 1000)year+=1900;
var day=mydate.getDay();
var month=mydate.getMonth();
month++
if (month<10)month="0"+month;
var daym=mydate.getDate();
if (daym<10)daym="0"+daym;

var theDate=year+''+month+''+daym;
theDate*=1;
//----------------------------------
function goLink(iBoard) {
	var board = window.boards[iBoard];
	var messageLink = board.messages[board.message_idx].Link;
	var messageTarget = board.messages[board.message_idx].Target;
	if ((messageLink!='') && (messageLink!='JavaScript: return false;')) {
		if(a = document.getElementById("linkContent"+iBoard)){
			a.href = messageLink;
			a.target = messageTarget;
			a.click();
		}
		else{
			f = document.getElementById("linkForm"+iBoard);
			if(messageLink.search(/\?/)!=-1){
				theURL=messageLink.replace(/\?.*$/,"");
				CGI=ParseData(messageLink);
				//alert(" link="+messageLink+";\n theURL="+theURL+";\n par="+CGI+";");
				f.innerHTML="";
				var param='';
				for (i=0; i<CGI.length; i++){
					param =param+'<input type="hidden" name="'+CGI[i].name+'" value="'+decodeURIComponent(CGI[i].data).replace(/\"/g,"&quot;")+'">';
					if(CGI[i].data==''){
						f.innerHTML='<a id="linkContent'+iBoard+'" href="'+theURL+'?'+unescape(CGI[i].name)+'" target="'+messageTarget+'"></a>';
						document.getElementById("linkContent"+iBoard).click();
						return false;
					}
				}
				f.innerHTML=param;
			}
			else{
				f.innerHTML="";
				theURL=messageLink;
			}
			f.action = theURL;
			f.target = messageTarget;
			f.submit();
		}
	}
}
//--------------------------------------
function mouseIn(iBoard) {
	var board = window.boards[iBoard];
	var messageLink = board.messages[board.message_idx].Link;
	if(messageLink != ""){
		runContent = document.getElementById("content"+iBoard);
	}
}
//------------------------------
function mouseOut(){
	window.status = "";
}
//---------------------------------------
function stopBoard(iBoard) {
	window.boards[iBoard].Run = false;
}
//-------------------------------------
function runBoard(iBoard) {
	window.boards[iBoard].Run = true;
	if( window.boards[iBoard].messages.length>0 ){
		for(ii=0; ii < window.boards[iBoard].messages.length; ii++){
			var m = window.boards[iBoard].messages[ii];
			
			if (!m.weekDaysShow) {
				m.weekDaysShow = new Array(1,1,1,1,1,1,1);
			}
			if(! m.weekDaysShow[day]){window.boards[iBoard].messages.splice(ii,1);ii--}
			else{
				if(getDateYYYYMMDD(m.dateOn)){mesDateOn=getDateYYYYMMDD(m.dateOn);}
				else{mesDateOn=0}
				if(getDateYYYYMMDD(m.dateOff)){mesDateOff=getDateYYYYMMDD(m.dateOff);}
				else{mesDateOff=30001231;}
//				alert('mes:'+ii+'; theDate='+theDate+'; mesDateOn='+mesDateOn+'; mesDateOff='+mesDateOff+';');
				if(!(theDate >= mesDateOn && theDate <= mesDateOff) ){window.boards[iBoard].messages.splice(ii,1);ii--}
			}
		}
	}
		
	if( window.boards[iBoard].messages.length>0 ){
//		try {
			if(window.boards[iBoard].randomize) {
				window.boards[iBoard].messagesTMP = new Array();
				var randomIndxStr=';';
				var randomIndxMAX=window.boards[iBoard].messages.length-1;
				for(indx=0; indx < window.boards[iBoard].messages.length; indx++){
					randomIndx=Math.round(Math.random() * randomIndxMAX);
					while( randomIndxStr.search(";"+randomIndx+";") != -1 ){
						randomIndx=Math.round(Math.random() * randomIndxMAX);
					}
					randomIndxStr+=randomIndx+';';
					window.boards[iBoard].messagesTMP.push(window.boards[iBoard].messages[randomIndx]);
				}
//				alert(randomIndxStr);
				window.boards[iBoard].messages=null;
				window.boards[iBoard].messages=window.boards[iBoard].messagesTMP;
				window.boards[iBoard].messagesTMP=null;
			}
			startNav(i);
			if (document.getElementById("dhtmlnews-nav_full_td")) beforeRunMessage(iBoard,0);
			else runMessage(iBoard,0);
//		}
//		catch(e) {}
		
		//runMessage(iBoard,0);
	}
}

function beforeRunMessage(iBoard,start) {
	
		if (document.getElementById("dhtmlnews-nav_full_td").clientHeight) {
			runMessage(iBoard,start);
			if (windowHeight && document.getElementById('dhtmlnews-main_full_table')) {
				document.getElementById('dhtmlnews-main_full_td').style.height = (windowHeight-document.getElementById("dhtmlnews-nav_full_td").clientHeight)+'px';
			}	
		}
		else window.setTimeout("beforeRunMessage("+iBoard+","+start+")",50);		
	
}
//------------------------------------------------------------
function runMessageAfterPause(iBoard, iMessage, checkRun) {
	var board = window.boards[iBoard];
	if (checkRun && !board.Run) return;
	var runContent = document.getElementById("content"+iBoard);
	runContent.innerHTML = '<br/>';
	setTimeout("runMessage("+iBoard+","+iMessage+")", board.pauseBetween*1000);
}
//------------------------------------------------------------
function runMessage(iBoard, iMessage, checkRun) {
	var board = window.boards[iBoard];
	if (checkRun && !board.Run) return;
	window.boards[iBoard].message_idx = iMessage;
   	var message = board.messages[iMessage];
	var nexti = (parseInt(iMessage)+1) % board.messages.length;
	var runContent = document.getElementById("content"+iBoard);	
	if (board.boxType == 'full') runContent.style.overflow = "auto";
	else runContent.style.overflow = "hidden";
	//var innerHeight = (board.Height-(2*message.BorderWidth))
	//var innerWidth = (board.Width-(2*message.BorderWidth))
	
	if ((message.Msg == "") || (message.Msg == undefined) || (alowToEdit == 1 && message.EditMsg == 0) ) {
		if ((message.Title) && (message.Title != "")) {
			message.TitleText = message.Title;
		}
		var final_message = ''
		if( message.Image != ''){
			if( message.Image.match(/^<img/i) ){
				final_message = message.Image+message.Text;
			}
			else if( message.imgAlign == "right" || message.imgAlign == "left" ){	
				final_message = "<img src='"+message.Image+"' align='"+message.imgAlign+"' "+message.imgWidth+" border='0' vspace='0' hspace='0'>"+message.Text;
			}
			else if( message.imgAlign == "top" ){
				final_message = message.Text+"<img src='"+message.Image+"' align='"+message.imgAlign+"' "+message.imgWidth+" border='0' vspace='0' hspace='0'>";
			}
			else if( message.imgAlign == "bottom" ){
				final_message = "<img src='"+message.Image+"' align='"+message.imgAlign+"' "+message.imgWidth+" border='0' vspace='0' hspace='0'><br>"+message.Text;
			}
			else{
				final_message = "<img src='"+message.Image+"' "+message.imgWidth+" border='0' vspace='0' hspace='0'>"+message.Text;
			}
		}
		else
			final_message = message.Text;
			
		
		if(message.hideTitle){
			message.TitleText="";
		}
		else{
			if( message.TitleText ) {
				/*if (typeof(message.BorderWidth) == 'number') message.BorderWidth += 'px';
				else if (typeof(message.BorderWidth) == 'string' && message.BorderWidth.search(/px$/) == -1) message.BorderWidth += 'px';*/
				if (typeof(message.TitleSize) == 'number') message.TitleSize += 'px';
				else if (typeof(message.TitleSize) == 'string' && message.TitleSize.search(/px$/) == -1) message.TitleSize += 'px';
				//message.TitleText ="<table cellpadding='0' cellspacing='0' border='0' style=\"width: 100%; border-bottom: "+message.BorderWidth+" solid "+message.BorderColor+";\"><tr><td align="+message.TitleAlign+" style='background-color:"+(message.TitleBgcolor?message.TitleBgcolor:'#ffffff')+" '>"+message.TitleBold+"<font color="+message.TitleFgcolor+" face="+message.TitleFamily+" style='font-size : "+message.TitleSize+";'>"+message.TitleText+"</font></b></td></tr></table>";
				message.TitleText ="<table cellpadding='0' cellspacing='0' border='0' style=\"width: 100%;\"><tr><td align="+message.TitleAlign+" style='background-color:"+(message.TitleBgcolor?message.TitleBgcolor:'#ffffff')+" '>"+message.TitleBold+"<font color="+message.TitleFgcolor+" face="+message.TitleFamily+" style='font-size : "+message.TitleSize+";'>"+message.TitleText+"</font></b></td></tr></table>";
			} else 
				message.TitleText="";
		}
		message.cEffect = message.Effect;
		
		
		/*if (typeof(message.BorderWidth) == 'number') message.BorderWidth += 'px';
		else if (typeof(message.BorderWidth) == 'string' && message.BorderWidth.search(/px$/) == -1) message.BorderWidth += 'px';*/
		if (typeof(message.Padding) == 'number') message.Padding += 'px';
		else if (typeof(message.Padding) == 'string' && message.Padding.search(/px$/) == -1) message.Padding += 'px';
		if (typeof(message.Size) == 'number') message.Size += 'px';
		else if (typeof(message.Size) == 'string' && message.Size.search(/px$/) == -1) message.Size += 'px';
			
		msgFontSize = '';
		if (message.Size) msgFontSize = "font-size: "+message.Size+";";
		if (message.Link == "") {			
			//message.Msg = "<table style='margin:0; width:100%; height: 100%; border: "+message.BorderWidth+" solid "+message.BorderColor+";' border='0' cellpadding='0' cellspacing='0'><tr  align="+message.Align+" valign=top><td style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; padding: "+message.Padding+" "+message.Padding+" "+message.Padding+" " +message.Padding+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+";\">"+message.TitleText+message.Bold+"<font  style='font-family: "+message.Family+"; font-size: "+message.Size+"; color: "+message.Fgcolor+";'>"+final_message+"</b></font></td></tr></table>";
			//message.Msg = "<table style='margin:0; width:100%; height: 100%; border: "+message.BorderWidth+" solid "+message.BorderColor+";' border='0' cellpadding='0' cellspacing='0'><tr  align="+message.Align+" valign=top><td style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; padding: "+message.Padding+" "+message.Padding+" "+message.Padding+" " +message.Padding+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+";"+message.tdStyle+"\">"+message.TitleText+message.Bold+"<table width='100%' height='100%' style='font-family: "+message.Family+"; font-size: "+message.Size+"; color: "+message.Fgcolor+";'><tr><td height='100%' valign='top'>"+final_message+"</b></td></tr></table></td></tr></table>";
			//message.Msg = "<table style='margin:0; width:100%; height: 100%;' border='0' cellpadding='0' cellspacing='0'><tr  align="+message.Align+" valign=top><td style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; padding: "+message.Padding+" "+message.Padding+" "+message.Padding+" " +message.Padding+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+";"+message.tdStyle+"border: "+message.BorderWidth+" solid "+message.BorderColor+";\">"+message.TitleText+message.Bold+"<table width='100%' height='100%' style='font-family: "+message.Family+"; font-size: "+message.Size+"; color: "+message.Fgcolor+";'><tr><td height='100%' valign='top'>"+final_message+"</b></td></tr></table></td></tr></table>";
			message.Msg = "<table style='margin:0; width:100%; height: 100%;' border='0' cellpadding='0' cellspacing='0'><tr valign=\"top\"><td valign=\"top\" style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+";"+message.tdStyle+";font-family: "+message.Family+"; "+msgFontSize+" color: "+message.Fgcolor+";\">"+final_message+"</td></tr></table>";
		}
		else {
			//message.Msg = "<table style='margin:0; cursor: pointer; width:100%; height: 100%; border: "+message.BorderWidth+" solid "+message.BorderColor+";' border='0' cellpadding='0' cellspacing='0'><tr  align="+message.Align+" valign=top><td style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; padding: "+message.Padding+" "+message.Padding+" "+message.Padding+" " +message.Padding+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+"; cursor: pointer;"+message.tdStyle+"\">"+message.TitleText+message.Bold+"<table width='100%' height='100%' style='font-family: "+message.Family+"; font-size: "+message.Size+"; color: "+message.Fgcolor+";'><tr><td height='100%' valign='top'>"+final_message+"</b></td></tr></table></td></tr></table>";
			//message.Msg = "<table style='margin:0; cursor: pointer; width:100%; height: 100%;' border='0' cellpadding='0' cellspacing='0'><tr  align="+message.Align+" valign=top><td style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; padding: "+message.Padding+" "+message.Padding+" "+message.Padding+" " +message.Padding+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+"; cursor: pointer;"+message.tdStyle+"border: "+message.BorderWidth+" solid "+message.BorderColor+";\">"+message.TitleText+message.Bold+"<table width='100%' height='100%' style='font-family: "+message.Family+"; font-size: "+message.Size+"; color: "+message.Fgcolor+";'><tr><td height='100%' valign='top'>"+final_message+"</b></td></tr></table></td></tr></table>";
			//message.Msg = "<table style='margin:0; cursor: pointer; width:100%; height: 100%;' border='0' cellpadding='0' cellspacing='0'><tr valign=top><td style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+"; cursor: pointer;"+message.tdStyle+"\">"+message.TitleText+message.Bold+"<table width='100%' height='100%' style='font-family: "+message.Family+"; font-size: "+message.Size+"; color: "+message.Fgcolor+";'><tr><td height='100%' valign='top'>"+final_message+"</b></td></tr></table></td></tr></table>";
			message.Msg = "<table style='margin:0; cursor: pointer; width:100%; height: 100%;' border='0' cellpadding='0' cellspacing='0'><tr valign=\"top\"><td valign=\"top\" style=\"background-color:"+(message.Bgcolor?message.Bgcolor:'#ffffff')+"; "+message.bgImage+" background-position: "+message.bgImgPosition+"; background-repeat: "+message.bgImgRepeat+"; cursor: pointer;"+message.tdStyle+";font-family: "+message.Family+"; "+msgFontSize+" color: "+message.Fgcolor+";\">"+final_message+"</td></tr></table>";
		}

		if ( alowToEdit == 1 ) {
			editAlow = "<table cellpadding=\"0\" cellspacing=\"1\" style=\"position:absolute;bottom:2px;left:0px;z-index:5\"><tr><td><img src=\""+biz_url+"/pagedit.gif\" border=\"0\" onClick=\"openMS("+window.boards[iBoard].boxID+")\" style=\"cursor: pointer;\" title=\"Message Box Administration\"></td><td><img src=\""+biz_url+"/newedit.gif\" border=\"0\" onClick=\"newMS("+window.boards[iBoard].boxID+")\" style=\"cursor: pointer;\" title=\"Add Message Box\"></td></tr></table>";
			message.Msg += editAlow;
			message.Link = "";
		}
	}

	if( message.Effect == 'rand' ) 
		message.cEffect = Math.floor(23*Math.random());
	
	if ( message.cEffect == 'NONE' ){
		runContent.innerHTML = message.Msg;
	}
	else if ( message.cEffect != 'x' ){
		if ( runContent.filters ) {
			runContent.filters.revealTrans.Transition = message.cEffect;
			runContent.filters.revealTrans.apply();
			runContent.innerHTML = message.Msg;
			runContent.filters.revealTrans.play();
		}
		else
			runContent.innerHTML = message.Msg;
	}
	else{
		if ( runContent.filters ) {
			runContent.filters.blendTrans.apply();
			runContent.innerHTML = message.Msg;
			runContent.filters.blendTrans.play();
		}
		else {			
			//alert(message.Msg);
			runContent.innerHTML = message.Msg;			
		}
	}
	
	if (document.getElementById('dhtmlnews-nav_play'+iBoard))
			document.getElementById('dhtmlnews-nav_play'+iBoard).nxt = nexti;
	if (board.Run){
		if(board.pauseBetween){
			setTimeout("runMessageAfterPause("+iBoard+","+nexti+", "+true+")", message.Interval*1000);
		}
		else{
			setTimeout("runMessage("+iBoard+","+nexti+", "+true+")", message.Interval*1000);
		}
	}
	/*else {
			if (document.getElementById('dhtmlnews-nav_play'+iBoard))
				document.getElementById('dhtmlnews-nav_play'+iBoard).nxt = nexti;
	}*/
}
//-------------------------------------------------------------------------------------------------------------------------------------
for (var i=0;i<window.boards.length;i++) {
	if (window.boards[i].Run == undefined) {
		if(window.boards[i].messages.length == 0) {
				try {
					document.getElementById('content'+i).style.display = 'none';
					document.getElementById('content'+i).style.height = '0px';
				} catch (e){}
		}
		else {
				runBoard(i);
		}
	}
}

function startNav(iBoard) {
	
	if (!nav) return;
	var div = '';
	div += '<select onChange="nextMsg('+iBoard+',\'select\');" id="dhtmlnews-nav_selectMsg'+iBoard+'" style="vertical-align: top;">';
	div += '<option value="-1"></option>';
	for (var i = 0 ; i < window.boards[iBoard].messages.length ; i++) {
			msg = window.boards[iBoard].messages[i].TitleText;
			if (msg.length > 20) {
					msg = msg.substring(0,17) + '...';
			}
			div += '<option value="'+i+'">'+msg+'</option>';
	}
	div += '</select>';
	div += '<img onClick="nextMsg('+iBoard+',\'-\')" id="dhtmlnews-nav_prv'+iBoard+'" src="/htm-webaxy/scanpic/images_new/prv.gif" title="'+prvT+'" border="0" height="20px" style="padding-left: 5px; padding-right: 5px; cursor: pointer;">';
	div += '<img onClick="runStopBoard('+iBoard+')" pause="0" id="dhtmlnews-nav_play'+iBoard+'" src="/htm-webaxy/scanpic/images_new/stop.gif" title="'+pauseT+'" border="0" height="20px" style="cursor: pointer;">';
	div += '<img onClick="nextMsg('+iBoard+',\'+\')" id="dhtmlnews-nav_nxt'+iBoard+'" src="/htm-webaxy/scanpic/images_new/nxt.gif" title="'+nxtT+'" border="0" height="20px" style="padding-left: 5px; cursor: pointer;">';
	document.getElementById('dhtmlnews-nav').innerHTML = div;
}

function nextMsg(iBoard, op) {
		
		if (op == 'select' && document.getElementById('dhtmlnews-nav_selectMsg'+iBoard).value == -1) return;
		document.getElementById('dhtmlnews-nav_play'+iBoard).pause = 1;
		document.getElementById('dhtmlnews-nav_play'+iBoard).title = playT;
		document.getElementById('dhtmlnews-nav_play'+iBoard).src = "/htm-webaxy/scanpic/images_new/play.gif";
		stopBoard(iBoard);
		var nxt;
		try {
			nxt = parseInt(document.getElementById('dhtmlnews-nav_play'+iBoard).nxt);
		} catch (e) {
			nxt = 0;
		}
		if (op == 'select') {
				nxt = document.getElementById('dhtmlnews-nav_selectMsg'+iBoard).value;
				document.getElementById('dhtmlnews-nav_play'+iBoard).nxt = nxt;
		}
		if (op == '-') nxt = nxt - 2;
		if (nxt < 0) nxt = nxt + window.boards[iBoard].messages.length;
		
		runMessage(iBoard, nxt);
	
}

function runStopBoard(iBoard) {
	
	var pause = document.getElementById('dhtmlnews-nav_play'+iBoard).pause;
	if (!pause) {
			document.getElementById('dhtmlnews-nav_play'+iBoard).pause = 1;
			document.getElementById('dhtmlnews-nav_play'+iBoard).title = playT;
			document.getElementById('dhtmlnews-nav_play'+iBoard).src = "/htm-webaxy/scanpic/images_new/play.gif";
			stopBoard(iBoard);
	}
	else {
			document.getElementById('dhtmlnews-nav_play'+iBoard).pause = 0;
			document.getElementById('dhtmlnews-nav_play'+iBoard).title = pauseT;
			document.getElementById('dhtmlnews-nav_play'+iBoard).src = "/htm-webaxy/scanpic/images_new/stop.gif";
			window.boards[iBoard].Run = true;
			runMessage(iBoard, document.getElementById('dhtmlnews-nav_play'+iBoard).nxt);
	}
	
}
//////////////////////////////////////////////////////////////////////////////
function CGI_Record (key,data) {
	this.name = key;
	this.data = data;
}

function ParseData (QS) {
	QS = QS.replace(/.*\?/,"");
	CGI = new Array();
	key_data = new Array();
	pairs = QS.split("&");
	if (!pairs)
		return CGI;
	for (i=0;i<pairs.length;i++) {
		if (pairs[i].indexOf("=") != -1) {
			key_data[0] = pairs[i].match(/^[^=]+/)[0];
			key_data[1] = pairs[i].match(/=.*/)[0].slice(1);
		}
		else {
			key_data[0] = pairs[i];
			key_data[1] = "";
		}
		CGI[CGI.length] = new CGI_Record(key_data[0],key_data[1]);
		CGI[key_data[0]] = key_data[1];
	}
	return CGI;
}
//------

function getDateYYYYMMDD(ddate) {
	var re = /^(\d+)\/(\d+)\/(\d+)$/;
	var dArr;
	var dd=0; var mm=0; var yyyy=0;
	if (dArr=re.exec(ddate)) {
		dd =dArr[1]*1; mm =dArr[2]*1; yyyy =dArr[3]*1;
		if ((dd < 1) || (dd > 31)){ return 0;}
		if ((mm < 1) || (mm > 12)){ return 0;}
		if ((dd == 31) && ((mm == 4)||(mm == 6)||(mm == 9)||(mm == 11))){ return 0;}
		if ((dd > 29) && (mm == 2)){ return 0;}
		if (yyyy > 9999){ return 0;}
		
		if (dd < 10){dd = "0"+dd;}
		if (mm < 10){mm = "0"+mm;}
		if (yyyy < 50){yyyy+=2000;}
		if (yyyy < 100){yyyy+=1900;}
		if (yyyy < 1000){yyyy+=1000;}
//		alert(yyyy+''+mm+''+dd);
		ddate = ''+yyyy+''+mm+''+dd;
	}
	else{ddate =0;}
	return ddate;
}
//////////////////////////////////////////////////////////////////////////////////