var newWindow;				
// set flag to help out with special handling for window closing
var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false

var winDisp


function confEmail(pC,pD,pA,pS,pF,pM) {   
    
    if (pD == 'V')
        sD = 'voucher'
    else
        sD = 'booking'

    if (confirm('Confirm sending ' + sD + ' email to ' + pM)) {    
                
        document.location.href = 'main.asp?t=res&qNum=' + pC + 
                                    '&act=Print&prn=' + pD + 
                                    '&agen=' + pA + 
                                    '&qServ=' + pS + 
                                    '&qCount=' + pF + 
                                    '&mailer=1&qMail=' + pM
    }
}

function doLang(l) {	
	frm = document.forms[1]
	if (frm.selButts) {frm.selButts.value = ''}
	if (frm.name == 'frmBooks' && frm.txtAct) {
		frm.txtAct.value = 'go'
		frm.tbLC.value = 1		
	}
	if (frm.name == 'frmEdit') {
		ChkInput()
		frm.tbLC.value = 1
		}
	frm.selLang.value = l
	document.cookie = "HSoft=" + escape("lang=" + l + "&type=H") + "; expires=Mon, 17 Jul 2045 23:59:59 UTC;"
	frm.submit()
}

function finShop(u,url,ssl) {

	//alert(u)
	
	frm = document.forms[1];

    bAuth = (u != null && u != "")
	
	//alert(frm.selCo.selectedIndex)	
	
	//alert(bAuth)
	
	if (!bAuth) {
	
	    //if (ssl == 1)
	    //    frm.action = "https://ibornfree.net/GuapoSkins/main.asp?t=login&o=" + frm.order.value;
	    //else	      
	          frm.action = "main.asp?t=login&o=" + frm.order.value;
	        
	    frm.submit();
	    return
	}
	
	//alert(frm.selCo.selectedIndex)
	
	//if (frm.selCo.selectedIndex > 0) {    
	
	    ////ship = frm.selCo.value
	    ////iCpos = ship.indexOf('|')
	    
	    //alert(ship)
	    //alert(ship.substr(iCpos, ship.length - iCpos))
	    
	    ////if (ship.substr(iCpos, ship.length - iCpos) == '|0|0|0|0|0|0|0|0|0|')
	    ////	{
	    ////    alert('Sorry, but we currently do not ship to the country you selected.')
        ////    frm.selCo.selectedIndex = 0
        ////    frm.selCo.focus()	        
	    ////return
	    ////}
	
	    if (!frm.chkAgree.checked) {
	    	    
	        alert('You need to read and agree to the Terms & Conditions...');
	        frm.chkAgree.focus();
	    }else{	
	    
		    //alert(u)
		
		    if (bAuth) {
		    
		        //alert(url)
		    
			    if (url != 'pay' && url != 'LinkPoint') {
			    
			        /*
			        if (url == "LinkPoint")			        
			        {
			            url = "../../HSoftCorpEyeCandy/HS_payments/LinkPoint.asp"		        
				        frm.action = "main.asp?t=" + url;
				    }    
			        else
			        {
			        */
			        
				    frm.PARAMPLUS.value = 'sCFre=' + frm.tFre.value + '&' +
										    'sCTax=' + frm.tTax.value;
				    frm.action = url;
				    
				    //}
				    
			    }else{
				    frm.action = "main.asp?t=" + url;
			    }	
		    }else{				
			    //sfx = '';
			    //if (url == 'pay') {sfx = '&HSpay=' + url}				    				
			    //frm.action = "main.asp?t=accts" + sfx;
			    
			    frm.action = "main.asp?t=login&o=" + frm.order.value;
		    }
		    frm.submit();
		}
		
	//}else{
   	//    alert('Select the country where you want the items to be posted. ' +
    //              '                                                            Different freight fees and taxes may apply...');
	//	frm.selCo.focus();	
	//}	
}

function valiAgree() {

//    var frm = document.forms[1];
    
//    if (frm.selCo.selectedIndex < 1) {
//	    alert('Select the country where you want the items to be posted. ' +
//              '                                                            Different freight fees and taxes may apply...');
//        frm.chkAgree.checked = false;
//        frm.selCo.focus();
//    }    
}
					
