/*
//find query attached
var pageLoc = String(document.location);
var queryPos = pageLoc.indexOf("?");
var queryString = (queryPos < 0) ? "" : pageLoc.substring(queryPos);

function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
}
*/

window.onerror = function(){ return true; };

//action tag
function actionTag(page){
	var actionLoad = 'http://switch.atdmt.com/action/';
	document.action_tag.src = actionLoad + page;
}

function popup( url, w, h, windowName, r, s ) {
	win = window.open(url, windowName, 'height=' +h+ ', width=' +w+ ', resizable=' +r+ ', status=no, scrollbars=' +s+ ', location=no, menubar=no, toolbar=no, left=50, top=50');
}

//local listings
function listings(){
	popup('http://bventertainment.go.com/tv/buenavista/atm/local_listings.html', 505, 400, 'listings', 'yes', 'yes');
}

//feedback
function feedback(){
	popup('http://bventertainment.go.com/tv/buenavista/atm/feedback.html', 400, 485, 'feedback', 'no', 'no');
}

function goPage() 
{
	var dd = document.getElementById('searchform_dropdownfield');
	
	if ((dd.options[dd.selectedIndex].value) != "/")
	{
		newURL=dd.options[dd.selectedIndex].value;
		document.location = newURL;
	}
}

function goPage(fieldID) 
{
	var dd = document.getElementById(fieldID);
	
	if ((dd.options[dd.selectedIndex].value) != "/")
	{
		newURL=dd.options[dd.selectedIndex].value;
		document.location = newURL;
	}
}


//Search Validate
function validate_required(field,alerttxt)
{
	
	with (field)
	{
		if (value==null||value=="")
 		{alert(alerttxt);return false;}
		else {return true}
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(subsec,"Type in at least one word to perform a search")==false)
 		{subsec.focus();return false;}
		else {return true;}
	}
}

//Validates the Search Field
function validate_search()
{
	var t = document.getElementById('searchform');
	if (t && validate_form(t))
	{
		t.submit();
	}

}

//Clears the form TextField
function reset_textfield(field)
{
	document.getElementById(field.id).value = "";
	document.getElementById(field.id).style.color = "#000000";
}

//Alerts all attributes
function alert_all_attrs(obj)
{
	var out = '';
	
	for (var attr_name in obj)
	{
		out += attr_name + " = " + obj[attr_name] + "\n";	
	
		if (out.length > 500)
		{
			alert(out);
			out = '';
		}
	
	}
	alert(out);

}

function ellipses(str, max_length)
{
	
	
	if (str.length > max_length)
	{
		return str.substring(0,max_length) + "...";
	}
	return str;
}