function dateInfo( sDate ) {
//Start Date
pos = sDate.indexOf( "/" );
sMth = sDate.substring( 0, pos );
sDate = sDate.substring( pos + 1 );
pos = sDate.indexOf( "/");
sDay = sDate.substring( 0, pos );
sDate = sDate.substring( pos + 1 );
sYr = sDate;
if ( sMth.substr(0, 1) == "0" ) {
sMth = sMth.substr(1, 1);
}
if ( parseInt( sYr ) < 2000 ) {
sYr = toString( ( parseInt( sYr ) + 2000 ) );
}
var aryInfo = new Array(2);
aryInfo[ 0 ] = sMth;
aryInfo[ 1 ] = sDay;
aryInfo[ 2 ] = sYr;
return aryInfo;
}
/*====================*/
function daysDiff( sDate ) {
//Convert passed date into mont, day , and year values
var dateAry = dateInfo( sDate );
var Mth = parseInt( dateAry[ 0 ] );
var Day = parseInt( dateAry[ 1 ] );
var Yr = parseInt( dateAry[ 2 ] );
//Set the two dates
today=new Date();
var curDate =new Date( Yr, Mth - 1, Day ); //Month is 0-11 in JavaScript
var one_day=1000*60*60*24; //Set 1 day in milliseconds
//Calculate difference btw the two dates, and convert to days
return Math.ceil(( curDate.getTime()-today.getTime())/(one_day));
}
/*=============*/
function showDate( sDate, eDate ) {
/*
Show event date in three possible ways. There is an suumption that years will always be the same:
1. If only a start date: DD MMM YYYY
2. If a start and end date with same month: DD-DD MMM YYYY
3. If a start and end date with different months: DD MMM - DD MMM YYYY
*/
var months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
var pos = 0;
var sMth = "";
var sDay = "";
var sYr = "";
var eMth = "";
var eDay = "";
//Start Date
var sAry = dateInfo( sDate );
sMth = sAry[ 0 ];
sDay = sAry[ 1 ];
sYr = sAry[ 2 ];
//End Date
var eAry = dateInfo( eDate );
eMth = eAry[ 0 ];
eDay = eAry[ 1 ];
eYr = eAry[ 2 ];
//Now compare the dates for output
if ( sDate == "" & eDate == "" ) {
return " ";
} else {
if ( eDate == "" ) {
return sDay + " " + months[ parseInt( sMth ) - 1 ] + " " + sYr;
} else if ( sMth == eMth ){ // Same month
return sDay + "-" + eDay + " " + months[ parseInt( sMth ) - 1 ] + " " + sYr;
} else { // Different months
return sDay + " " + months[ parseInt( sMth ) - 1 ] + " - " + eDay + " " + months[ parseInt( eMth ) - 1 ] + " " + sYr;
}
}
}
/* ===End showDate() ===*/
function KDContentTradeShows() {
var counter = 0;
if ( daysDiff( '07/19/2010' ) <= 30 ) {
if ( headerVisible == 0 ) {
document.write("
" + getLangText("NewsAndEvents") + "");
headerVisible = 1; // used to indicate header was displayed. The trade show line layout will produce a header if this variable is zero.
}
if ( ' ' == ' ' ) {
document.write("
| Farnborough International Airshow 2010 |
| United Kingdom | " + showDate('07/19/2010','07/25/2010') + " | |
");
} else {
document.write("| United Kingdom | " + showDate('07/19/2010','07/25/2010') + " | |
");
}
}
return counter;
}
KDContentTradeShows();