function display(sSSL,cod,lan,sys,map,q,edit,ame,chart) {

	frm = document.forms[1]

	if (edit) {
	
		aM1 = new Array()
	
		oS = frm.selRoom;
		ooS = frm.selSea;
		
		//alert(oS.selectedIndex)
		
		tM = frm['txtSea_' + oS.selectedIndex].value									
			
		//alert(tM)
					
		for (i=0; i<ooS.length; i++) {
					
			nM = tM.indexOf(';')
			if (nM>-1) {				
				
				aM1[i] = tM.substr(0,nM);										
				tM = tM.substr(nM+1, tM.length - nM);
						
				if (i+1 == ooS.selectedIndex) {
						
					sM = aM1[i]
				}
			}					
		}
			
		//alert(sM)
		//alert(oS.value)

		dI = sM.substr(0,10)
		dO = sM.substr(14,10)
	
	}else{
	
		if (q == 'seas') {
		
			dI = frm.inMonth.value + '/' + frm.inDay.value + '/' + frm.inYear.value
			if(frm.outMonth) 
				dO = frm.outMonth.value + '/' + frm.outDay.value + '/' + frm.outYear.value
			else
				dO = dI
		}		
	}
	if (!winDisp || winDisp.closed) {
	
	    if (chart)
	        if (sys == 'yearsales')
			    winDisp = window.open("../../OleToursHawaiiCharts/MonthlySalesChart.swf?qYear=" + q, "winDisp", "dependent=true,width=720,height=420")	
			else
			    winDisp = window.open("../../OleToursHawaiiCharts/AnnualSalesChart.swf", "winDisp", "dependent=true,width=720,height=420")
			
		else if (map) 
			winDisp = window.open("http://maps.google.com/maps?q=" + q, "winDisp", "dependent=true,width=680,height=380")
		else
			if (q == 'seas')

				winDisp = window.open(sSSL + "SeasonsCalendar.asp?t=edit&qButt=edit&c=" + cod + "&qDat1=" + dI + "&qDat2=" + dO + "&n=1&seas=1&edit=" + edit, "winDisp", "dependent=true,width=680,height=380")

			else
			    if (q == 'log')
			    
				    winDisp = window.open(sSSL + "OLE_headers/OLE_reservationsLog.asp?c=" + cod + '&l=' + lan + '&sN=' + sys + '&ame=' + ame, "winDisp", "dependent=true,width=680,height=280")
			    
			    else			
				    if (ame > 0) 
					    winDisp = window.open(sSSL + "OLE_headers/OLE_htmlDisplay.asp?c=" + cod + '&l=' + lan + '&sN=' + sys + '&ame=' + ame, "winDisp", "dependent=true,width=680,height=380")
				    else
					    winDisp = window.open(sSSL + "OLE_headers/OLE_display.asp?c=" + cod + '&l=' + lan + '&sN=' + sys + '&ame=' + ame, "winDisp", "dependent=true,width=680,height=380")
				

		if (!winDisp.opener)
			winDisp.opener = window;
		
	}else{
		
		//winDisp.focus();						
	    if (chart)
	        if (sys == 'yearsales')	    
			    winDisp.location.href = "../../OleToursHawaiiCharts/MonthlySalesChart.swf?qYear=" + q;
			else
			    winDisp.location.href = "../../OleToursHawaiiCharts/AnnualSalesChart.swf";	
			
		else if (map) 
			winDisp.location.href = "http://maps.google.com/maps?q=" + q;
		else
			if (q == 'seas')
				
				winDisp.location.href = sSSL + "SeasonsCalendar.asp?t=edit&qButt=edit&c=" + cod + "&qDat1=" + dI + "&qDat2=" + dO + "&n=1&seas=1&edit=" + edit;
			else
			    if (q == 'log')
			    
				    winDisp.location.href = sSSL + "OLE_headers/OLE_reservationsLog.asp?c=" + cod + '&l=' + lan + '&sN=' + sys + '&ame=' + ame;
			    else
				    if (ame > 0) 

					    winDisp.location.href = sSSL + "OLE_headers/OLE_displayHtml.asp?c=" + cod + '&l=' + lan + '&sN=' + sys + '&ame=' + ame;
				    else	
					    winDisp.location.href = sSSL + "OLE_headers/OLE_display.asp?c=" + cod + '&l=' + lan + '&sN=' + sys + '&ame=' + ame;
				
				
		winDisp.focus();						

	}		
}


function chkNum(o,e,p) {
		
	var frm = document.forms[1]		
	if (window.Event){
		uKey = e.which;
	}else{
		uKey = e.keyCode;
	}						

	var sNum = o.value

	//alert(uKey)

	var pnt = 46		
	if (p != 1 && sNum.indexOf('.') < 0) {				
		pnt = 45
	}	
	if (p == 2) {
		if (uKey == 37 && sNum.indexOf('%') < 0) pnt = 36		
	}
	if (p == 3) {
		if (uKey == 45 && sNum.indexOf('-') < 0) pnt = 44
	}
	
	
	if (!((uKey > pnt && uKey < 58) && uKey != 47)) {
	
		if (uKey == 0 || uKey == 8) {
			
			return true
				
		}else{			
			return false
		}		
	}else{			
		return true	
	}
}


