/* Open window functions -----START */
function openFile(url, width, height) {
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var parameters = 'toolbar=no,status=no,scrollbars=no,location=no,resizable=no,dependent,width=' + width +',height=' + height +',left=' + left + ',top=' + top;
	newWindow = window.open(url, 'file_w', parameters);
}
function openFileScroll(url, width, height) {
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var parameters = 'toolbar=no,status=no,scrollbars=yes,location=no,resizable=no,dependent,width=' + width +',height=' + height +',left=' + left + ',top=' + top;
	newWindow = window.open(url, 'file_ws', parameters);
}
function openFileSR(url, width, height) {
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top = parseInt((screen.availHeight/2) - (height/2));
	var parameters = 'toolbar=no,status=no,scrollbars=yes,location=no,resizable=yes,dependent,width=' + width +',height=' + height +',left=' + left + ',top=' + top;
	newWindow = window.open(url, 'file_wsr', parameters);
}
/* Open window functions -----END */

//Get FileName of the current document.
function get_file_name() {
	var path = window.location.pathname;
	var st = path.split("/");
	var stlength = st.length;
	var file_query = st[stlength - 1];
	var filename = file_query;
	var new_file = file_query.split("?");
	filename = new_file[0];
	return filename;
}

/* Get Variables from location query -----START */
function parse_get_vars(varname) {
	var query = window.location.search;
	if(query != "") {
		var st = query.split("?");
		var para = st[1].split("&");
		var chk = 0;
		for(i=0; i < para.length; i++) {
			chk = para[i].search(varname);
			if(chk != -1) {
				var value = para[i].split("=");
				return value[1];
			}
		}
	}else {
		return query;
	}
}
function get_vars(varname) {
	var return_var = parse_get_vars(varname);
	if(return_var == null) {
		var nul = "";
		return_var = nul;
	}
	return return_var;
}
/* Get Variables from location query -----END */

//Include a JS file Dynamically
function include(path, file, param) {
	if(param == "") {
		if(path == "") {
			document.write('<' + 'script src="' + file + '"' +' type="text\/javascript"><' + '\/script>');
		}else{
			document.write('<' + 'script src="' + path + file + '"' +' type="text\/javascript"><' + '\/script>');	
		}
	}else{
		if(path == "") {
			document.write('<' + 'script src="' + file + param + '"' +' type="text\/javascript"><' + '\/script>');
		}else{
			document.write('<' + 'script src="' + path + file + param + '"' +' type="text\/javascript"><' + '\/script>');	
		}
	}
}

//Add Option to Select
function add_opt2Sel(obj, param, optTXT, optVAL) {
	if(param == "") {
		var objSel = document.getElementById(obj);		
	}	
	if(param == "pop") {
		var objSel = window.opener.document.getElementById(obj);
	}
	var opt = document.createElement('option');
	opt.text = optTXT;
	opt.value = optVAL;
	try {
		objSel.add(opt,null);
	}
	catch(ex) {
		objSel.add(opt);
	}
}
//Remove Option from Select
function remove_optFrmSel(obj, param) {
	if(param == "") {
		var objSel = document.getElementById(obj);		
	}	
	if(param == "pop") {
		var objSel = window.opener.document.getElementById(obj);
	}
	objSel.remove(objSel.selectedIndex);
}

//Get Object from Opener or Parent
function get_obj(obj, param) {
	if(param == "") {
		var returnObj = document.getElementById(obj);		
	}	
	if(param == "pop") {
		var returnObj = window.opener.document.getElementById(obj);
	}
	return returnObj;
}
//Display Section ComboBox
function disp_sections(selParam) {
	var sec_label = new Array();
	var sec_values = new Array();
	sec_label[0] = "Select Section";
	sec_label[1] = "All";
	sec_label[2] = "Top Story";
	sec_label[3] = "West Bengal";
	sec_label[4] = "National";
	sec_label[5] = "International";
	sec_label[6] = "Business";
	sec_label[7] = "Sports";
	sec_label[8] = "Entertainment";
	
	sec_values[0] = "Select";
	sec_values[1] = "All";
	sec_values[2] = "TopStory";
	sec_values[3] = "WestBengal";
	sec_values[4] = "National";
	sec_values[5] = "International";
	sec_values[6] = "Business";
	sec_values[7] = "Sports";
	sec_values[8] = "Entertainment";
	
	if(selParam == "") {
		selParam = "Select";
	}
	
	document.write ('<select name="sec" id="sec">');
   	for(i=0; i<sec_label.length; i++) {
		if(selParam == sec_values[i]) {
			document.write('<option value="'+sec_values[i]+'" selected="selected">'+sec_label[i]+'<\/option>');
		}else{
			document.write('<option value="'+sec_values[i]+'">'+sec_label[i]+'<\/option>');
		}
	}   
    document.write('<\/select>');
}

//Display Day
function disp_day(selParam){
	document.write ('<select name="day" id="day">');
	document.write('<option value="Select">Select Day<\/option>');
	for(i=1; i<=31; i++) {
		if(selParam == i) {
			document.write('<option value="'+i+'" selected="selected">'+i+'<\/option>');
		}else{
			document.write('<option value="'+i+'">'+i+'<\/option>');
		}
	}   
    document.write('<\/select>');
	document.write('&nbsp;');
}

//Display Day
function disp_month(selParam){
	var months = new Array();
	months[0] = "Select Month";
	months[1] = "January";
	months[2] = "February";
	months[3] = "March";
	months[4] = "April";
	months[5] = "May";
	months[6] = "June";
	months[7] = "July";
	months[8] = "August";
	months[9] = "September";
	months[10] = "October";
	months[11] = "November";
	months[12] = "December";
	if(selParam == "") {
		selParam = "Select Month";
	}	
	document.write ('<select name=month" id="month">');
   	for(i=0; i<months.length; i++) {
		if(selParam == months[i]) {
			document.write('<option value="'+months[i]+'" selected="selected">'+months[i]+'<\/option>');
		}else{
			document.write('<option value="'+months[i]+'">'+months[i]+'<\/option>');
		}
	}   
    document.write('<\/select>');
	document.write('&nbsp;');
}
//Display Day
function disp_year(selParam, start, end){
	document.write ('<select name="year" id="year">');
	document.write('<option value="Select">Select Year<\/option>');
	for(i=start; i<=end; i++) {
		if(selParam == i) {
			document.write('<option value="'+i+'" selected="selected">'+i+'<\/option>');
		}else{
			document.write('<option value="'+i+'">'+i+'<\/option>');
		}
	}   
    document.write('<\/select>');
	document.write('&nbsp;');
}

//Detect OS
function check_os(os) {
	var status=false;
	var info = navigator.appVersion.toLowerCase();
	if (info.indexOf(os)!=-1) {
		status=true;	
	}
	return status;
}
/*var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";*/

//Glogal Variables
var scriptPath = "Scripts/";
var hlscrolldb = "db_latest.php";
var disp_hlscroll = "disp_latest.js";
var player_cp = "player.js";
var left_menu = "main_left.js.php";

var pgname = get_file_name();

if(pgname == "tv_live.php") {
	include(scriptPath, player_cp, "");
}

