// JavaScript Document


//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr','font','p','span');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
 if (!document.getElementById) return;
 var d = document,cEl = null,sz = startSz,i,j,cTags;
 
 sz += inc;
 if ( sz < 0 ) sz = 0;
 if ( sz > 6 ) sz = 6;
 startSz = sz;
  
 if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

 cEl.style.fontSize = szs[ sz ];

 for ( i = 0 ; i < tgs.length ; i++ ) {
  cTags = cEl.getElementsByTagName( tgs[ i ] );
  for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
 }
}




var fontsizePx = 12;	// same as font-size in body
/* *** Adjust Font Size *** */
function adjustFontsize(tag, sizechange) {
	if (!document.getElementById) return;
	var d = document,cEl = null,i,j,cTags;
	if( sizechange == 'smaller' && fontsizePx > 12 ) fontsizePx = fontsizePx - 1;
	else if( sizechange == 'larger' && fontsizePx < 17 ) fontsizePx = fontsizePx + 1;
	else if( sizechange == 'small' ) fontsizePx = 12;	// same as font-size in body
	else if( sizechange == 'large') fontsizePx = 14;
	
	if ( !( cEl = d.getElementById( tag ) ) ) cEl = d.getElementsByTagName( tag )[ 0 ];
	//debug(cEl);
	cEl.style.fontSize = fontsizePx + "px";
	
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		t = cEl.all.tags(tgs[ i ]);
		//alert(tgs[i] +":" + cTags.length);
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = fontsizePx + "px";
	}
}
/* *** end of Adjust Font Size *** */

function debug(obj) {
        if(obj) {
                var s = '';
                for(var itm in obj) {
                        s += 'obj.' + itm + '=' + obj[itm] + ';\r\n';
                }
                alert(s);
        }
}


//explor table to excel
function AutomateExcel( id ){
	var oXL = new ActiveXObject("Excel.Application"); 
	var oWB = oXL.Workbooks.Add(); 
	var oSheet = oWB.ActiveSheet;
	var outtable = document.getElementById( id );
	var hang = outtable.rows.length; 
	
	var lie = outtable.rows(0).cells.length; 
	
	for (i=0;i<hang;i++){ 
	for (j=0;j<lie;j++){ 
		oSheet.Cells(i+1,j+1).value = outtable.rows(i).cells(j).innerText; 
	} 
	
	} 
	oXL.Visible = true; 
	oXL.UserControl = true; 
}


//explor to word
function OpenWord(){
	Layer1.style.border=0
	ExcelSheet = new ActiveXObject('Word.Application');
	ExcelSheet.Application.Visible = true;
	var mydoc=ExcelSheet.Documents.Add('',0,1);
	myRange =mydoc.Range(0,1)
	var sel=Layer1.document.body.createTextRange()
	sel.select()
	Layer1.document.execCommand('Copy')
	sel.moveEnd('character')
	myRange.Paste();
	location.reload()
	ExcelSheet.ActiveWindow.ActivePane.View.Type=9
}

//show cruise options
var allCruises = '';
function showCruise(){
	var depart = $("#DeparturePort").val();
	var cruise = $("#cruise");
	if(allCruises==""){
		allCruises = cruise.html();
	}
	var v = allCruises.replace(/option/gi,"option");
	var op = "";
	switch(depart){
		case 'Shanghai' :
			  op = "<option value='Victoria Prince'>Victoria Prince</option>";
			  cruise.html(op);break;
		case 'Nanjing' :
			  op ="<option value='Viking Century Sun'>Viking Century Sun</option>";
			  cruise.html(op);break;
		case 'Wuhan' :
			  op ="<option value='China Regal'>China Regal</option>";
			  cruise.html(op);break;
		default : cruise.html(v);document.getElementById('cruise').options[0].selected = true; break;
	}
}

// automatic fill the checkindate field.
function inputDate(){
	var thisDate = new Date();
	var obj = document.getElementById('checkindate');
	var thisMonth = thisDate.getMonth()+1;
	thisMonth = thisMonth<10?"0"+thisMonth:thisMonth;
	if(obj.value == null || obj.value == ""){
		obj.value = thisDate.getFullYear() + "-" + thisMonth + "-" + thisDate.getDate();
	}
}
$(document).ready(function(){
	inputDate();
});