function booksOnload(t) {

	window.status = sysFullName + ", bookings...";	
	var frm = document.forms['frmBooks'];
	
	if (frm && t == 1) {
	
		CheckStars(0)
		
		document.onkeydown = mSubBooks;
		
		//frm.txtSearch.focus();
	}
	loadShiny('books')
}


function resOnload() {

	window.status = sysFullName + ", itineraries...";
	
	document.onkeydown = alert;	
	loadShiny()
}

function accOnload() {

	window.status = sysFullName + ", agents...";

	var frm = document.forms['frmList'];
		
	if (frm.txtCodeEdit) {
		
		if (frm.txtCodeEdit.type != 'hidden')  {	
			frm.txtCodeEdit.focus();
		}else{	
			frm.txtName.focus();
		}	
	}
	loadShiny('books')
}	

function payOnload() {

	window.status = sysFullName + ", pay...";

	frm = document.forms[1]
	
	if (frm.txtFact) {
	
		frm.txtFact.value = 0
	
		for (i=0;i<frm.txtCount.value;i++) {
	
			cbeGetElementById('aCheck_' + i).checked = false
		}
	}
	loadShiny('books')
}	
			
function loginOnload() {

	window.status = "Members's login..."
	
	var frm = document.forms['frmLogin'];
	if (frm) {
		if (frm.txtUser.value == '') {frm.txtUser.focus();}	
	}
	loadShiny('login')
}

function editOnload(but) {

	window.status = "Editing services..."
	
	var frm = document.forms['frmEdit'];
	
	//alert(frm.name)
	
	if (frm) {
		if (but == 'new') {
			frm.txtName.focus()		
		}else{		
			oS = frm.selRoom
			oS.selectedIndex = 1
			setPrice()
		}	
	}
	loadShiny('books')
}		

function acctsOnload() {

	window.status = "Editing accounts..."

	var frm = document.forms['frmList']
		
	//if (frm) frm.txtCodeEdit.focus()
	loadShiny('books')
}


function pmntOnload(l) {

	window.status = "Make or receive payments..."

	var frm = document.forms['frmList']

	//alert(frm.txtTotal.value)
		
	if (frm) {
		if (l == 9) {
			frm.selPay.selectedIndex = 0
			frm.selPay.focus()
		}else{
			frm.tDetGas.focus()
		}
		//frm.txtTotal.value = 0
				
		//frm.txtAccts.value = ""
	}
	loadShiny('books')
}


function goM(url,t,g,s,u,w) {

	//alert(url)

	if (t == 'group') {
		document.location.href = 'main.asp?t='+t+'&g='+g+'&s='+s+'&m='+s+'&u='+u;
	}else{
		if (url != '') {		
			//, "dependent=true,width=850,height=680"		
			if (w == 2) {
				//if (!winDisp || winDisp.closed) {
					winDisp = window.open(url, "winDisp")
					//if (!winDisp.opener) {
						winDisp.opener = window;
					//}
				//}else{
				//	winDisp.location.href = url
					winDisp.focus();						
				//}
			////}else if (w == 0) {
			////	document.location.href = 'main.asp?url='+url+'&t='+t+'&g='+g+'&s='+s+'&m='+s+'&u='+u;
			}else{
				document.location.href = url
			}	
		}else{
			document.location.href = 'main.asp?g='+g+'&s='+s+'&u='+u;
		}	
	}	
}

function FactIt(nom,act) {		
	var frm = document.forms['frmList'];
	
	//alert(frm.name)
	//alert(act)
	//alert(frm.txtFact.value)
	
	////if (act == 1 || frm.txtFact.value == 0) {		

	if (frm.txtFact.value == 0) {		
		alert("Seleccione alguna reserva para facturar...");
		return false;
	}else{
		if (act != 1 && frm.txtInvo.value == '') {
			alert("Ingrese el numero de factura...");
			frm.txtInvo.focus()
			return false;
		}else{	
			if (!confirm("Confirma generacion de factura para " + nom + "?")) {
				return false;
			}
		}	
	}	
	return true;
}

function FactGuia(nom) {		
	var frm = document.forms['frmList'];
	
	if (!confirm("Confirma generacion de factura para " + nom + "?")) {
		return false;
	}
	return true;
}

function mmeU(anc) {
	anc.className = "mmeu";	
}
	
function mmeD(anc) {
	anc.className = "menu";	
}

function mrU(anc) {
	anc.className = "reu";	
}
	
function mrD(anc) {
	anc.className = "res";	
}

function mmU(anc) {
	anc.className = "tou";	
}
	
function mmD(anc) {
	anc.className = "top";	
}

function msU(anc,a) {
	if (a == 3) {
		anc.className = "shou";
	}else if (a == 1) {
		anc.className = "msu";
	}else{
		anc.className = "tau";	
	}
}
	
