// http://thunder.eeap.cwru.edu/ccal/view.htm 
// this is the web site converting lunar to western
//
// Year   Spring Festival:    Autumn Festival
// 2005				9/18
// 2006		1/29		10/6
// 2007		2/18		9/25
// 2008		2/7		9/14
// 2009		1/26		10/3
// 2010		2/14		9/22
//


function overCell(el) {
el.style.background='#FCF7F2';
}

function outCell(el) {
el.style.background='#ffffff';
}

// used for main pages
function getLogo1(alt) {
var thisImg;
var alt;

var thisDate= new Date();
var thisYear= thisDate.getFullYear();
var thisMonth = thisDate.getMonth();
var thisDay = thisDate.getDate();
var weekDay = thisDate.getDay();
var inWhichWeek;

inWhichWeek = Math.floor((thisDay -1) / 7 ) + 1;	// this day is in which week (1 or 2 or 3 or 4 ...)	

thisImg = "images/logo-1.gif";	// default display	//default

if (thisYear ==2006 && thisMonth == 0 && (thisDay >=29 && thisDay <=31)) // spring
{
thisImg = "images/logoSpringFestival-1.gif";
}
if (thisYear ==2007 && thisMonth == 1 && (thisDay >=18 && thisDay <=20)) 
{
thisImg = "images/logoSpringFestival-1.gif";
}
if (thisYear ==2008 && thisMonth == 1 && (thisDay >=7 && thisDay <=9)) 
{
thisImg = "images/logoSpringFestival-1.gif";
}
if (thisYear ==2009 && thisMonth == 0 && (thisDay >=26 && thisDay <=28)) 
{
thisImg = "images/logoSpringFestival-1.gif";
}
if (thisYear ==2010 && thisMonth == 1 && (thisDay >=14 && thisDay <=16)) 
{
thisImg = "images/logoSpringFestival-1.gif";
}

if (thisYear == 2005 && thisMonth == 8 && thisDay ==18 ) // autumn
{
thisImg = "images/logoMoonFestival-1.gif";
}
if (thisYear ==2006 && thisMonth == 9 && thisDay ==6 ) 
{
thisImg = "images/logoMoonFestival-1.gif";
}
if (thisYear ==2007 && thisMonth == 8 && thisDay ==25 ) 
{
thisImg = "images/logoMoonFestival-1.gif";
}
if (thisYear ==2008 && thisMonth == 8 && thisDay ==14 ) 
{
thisImg = "images/logoMoonFestival-1.gif";
}
if (thisYear ==2009 && thisMonth == 9 && thisDay ==3 ) 
{
thisImg = "images/logoMoonFestival-1.gif";
}
if (thisYear ==2010 && thisMonth == 8 && thisDay ==22 ) 
{
thisImg = "images/logoMoonFestival-1.gif";
}

if (thisMonth == 4 && thisDay ==1 )	// May day 5/1
{
thisImg = "images/logoLabor-1.gif";	
}
if (thisMonth == 6 && thisDay ==4 )	// independent day 7/3-5
{
thisImg = "images/logoUSA-1.gif";	
}
if (thisMonth == 8 && weekDay == 1 && inWhichWeek == 1)	// Laborday 9/the first week/Monday
{
thisImg = "images/logoLabor-1.gif";	
}
if (thisMonth == 9 && thisDay ==1 )	// National day 10/1
{
thisImg = "images/logoChina-1.gif";	
}
if (thisMonth == 9 && thisDay == 31 )	// Holloween day 10/31
{
thisImg = "images/logoHolloween-1.gif";	
}
if (thisMonth == 10  && (weekDay >= 4 && weekDay <= 4) && inWhichWeek == 4)	// Thanksgiving day 11/the fourth week\thursday-saturday
{
thisImg = "images/logoThanksgiving-1.gif";	
}
if (thisMonth == 11 && (thisDay >23 && thisDay<27) )	// christmas 12/24-26
{
thisImg = "images/logoChristmas-1.gif";	
}
if (thisMonth == 0 && thisDay ==1  )	// new year 1/1
{
thisImg = "images/logoChristmas-1.gif";	
}

document.write("<img border=0  src="  + thisImg  + " alt='" + alt + "' width = 350 height=77 align=middle ");
}


