function getDirFromURL(obj) {
	obj.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	obj.dom = obj.dir;
	
	if (obj.dom.substr(0,7) == 'http:\/\/') {
		obj.dom = obj.dom.substr(7);
	}//end_if
	
	obj.path = '';
	var pos = obj.dom.indexOf('\/');

	if (pos > -1) {
		obj.path = obj.dom.substr(pos+1);
		obj.dom = obj.dom.substr(0,pos);
	}//end_if

	return obj;
}//end_function

function showClipOptions(sID, iShow) {
  obj = document.getElementsByName(sID);

  if (obj!=null && obj.length>0) {
    for(i=0;i<obj.length;i++) { 
      obj[i].style.display = (iShow == 1 ? 'block' : 'none');
    }//end_for

    obj[0].parentNode.selectedIndex = obj[0].index;
  }//end_if
}//end_function

function downloadClip(sID) {
  obj = document.getElementById(sID);

  if (obj!=null) {
    if (obj.value!='') {
      var uri = new Object();
      uri = getDirFromURL(uri);
      window.open('http://'+uri.dom+'/'+obj.value);
    } else {
      alert('Please select the version and the quality of the video!');
    }//end_if
  }//end_if
}//end_function


function switchObjDisplay(sID, iShow) {
  obj = document.getElementById(sID);
  if (obj!=null) {
    obj.style.display = iShow ? 'block' : 'none';
  }//end_if
}//end_function

function setObjValue(sID, sValue){
  obj = document.getElementById(sID);

  if (obj!=null) {
    obj.value = sValue;
  }//end_if
}//end_function

function setObjHref(sID, sValue){
  obj = document.getElementById(sID);

  if (obj!=null) {
    obj.href = sValue;
  }//end_if
}//end_function

function setObjInnerHTML(sID, sValue){
  obj = document.getElementById(sID);

  if (obj!=null) {
    obj.innerHTML = sValue;
  }//end_if
}//end_function


//Mozilla
function getInstallURL(aEvent) {
 
    // The event target might be the link itself or one of its children
    var target = aEvent.target;
    while (target && !target.href)
      target = target.parentNode;
    
    return target && target.href;
}

function install( aEvent, extName, iconURL, extHash)  {   

    if (aEvent.altKey || !window.InstallTrigger)
        return true;

    var url = getInstallURL(aEvent);

    if (url) {

        var params = new Array();

        params[extName] = {
            URL: url,
            IconURL: iconURL,
            toString: function () { return this.URL; }
        };

        // Only add the Hash param if it exists.
        //
        // We optionally add this to params[] because installTrigger
        // will still try to compare a null hash as long as the var is set.
        if (extHash) {
            params[extName].Hash = extHash;
        }

        InstallTrigger.install(params);

        return false;
    }
    return true;
}

function switchBrowser(brow,os){
	switchObjDisplay('ieDwnld', 0); 
	switchObjDisplay('ffDwnld', 0); 
	switchObjDisplay('ffMacDwnld', 0); 
	switchObjDisplay('help_ie', 0); 
	switchObjDisplay('help_ff', 0);
	
	document.getElementById("radioFF").checked = false;
	document.getElementById("radioIE").checked = false;


	if(!brow){
		brow = "";
		if(navigator.userAgent.indexOf("Firefox")!=-1)
			brow = "FF";

		if(navigator.userAgent.indexOf("MSIE")!=-1)
			brow = "IE";
	}
	if(!os){
		if(navigator.platform.indexOf("Win")!=-1)
			os = "win";

		if(navigator.platform.indexOf("Mac")!=-1)
			os = "mac";
	}
	var browser = os+brow;
	switch(browser){
		case "winFF":
			switchObjDisplay('ffDwnld', 1);
			switchObjDisplay('help_ff', 1);
			document.getElementById("radioFF").checked = true;
			break;
		case "macIE":
		case "macFF":
			switchObjDisplay('ffMacDwnld', 1);
			switchObjDisplay('help_ff', 1);
			document.getElementById("radioFF").checked = true;
			break;

		case "winIE":
		default:
			switchObjDisplay('ieDwnld', 1);
			switchObjDisplay('help_ie', 1);
			document.getElementById("radioIE").checked = true;
			break;

	}
}
