function doSearch(base_path) {
	var vSearch = document.frmSearch.src.value;
	var type = document.frmSearch.tp.value;
	var type = document.frmSearch.tp.value;
	var stat = document.frmSearch.stat.value;
	var url = vSearch
				.toLowerCase() // change everything to lowercase
				.replace(/^\s+|\s+$/g, "") // trim leading and trailing spaces		
				.replace(/[_|\s]+/g, "-") // change all spaces and underscores to a hyphen
				.replace(/[^a-z0-9-]+/g, "") // remove all non-alphanumeric characters except the hyphen
				.replace(/[-]+/g, "-") // replace multiple instances of the hyphen with a single instance
				.replace(/^-+|-+$/g, "") // trim leading and trailing hyphens				
				;
	if (stat == 1) {
		var dtfrom = document.frmSearch.dtfrom.value.replace(/\//gi, '+');
		var dtto = document.frmSearch.dtto.value.replace(/\//gi, '+');
		if (vSearch || stat == 1) document.location = base_path + '/search/' + type + '/1/' + url + '/' + dtfrom + '+' + dtto;
	} else {
		if (vSearch) document.location = base_path + '/search/' + type + '/1/' + url;
	}
	return false;
}
var anim_loop;
function showAdvance() {
	var objAdv = document.getElementById('searchadvance');
	var objFrm = document.frmSearch;
	if (objFrm.stat.value == 0) {		
		objAdv.style.height = 0;
		objAdv.style.display = '';
		objFrm.stat.value = 1;
		objFrm.dtfrom.value = '';
		objFrm.dtto.value = '';
		anim_loop = setInterval('showAnim("show");', 50);
	} else {
		objFrm.stat.value = 0;
		anim_loop = setInterval('showAnim("hide");', 50);
	}
}
function showAnim(stat) {
	var objAdv = document.getElementById('searchadvance');
	if (stat == 'show') {
		objAdv.style.height = (parseInt(objAdv.style.height)+10) + 'px';
		if (parseInt(objAdv.style.height) >= 20) {
			clearInterval(anim_loop);
		}
	} else {
		objAdv.style.height = (parseInt(objAdv.style.height)-10) + 'px';
		if (parseInt(objAdv.style.height) <= 0) {
			clearInterval(anim_loop);
			objAdv.style.display = 'none';
		}
	}
}
function validKomen(o) {
	var isOK = true;
	if (o.txtName.value.length <= 0) {
		o.txtName.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtName.style.background = '#FFFFFF';
	}
	if (o.txtEmail.value.length <= 0) {
		o.txtEmail.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtEmail.style.background = '#FFFFFF';
	}
	if (o.txtKomen.value.length <= 0) {
		o.txtKomen.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtKomen.style.background = '#FFFFFF';
	}
	if (o.txtKomen.value.length > 500) {
		alert('Komentar yang Anda masukkan lebih dari 500 karakter!');
		o.txtKomen.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtKomen.style.background = '#FFFFFF';
	}
	if (o.security_code.value.length <= 0) {
		o.security_code.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.security_code.style.background = '#FFFFFF';
	}
	if (isOK == false) {
		return false;
	} else {
		var msg = o.txtKomen.value.replace(/&/gi, 'dan');
		var params = '';
		params += '&id=' + o.newsId.value;
		params += '&name=' + o.txtName.value;
		params += '&email=' + o.txtEmail.value;
		params += '&msg=' + msg;
		params += '&sc=' + o.security_code.value;
		getAjax('commentAjax', 'savecomment', params);
	}
}
function ValidOrder(o) {
	var isOK = true;
	if (o.txtNmProgram.value.length <= 0) {
		o.txtNmProgram.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtNmProgram.style.background = '#FFFFFF';
	}
	if (o.txtName.value.length <= 0) {
		o.txtName.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtName.style.background = '#FFFFFF';
	}
	if (o.txtEmail.value.length <= 0) {
		o.txtEmail.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtEmail.style.background = '#FFFFFF';
	}
	if (o.txtPhone.value.length <= 0) {
		o.txtPhone.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.txtPhone.style.background = '#FFFFFF';
	}
	if (o.security_code.value.length <= 0) {
		o.security_code.style.background = '#E9D5D1';
		isOK = false;
	} else {
		o.security_code.style.background = '#FFFFFF';
	}
	if (isOK == false) {
		return false;
	} else {
		var params = '';
		params += '&txtNmProgram=' + o.txtNmProgram.value;
		params += '&txtName=' + o.txtName.value;
		params += '&txtPhone=' + o.txtPhone.value;
		params += '&txtNote=' + o.txtNote.value;
		params += '&txtEmail=' + o.txtEmail.value;
		params += '&security_code=' + o.security_code.value;
		getAjax('ajaxOrder', 'orderdvd', params);
	}
}

function selNewsTab(id) {
	if (id == 'kbrTerkini') {
		document.getElementById('kbrTerkini').style.display = '';
		document.getElementById('kbrtvOne').style.display = 'none';
		document.getElementById('tabNews_1').className = 'tabMenuTop';
		document.getElementById('tabNews_2').className = 'tabMenuBtm';
	} else {
		document.getElementById('kbrTerkini').style.display = 'none';
		document.getElementById('kbrtvOne').style.display = '';
		document.getElementById('tabNews_1').className = 'tabMenuBtm';
		document.getElementById('tabNews_2').className = 'tabMenuTop';
	}
}

function votePoll(pid) {
	var o = eval('document.frmVote_' + pid);
	var params = '&id=' + pid;
	for (var i = 0; i < o.poll.length; i++) {
		if (o.poll[i].checked) {
			params += '&vote=' + o.poll[i].value;
			getAjax('voteAjax_' + pid, 'savevote', params);
		}
	}
}

function voteResult(pid) {
	var params = '&id=' + pid;
	getAjax('voteAjax_' + pid, 'resultvote', params);
}

function printFriendly(target) {
	var width  = 700;
	var height = 500;
	var left   = (screen.width  - width)/2;
	var top    = (screen.height - height)/2;
	myRef = window.open(target,'tvOnePrint', 'left='+ left +',top='+ top +',width='+ width +',height='+ height +',toolbar=0,location=no,resizable=1,scrollbars=yes');
	setTimeout('myRef.close()', 120000);
}
function sendShout(o) {
	if ((o.nm.value.length > 1 && o.nm.value.length <= 20) && (o.msg.value.length > 1 && o.msg.value.length <= 500) && o.sc.value.length == 5) {
		var params = '';
		params += '&t=add';
		params += '&tp=' + o.tp.value;
		params += '&nm=' + o.nm.value;
		params += '&msg=' + Base64.encode(o.msg.value);
		params += '&sc=' + o.sc.value;
		getAjax('shoutcontrol', 'shout', params);
	}
	return false;
}
function updateShout(t) {
	var params = '';
		params += '&t=load';
		params += '&tp=' + t;
	getAjax('msg', 'shout', params, 'none');
}
function playstream(alt, path) {
	if (!alt) alt = 'default';
	if (!path) path = 'http://www.tvone.co.id/themes/default/images/';
	if (alt == 'default') {
		streamer.write('player');
		document.getElementById('ch_1').src = path + 'channel_def.gif';
		document.getElementById('ch_2').src = path + 'channel_alt_h.gif';
	} else {
		streamer_alt.write('player');
		document.getElementById('ch_1').src = path + 'channel_def_h.gif';
		document.getElementById('ch_2').src = path + 'channel_alt.gif';
	}
}