// used for pages in lower level directories (n=1) or root (n=0), logo is small
function getLogo20(alt) {
var thisImg;
var alt;
var n;
var thisDate= new Date();
var thisYear= thisDate.getFullYear();
var thisMonth = thisDate.getMonth();
var thisDay = thisDate.getDate();
var weekDay = thisDate.getDay();
var inWhichWeek;

inWhichWeek = Math.floor((thisDay -1) / 7 ) + 1;	// this day is in which week (1 or 2 or 3 or 4 ...)	

thisImg = "images/logo-2.gif";	// default display	//default

if (thisYear ==2006 && thisMonth == 0 && (thisDay >=29 && thisDay <=31)) // spring
{
thisImg = "images/logoSpringFestival-2.gif";
}
if (thisYear ==2007 && thisMonth == 1 && (thisDay >=18 && thisDay <=20)) 
{
thisImg = "images/logoSpringFestival-2.gif";
}
if (thisYear ==2008 && thisMonth == 1 && (thisDay >=6 && thisDay <=8)) 
{
thisImg = "images/logoSpringFestival-2.gif";
}
if (thisYear ==2009 && thisMonth == 0 && (thisDay >=26 && thisDay <=28)) 
{
thisImg = "images/logoSpringFestival-2.gif";
}
if (thisYear ==2010 && thisMonth == 1 && (thisDay >=14 && thisDay <=16)) 
{
thisImg = "images/logoSpringFestival-2.gif";
}

if (thisYear == 2005 && thisMonth == 8 && thisDay ==18 ) // autumn
{
thisImg = "images/logoMoonFestival-2.gif";
}
if (thisYear ==2006 && thisMonth == 9 && thisDay ==6 ) 
{
thisImg = "images/logoMoonFestival-2.gif";
}
if (thisYear ==2007 && thisMonth == 8 && thisDay ==25 ) 
{
thisImg = "images/logoMoonFestival-2.gif";
}
if (thisYear ==2008 && thisMonth == 8 && thisDay ==14 ) 
{
thisImg = "images/logoMoonFestival-2.gif";
}
if (thisYear ==2009 && thisMonth == 9 && thisDay ==3 ) 
{
thisImg = "images/logoMoonFestival-2.gif";
}
if (thisYear ==2010 && thisMonth == 8 && thisDay ==22 ) 
{
thisImg = "images/logoMoonFestival-2.gif";
}

if (thisMonth == 4 && thisDay ==1 )	// May day 5/1
{
thisImg = "images/logoLabor-2.gif";	
}
if (thisMonth == 6 && thisDay ==4 )	// independent day 7/3-5
{
thisImg = "images/logoUSA-2.gif";	
}
if (thisMonth == 8 && weekDay == 1 && inWhichWeek == 1)	// Laborday 9/the first week/Monday
{
thisImg = "images/logoLabor-2.gif";	
}
if (thisMonth == 9 && thisDay ==1  )	// National day 10/1
{
thisImg = "images/logoChina-2.gif";	
}
if (thisMonth == 9 && thisDay == 31 )	// Holloween day 10/31
{
thisImg = "images/logoHolloween-2.gif";	
}
if (thisMonth == 10  && (weekDay >= 4 && weekDay <= 4) && inWhichWeek == 4)	// Thanksgiving day 11/the fourth week\thursday-saturday
{
thisImg = "images/logoThanksgiving-2.gif";	
}
if (thisMonth == 11 && (thisDay >23 && thisDay<27) )	// christmas 12/24-26
{
thisImg = "images/logoChristmas-2.gif";	
}
if (thisMonth == 0 && thisDay ==1 )	// new year 1/1
{
thisImg = "images/logoChristmas-2.gif";	
}

document.write("<a href=index.htm class=blue onclick=blur()><img border=0  src="  + thisImg  + " alt='" + alt + "' width = 205 height=45 align=baseline ");

}

