/*
var parentWindowVar		= "purl=";
var detectSuccessUrl 	= "/vspot/player.jhtml";
var detectFailUrl 		= "/vspot/index.jhtml";
var detectFailUrlWin 	= "/vspot/player_detect.jhtml";
var winWidth 			= "750";
var winHeight 			= "555";
*/

var parentWindowVar		= "purl=";
var detectSuccessUrl 	= "/video/play.jhtml";
var detectFailUrl 		= "/video/index.jhtml";
var detectFailUrlWin 	= "/video/player_detect.jhtml";
var winWidth 			= "750";
var winHeight 			= "555";

function launchVspot() {

	//launchVspot('id=1536681&vid=97279');
	//launchVspot('id=1536681','vid=97279');
	
	var id = null;
	var vid = null;
	var name = null;
	
	var videoURL = "/video/";
	var params = "?";
	
	//http://www.vh1-d.mtvi.com/video/play.jhtml?id=1536681&vid=97279
	
	if (arguments.length > 0) {
		for(var i=0; i<arguments.length; i++){
			if(arguments[i].indexOf('&')>-1){
				var pairs = arguments[i].split('&');
				for(var j = 0; j <pairs.length; j++){
					var namevalue = pairs[j].split('=');	
					if(namevalue[0]=='id')
						id = namevalue[1];
					if(namevalue[0]=='vid')	
						vid = namevalue[1];	
					if(namevalue[0]=='name')	
						name = namevalue[1];	
				}
			}
			else {
				var namevalue = arguments[i].split('=');
				if(namevalue[0]=='id')
					id = namevalue[1];
				if(namevalue[0]=='vid')	
					vid = namevalue[1];	
				if(namevalue[0]=='name')	
					name = namevalue[1];	
			}
		}
		
		//System.out.println('id='+id);
		//System.out.println('vid='+vid);
		//System.out.println('name='+name);
	}
	else{
		// no usable arguments - load the /video/ page
	
	}	
	
	if(id==null && vid==null && name==null){
		
		document.location.href = '/video/';
		return;
	}
	else if(id==null && vid==null && name!=null){
		// redirect to the name page
		var redirectPage = "/video/"
		if(name != 'editorspicks' || name != 'featured'){
			redirectPage += name+'.jhtml';
		}
		
		//System.out.println('redirect to:'+redirectPage);
		document.location.href = redirectPage;
		return;
	}
	else{
	
		var redirectPage = '/video/play.jhtml';
		
		var params = '';
		if(id!=null || vid !=null || name!=null)
			params += '?';
		
		if(id!=null)
			params+='id='+id;
		
		if(vid!=null){
			if(id!=null)
				params+='&';
			params+='vid='+vid;
		}
		
		if(name!=null){
			if(id!=null || vid !=null)
				params+='&';
			params+='name='+name;
		
		}
	
		document.location.href = redirectPage+params;
		return;
	}
}


/*
function launchVspot() {
	
	var arg = "";
	
	if (arguments.length > 0) {
	
		detectFailUrl += "?";
	
		for (var i = 0; i < arguments.length; i++) {

				if (i == 0) detectFailUrl += arguments[i];
				if (i != 0) {
					arg += ", ";
					detectFailUrl += ("&" + arguments[i]);
				}
				arg += ("'" + arguments[i] + "'");
			}
		}	
	
	eval("launchOverdrive(" + arg + ")");
}
*/