﻿function dealBtnOver(objAnc) {
	window.status = objAnc.title;
}

function dealBtnOut() {
	window.status = '';
}

function startTick(hh, mm, ss) {
	setInterval('dealTick("' + hh + '", "' + mm + '", "' + ss + '")', 1000)
}

function dealTick(hh, mm, ss) {
	function getInt(str) {
		str = str.replace(/(<([^>]+)>)/ig,"");
		if (str.indexOf('0') == 0) {
			str = str.substring(1);
		}
		return parseInt(str)
	}

	var objHour = document.getElementById(hh);
	var objMinute = document.getElementById(mm);
	var objSecond = document.getElementById(ss);
	var i;
	try {
		if (getInt(objSecond.innerHTML) > 0) {
			i = getInt(objSecond.innerHTML) - 1;
			objSecond.innerHTML = (i<10 ? '0' : '') + i;
		} else {
			objSecond.innerHTML = '59';
			if (getInt(objMinute.innerHTML) > 0) {
				i = getInt(objMinute.innerHTML) - 1;
				objMinute.innerHTML = (i<10 ? '0' : '') + i;
			} else {
				objMinute.innerHTML = '59';
				if (getInt(objHour.innerHTML) > 0) {
					i = getInt(objHour.innerHTML) - 1;
					objHour.innerHTML = (i<10 ? '0' : '') + i;
					
				} else {
					document.location.reload();
				}
			}
		}
		//Warning
		if ((getInt(objHour.innerHTML) == 0) && (getInt(objMinute.innerHTML) < 15)) {
			var FlashBack = false;
			if (getInt(objMinute.innerHTML) < 5) FlashBack = true;
			if ((getInt(objSecond.innerHTML)/2) == (parseInt(getInt(objSecond.innerHTML)/2))) {
				objHour.style.color = '#A31515';
				objMinute.style.color = '#A31515';
				objSecond.style.color = '#A31515';
				if (FlashBack) objHour.parentNode.parentNode.style.backgroundColor = '';
			} else {
				objHour.style.color = '';
				objMinute.style.color = '';
				objSecond.style.color = '';
				if (FlashBack) objHour.parentNode.parentNode.style.backgroundColor = '#FFDFD7';
			}
		}
	} catch(e) {}
}

function popupFriend(url) {
	window.open(url, 'help', 'width=450,height=580,status=no,location=no');
}

function popupHelp(url) {
	window.open(url, 'help', 'width=400,height=350,status=no,location=no,scrollbars=yes');
}

function doPercentage(objRegularPrice, objDiscountPrice, objPercentageSaving) {
	var objReg = document.getElementById(objRegularPrice);
	var objDis = document.getElementById(objDiscountPrice);
	var objSpn = document.getElementById(objPercentageSaving);
	var intPercent = 0;
	if (objReg && objDis && objSpn) {
		if ((objReg.value.length > 0) && (objDis.value.length > 0)) {
			intPercent = Math.ceil(100 - objDis.value / objReg.value * 100);
		}
		switch (true) {
			case (intPercent < 30):
				objSpn.innerHTML = intPercent + '% <small style="font-weight:bold;color:#E60000">Too Low</small>';
				break;
			case ((intPercent >= 30) && (intPercent < 40)):
				objSpn.innerHTML = intPercent + '% <small style="font-weight:bold;color:#F39302">Poor</small>';
				break;
			case ((intPercent >= 40) && (intPercent < 45)):
				objSpn.innerHTML = intPercent + '% <small style="font-weight:bold;color:#02C519">OK</small>';
				break;
			case ((intPercent >= 45) && (intPercent < 50)):
				objSpn.innerHTML = intPercent + '% <small style="font-weight:bold;color:#02C519">Good</small>';
				break;
			case ((intPercent >= 50) && (intPercent < 60)):
				objSpn.innerHTML = intPercent + '% <small style="font-weight:bold;color:#02C519">Very Good</small>';
				break;
			case ((intPercent >= 60)):
				objSpn.innerHTML = intPercent + '% <small style="font-weight:bold;color:#02C519">Excellent!</small>';
				break;
		}
	}
}


function doCommission(objCommission, objCommissionNote) {
	var objComm = document.getElementById(objCommission);
	var objSpn = document.getElementById(objCommissionNote);
	var intComm = 0;
	if (objComm && objSpn) {
		if (objComm.value.length > 0) {
			intComm = objComm.value;
		}
		switch (true) {
			case (intComm < 30):
				objSpn.innerHTML = '<small style="font-weight:bold;color:#E60000">Too Low</small>';
				break;
			case ((intComm >= 30) && (intComm < 35)):
				objSpn.innerHTML = '<small style="font-weight:bold;color:#02C519">OK</small>';
				break;
			case ((intComm >= 35) && (intComm < 45)):
				objSpn.innerHTML = '<small style="font-weight:bold;color:#02C519">Good</small>';
				break;
			case ((intComm >= 45) && (intComm < 55)):
				objSpn.innerHTML = '<small style="font-weight:bold;color:#02C519">Very Good</small>';
				break;
			case ((intComm >= 55)):
				objSpn.innerHTML = '<small style="font-weight:bold;color:#02C519">Excellent!</small>';
				break;
		}
	}
}

function RevealOldComments(cid) {
	document.getElementById('ancOldComments_'+cid).style.display = 'none';
	document.getElementById('ancOldCommentsHide_'+cid).style.display = 'inline';
	document.getElementById('ulOldComments_'+cid).style.display = 'block';
}
function HideOldComments(cid) {
	document.getElementById('ancOldComments_'+cid).style.display = 'inline';
	document.getElementById('ancOldCommentsHide_'+cid).style.display = 'none';
	document.getElementById('ulOldComments_'+cid).style.display = 'none';
}
function ExpandComments(id) {
	document.getElementById('ddcom' + id).style.display = 'inline';
	document.getElementById('ddcomlink' + id).style.display = 'none';
}