// when pushing Enter, default is Name button
function catchEnter(){
if(event.keyCode == 13)
{
  getTypeAndRun(1);
 return false;
}
else
return true;
}

// for install search box
function boxTypeClick(what)
{
    movePic();
}    

function boxBorderClick(what)
{
    movePic();
}    

function boxLogoClick(what)
{
    movePic();
}    

function movePic() {
var block = new Array();
var strip = new Array();
	
	block[1]='<p><link rel=stylesheet type="text/css" href="http://www.chemblink.com/css/chemBlink.css">';
	block[2]='<scr' + 'ipt language="JavaScript" src="http://www.chemblink.com/chemBlink3C.js"></sc' + 'ript>'; 
	block[3]='<table border=';
	block[4]='"0"';
	block[5]=' cellpadding="3" cellspacing="0" width="250">';
	block[6]='<tr><td width="100%">';
	block[7]='<table border="0" cellpadding="0" cellspacing="0" width="100%">';
	block[8]='<form method="post" action="http://www.chemblink.com/asp/searchingC.asp" name="searchForm" onsubmit="return(checkBlank())" target="_blank">';
	block[9]='<tr><td rowspan="2" height="50" width="110" align="center">';
	block[10]='<a href="http://www.chemblink.com/" target="_blank"  class="style4">';
	block[11]='<img src="http://www.chemblink.com/images/logo-G.gif" border="0" height="46" width="100">';
	block[12]='</a></td>';
	block[13]='<td align="center" height="23" width="140">'    ;
	block[14]='<input name="types" type="hidden">';
	block[15]='<input name="terms" size="18" type="text">';
	block[16]='</td></tr><tr>';
	block[17]='<td align="center" height="23" width="140">';
	block[18]='<input name="Name" value="²úÆ·" onclick="return(runName())" type="submit">' ;
	block[19]='<input name="CAS" value="CAS" onclick="return(runCAS())" type="submit">';
	block[20]='</td></tr></form></table></td></tr></table></p>';
	
	strip[1]='<p><link rel=stylesheet type="text/css" href="http://www.chemblink.com/css/chemBlink.css">';
	strip[2]='<scr' + 'ipt language="JavaScript" src="http://www.chemblink.com/chemBlink3C.js"></sc' + 'ript>';
	strip[3]='<table border=';
	strip[4]='"0"';
	strip[5]=' cellpadding="3" cellspacing="0" width="350">';
	strip[6]='<tr><td width="100%">';
	strip[7]='<table border="0" cellpadding="0" cellspacing="0" width="100%">';
	strip[8]='<form method="post" action="http://www.chemblink.com/asp/searchingC.asp" name="searchForm" onsubmit="return(checkBlank())" target="_blank">';
	strip[9]='<tr><td height="50" width="110" align="center">';
	strip[10]='<a href="http://www.chemblink.com/" target="_blank"  class="style4">';
	strip[11]='<img src="http://www.chemblink.com/images/logo-G.gif" border="0" height="46" width="100">';
	strip[12]='</a></td>';
	strip[13]='<td align="left" height="46" width="240">';    
	strip[14]='<input name="types" type="hidden">';
	strip[15]='<input name="terms" size="18" type="text">';
	strip[16]='<input name="Name" value="²úÆ·" onclick="return(runName())" type="submit">';
	strip[17]='<input name="CAS" value="CAS" onclick="return(runCAS())" type="submit">';
	strip[18]='</td></tr>';
	strip[19]='</form></table>';
	strip[20]='</td></tr></table></p>';

	if (document.boxForm.boxType[0].checked &&
		document.boxForm.boxLogo[0].checked &&
		document.boxForm.boxBorder[0].checked)
	{
		document['boxPic'].src='images/logoStrip.jpg';
		strip[4]='"0"';
		strip[11]='<img src="http://www.chemblink.com/images/logo-G.gif" border="0" height="46" width="100">';
		fillCode(strip); 
	}	
	if (document.boxForm.boxType[0].checked &&
		document.boxForm.boxLogo[0].checked &&
		document.boxForm.boxBorder[1].checked)
	{
		document['boxPic'].src='images/borderLogoStrip.jpg';
		strip[4]='"1"';
		strip[11]='<img src="http://www.chemblink.com/images/logo-G.gif" border="0" height="46" width="100">';
        		fillCode(strip);
	}	
	if (document.boxForm.boxType[0].checked &&
		document.boxForm.boxLogo[1].checked &&
		document.boxForm.boxBorder[0].checked)
	{
		document['boxPic'].src='images/textStrip.jpg';
		strip[4]='"0"';
		strip[11]='chemBLink<br>ËÑË÷';		
        		fillCode(strip);
	}	
	if (document.boxForm.boxType[0].checked &&
		document.boxForm.boxLogo[1].checked &&
		document.boxForm.boxBorder[1].checked)
	{
		document['boxPic'].src='images/borderTextStrip.jpg';
		strip[4]='"1"';
		strip[11]='chemBLink<br>ËÑË÷';		
        		fillCode(strip);
	}	
	if (document.boxForm.boxType[1].checked &&
		document.boxForm.boxLogo[0].checked &&
		document.boxForm.boxBorder[0].checked)
	{
		document['boxPic'].src='images/logoBlock.jpg';
 		block[4]='"0"';
		block[11]='<img src="http://www.chemblink.com/images/logo-G.gif" border="0" height="46" width="100">';		
       		fillCode(block);
	}	
	if (document.boxForm.boxType[1].checked &&
		document.boxForm.boxLogo[0].checked &&
		document.boxForm.boxBorder[1].checked)
	{
		document['boxPic'].src='images/borderLogoBlock.jpg';
		block[4]='"1"';
		block[11]='<img src="http://www.chemblink.com/images/logo-G.gif" border="0" height="46" width="100">';		
        		fillCode(block);
	}	
	if (document.boxForm.boxType[1].checked &&
		document.boxForm.boxLogo[1].checked &&
		document.boxForm.boxBorder[0].checked)
	{
		document['boxPic'].src='images/textBlock.jpg';
		block[4]='"0"';
		block[11]='chemBLink<br>ËÑË÷';		
        		fillCode(block);
	}	
	if (document.boxForm.boxType[1].checked &&
		document.boxForm.boxLogo[1].checked &&
		document.boxForm.boxBorder[1].checked)
	{
		document['boxPic'].src='images/borderTextBlock.jpg';
 		block[4]='"1"';
		block[11]='chemBLink<br>ËÑË÷';		
        		fillCode(block);
	}	
}