function msD(anc,a) {
	if (a == 3) {
		anc.className = "shop";
	}else if (a == 1) {
		anc.className = "ms";
	}else{	
		anc.className = "tab";	
	}
}	



function setDate(d,nIO,n,cod,cat,edit)	{

	if (edit) return

	//alert(d)
	//objDat = new String(d);
	
	at = new Array();
	
	at[0] = d.indexOf('/', 0);	
	if (at[0] > -1) {
		var mon = d.substr(0, at[0])		
	}
	at[1] = d.indexOf('/', at[0]);
	if (at[1] > -1) {
		var day = d.substr(at[1] + 1, (d.length - 6 - at[0]))		
	}
	at[2] = d.indexOf('/', at[1] + 1);
	if (at[1] > -1) {
		var yea = d.substr(at[2] + 1, 4)		
	}

	if (nIO == 2) 
		t = 'out' 
	else 
		t = 'in' 
		
	var e
	e = document.getElementById(t + 'Month')
	e.options[mon-1].selected = true;
	
	mDate(t.substr(0,1)+'m')	
	
	e = document.getElementById(t + 'Day')
	e.options[day-1].selected = true;

	e = document.getElementById(t + 'Year')	
	for (y=0; y<10; y++) {
		if (e.options[y].value == yea) {
			e.options[y].selected = true;
		}
	}
	
	sYI = document.getElementById('inYear').value
	sMI = document.getElementById('inMonth').value
	sDI = document.getElementById('inDay').value

	sYO = document.getElementById('outYear').value
	sMO = document.getElementById('outMonth').value
	sDO = document.getElementById('outDay').value
					
	dI = sMI + '/' + sDI + '/' + sYI
	dO = sMO + '/' + sDO + '/' + sYO
			
	tDat1 = new Date(sYI, Number(sMI)-1, Number(sDI))
	tDat2 = new Date(sYO, Number(sMO)-1, Number(sDO))

	//alert(tDat1)
	//alert(tDat2)

	if (tDat2 < tDat1) {

		e = document.getElementById('outMonth')

		//if (Number(sMI) = Number(sMO))

		//	e.options[sMI-1].selected = true;
			
		//else
			e.options[sMO-1].selected = true;
			
		///////////////mDate('om')
	
		e = document.getElementById('outDay')
		e.options[sDI-1].selected = true;

		e = document.getElementById('outYear')	
		for (y=0; y<10; y++) {
			if (e.options[y].value == sYI) {
				e.options[y].selected = true;
			}
		}
		
		dO = dI		
	}	

	if (cod != '')
			
		winDisp.moveSeaCalendar(cod,dI,dO,0,0,'',nIO,n,cat,edit)
	else
		newWindow.moveCalendar(dI,dO,0,0,'',nIO,n)
}



	
function PrintPrev() {
		
	var frm = document.forms['frmList'];	
	
	frm.txtSelect.value = 'Print';
	frm.submit()
}

function winCalendar(t,nIO)	{
	
	frm = document.forms[1]

	dI = frm.inMonth.value + '/' + frm.inDay.value + '/' + frm.inYear.value
	if(frm.outMonth) 
		dO = frm.outMonth.value + '/' + frm.outDay.value + '/' + frm.outYear.value
	else
		dO = dI

	if (!newWindow || newWindow.closed)	{

		newWindow = window.open("OLE_calendar.asp?qDat1=" + dI + "&qDat2=" + dO + '&n=' + nIO, "subwindow", "dependent=true,height=170,width=342,screenX=570,screenY=430")

		if (!newWindow.opener) {
			newWindow.opener = window
		}	
	}else{

		newWindow.moveCalendar(dI,dO,0,0,'',nIO,1)
		newWindow.focus()		
	}
}

function ancU(obj) {
	obj.className = "mmau";
}

function ancUenu(obj) {
	obj.className = "mmeu";
}

function ancD(obj) {
	obj.className = "mman"  //mM"
}	

function ancM(obj) {
	obj.className = "mman"
}

function ancMenu(obj) {
	obj.className = "mmen"
}

function lightsOn(obj,col,act) {
	obj.style.color = col;
}

function loadShiny(t) {
    
    //alert(t)
    
    fPro = document.getElementById('promos')    
    if (t) {    
        fPro.src = "OLE_headers/PlayPromos.asp?t=" + t   
    }else{
        fPro.src = "OLE_headers/OLE_bgcolor.html"    
    }   

    ////fSea = document.getElementById('seal')
    ////if (fSea) fSea.src = "OLE_headers/PlaysiteSeal.asp"    
    
    fShi = document.getElementById('shinystat')
    if (fShi) fShi.src = "OLE_headers/ShinyStat.asp"    
}