
/* for the quest string */
/* http://adamv.com/dev/javascript/querystring */
function Querystring(qs) {
	this.params = {};
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&');
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		this.params[name] = value;
	}
}
Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}
Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

var qs = new Querystring();
if ( isVideosPicks() ) {
	//$('videos_picks_tab').addClassName("active");
	document.getElementById('videos_picks_tab').className = "C";
	document.getElementById('our_web_picks_tab').className = "notC";
	document.getElementById('all_the_web_tab').className = "notC";
//our web picks
} else if ( isOurWebPicks() ) {
	//$('our_web_picks_tab').addClassName("active");
	document.getElementById('videos_picks_tab').className = "notC";
	document.getElementById('our_web_picks_tab').className = "C";
	document.getElementById('all_the_web_tab').className = "notC";
//all the web
} else if ( isAllTheWeb() ) {
	//$('all_the_web_tab').addClassName("active");
	document.getElementById('videos_picks_tab').className = "notC";
	document.getElementById('our_web_picks_tab').className = "notC";
	document.getElementById('all_the_web_tab').className = "C";
} else {
	//do nothing..
}
/*******/
//return true if it is vidoes picks
function isVideosPicks() {
	var cx= qs.get("cx");
	return (cx === "004426306133694050622:t8qlztzaqos");
}
//return true if it is our web picks
function isOurWebPicks() {
	var cx= qs.get("cx");
	return (cx === "partner-pub-7976541245634691:kg3w5g-tt1n");
}
//return true if it is all the web
function isAllTheWeb() {
	var cx= qs.get("cx");
	return (cx === "004426306133694050622:dvw57yhzlfy");
}

//return the url for the videos pick
function getVideosPicksUrl() {
	if ( isVideosPicks() ) {
		return window.location;
	} else {
		var uri = window.location.href.split("?");
		return uri[0] + "?cx=004426306133694050622:t8qlztzaqos&cof=FORID%3A10&ie=ISO-8859-1&q=" + escape(qs.get("q")) + "&sa=Search";
	}
}
//return the url for the our web pick
function getOurWebPicksUrl() {
	if ( isOurWebPicks() ) {
		return window.location;
	} else {
		var uri = window.location.href.split("?");
		return uri[0] + "?cx=partner-pub-7976541245634691:kg3w5g-tt1n&cof=FORID%3A10&ie=ISO-8859-1&q=" + escape(qs.get("q")) + "&sa=Search";
	}
}
//return the url for the all the web
function getAllTheWeb() {
	if ( isAllTheWeb() ) {
		return window.location;
	} else {
		var uri = window.location.href.split("?");
		return uri[0] + "?cx=004426306133694050622:dvw57yhzlfy&cof=FORID%3A10&ie=ISO-8859-1&q=" + escape(qs.get("q")) + "&sa=Search";
	}
}

function goVideosPicks() {
	window.location = getVideosPicksUrl();
}
function goOurWebPicks() {
	window.location = getOurWebPicksUrl();
	
}

function goAllTheWeb() {
	window.location = getAllTheWeb();
}