function fillCode(theArray)
{
var i;
var str;
	str='';
	for (i=1; i <=20; i++)
	{
		str=str+theArray[i]+String.fromCharCode(13);
	}
		document.boxForm.boxCode.value=str;

}

// this function is only for IE.  It is simply
function copyToClipboard0()
{
	document.boxForm.boxCode.select();
	window.clipboardData.setData("Text",document.boxForm.boxCode.value);
}

// this function works for IE, Netscape and Firefox. When running, warning will be shown at the first tine. 
function copyToClipboard() {

	document.boxForm.boxCode.select();
	meintext=document.boxForm.boxCode.value;

	if (window.clipboardData) {
		// the IE-way
		window.clipboardData.setData("Text", meintext);
	}
	// Probabely not the best way to detect netscape/mozilla.
	// I am unsure from what version this is supported
	else if (window.netscape) { 
		// This is important but it's not noted anywhere
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		// create interface to the clipboard
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		// create a transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

	// specify the data we wish to handle. Plaintext in this case. trans.addDataFlavor('text/unicode'); 
	// To get the data from the transferable we need two new objects var str = new Object(); var len = new Object();

	var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

	var copytext=meintext; 
	str.data=copytext; 
	trans.setTransferData("text/unicode",str,copytext.length*2); 
	var clipid=Components.interfaces.nsIClipboard; 
	if (!clip) return false; 
	clip.setData(trans,null,clipid.kGlobalClipboard); }

	//alert("Following info was copied to your clipboard:nn" + meintext); 

	return false;
}

