function addswf(archivo,width,height) {
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">\n');
  document.write('<param name="movie" value="'+archivo+'">\n');
  document.write('<param name="quality" value="high">\n');
  document.write('<param name="wmode" value="transparent">\n');
  document.write('<param name="menu" value="false">\n');
  document.write('<param name="scale" value="showall">\n');
  document.write('<embed src="'+archivo+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" wmode="transparent"></embed>\n');
  document.write('</object>\n');
}

function np(url, ancho, alto) {
  xpos=(screen.width/2)-(ancho/2);
  ypos=(screen.height/2)-(alto/2);
  var feat = "resizable=1, scrollbars=yes, width="+ancho+", height="+alto+", left="+xpos+", top="+ypos;
  window.open(url, "popup", feat);
}

function np2(url, ancho, alto) {
  xpos=(screen.width/2)-(ancho/2)+50;
  ypos=(screen.height/2)-(alto/2)+50;
  var feat = "resizable=1, scrollbars=yes, width="+ancho+", height="+alto+", left="+xpos+", top="+ypos;
  window.open(url, "popup2", feat);
}

function showHideDiv(o) {
  var obj=document.getElementById(o);
  if(obj.style.display=='block') obj.style.display='none';
  else obj.style.display='block';
}

function extras(opcion) {
  if(opcion==1) document.getElementById('ptd_c_header_extras').style.backgroundPosition="-147px -24px";
  else if(opcion==2) document.getElementById('ptd_c_header_extras').style.backgroundPosition="-147px -48px";
  else document.getElementById('ptd_c_header_extras').style.backgroundPosition="-147px 0px";
}

function sethomepage() {
  if(document.all) {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage('http://www.tabascohoy.com/');
  }
  else if(window.sidebar) {
    if(window.netscape) {
      try {netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}
      catch(e) {alert("Esta acci\u00F3n fue deshabilitada por su navegador. Si desea habilitarla por favor escriba 'about:config' en la barra de direcciones y cambie el valor de 'signed.applets.codebase_principal_support' a 'true'");}
    }
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','http://www.tabascohoy.com/');
  }
}

function setfavoritos() {
  if((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
    var url="http://www.tabascohoy.com/";
    var titulo="TabascoHOY.com";
    window.external.AddFavorite(url,titulo);
  }
  else {
    if(navigator.appName=="Netscape") alert("Presione Crtl+D para agregar este sitio en sus Favoritos");
  }
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

// Windows Media Player
WMPObject = function(mov, id, w, h) {
  this.mov = mov;
  this.id = id;
  this.width = w;
  this.height = h;
  this.redirect = "";
  this.sq = document.location.search.split("?")[1] || "";
  this.altTxt = "Se requiere el Plugin de Microsoft Windows Media.<br /><a href='http://www.microsoft.com/windows/windowsmedia/download/'>Descarga Windows Media Player aquí</a>.";
  this.bypassTxt = "<p>Ya tienes Windows Media Player? <a href='?detectwmp=false&"+ this.sq +"'>Presiona aquí.</a></p>";
  this.params = new Object();
  this.doDetect = getQueryParamValue('detectwmp');
}

WMPObject.prototype.addParam = function(name, value) {this.params[name] = value;}
WMPObject.prototype.getParams = function() {return this.params;}
WMPObject.prototype.getParam = function(name) {return this.params[name];}
WMPObject.prototype.getParamTags = function() {
  var paramTags = "";
  for(var param in this.getParams()) paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
  if(paramTags=="") paramTags = null;
  return paramTags;
}

WMPObject.prototype.getHTML = function() {
  var wmpHTML = "";
  if(navigator.plugins && navigator.plugins.length) {
    wmpHTML += '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="' 
            + this.mov + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '"';
    for(var param in this.getParams())  wmpHTML += ' ' + param + '="' + this.getParam(param) + '"';
    wmpHTML += '></embed>';
  }
  else {
    wmpHTML += '<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '">';
    this.addParam("src", this.mov);
    if(this.getParamTags()!=null) wmpHTML += this.getParamTags();
    wmpHTML += '</object>';
  }
  return wmpHTML;
}

WMPObject.prototype.getVariablePairs = function() {
  var variablePairs = new Array();
  for (var name in this.getVariables()) variablePairs.push(name + "=" + escape(this.getVariable(name)));
  if(variablePairs.length>0) return variablePairs.join("&");
  else return null;
}

WMPObject.prototype.write = function(elementId) {
  if(isWMPInstalled() || this.doDetect=='false') {
    if(elementId) document.getElementById(elementId).innerHTML = this.getHTML();
    else document.write(this.getHTML());
  }
  else {
    if(this.redirect!="") document.location.replace(this.redirect);
    else {
      if(elementId) document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
      else document.write(this.altTxt +""+ this.bypassTxt);
    }
  }		
}

function isWMPInstalled() {
  var wmpInstalled = false;
  wmpObj = false;
  if(navigator.plugins && navigator.plugins.length) {
    for(var i=0; i<navigator.plugins.length; i++) {
      var plugin = navigator.plugins[i];
      if(plugin.name.indexOf("Windows Media Player")>-1) wmpInstalled = true;
    }
  }
  else {
    execScript('on error resume next: wmpObj = IsObject(CreateObject("MediaPlayer.MediaPlayer.1"))','VBScript');
    wmpInstalled = wmpObj;
  }
  return wmpInstalled;
}

function getQueryParamValue(param) {
  var q = document.location.search;
  var detectIndex = q.indexOf(param);
  var endIndex = (q.indexOf("&", detectIndex)!=-1)?q.indexOf("&", detectIndex):q.length;
  if(q.length>1 && detectIndex!=-1) return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
  else return "";
}

function myWMPlayer (mymediaid,myfile,width,height,showcontrols,showdisplay,showstatusbar,autoplay,autostart) {
  var myfilename = addPath(myfile);
  var qtVid = new WMPObject(myfilename, 'MMPlayer1', width, height);
  qtVid.addParam('TYPE', 'application/x-mplayer2');
  qtVid.addParam('PLUGINSPACE', 'http://www.microsoft.com/Windows/MediaPlayer/download/default.asp');
  qtVid.addParam('ShowControls', showcontrols);
  qtVid.addParam('ShowDisplay', showdisplay);
  qtVid.addParam('ShowStatusBar', showstatusbar);
  qtVid.addParam('Autoplay', autoplay);
  qtVid.addParam('Autostart', autostart);
  qtVid.addParam('DefaultFrame', 'Slide');
  qtVid.write(mymediaid);
}

function findPath() {
  var URL = unescape(location.href);
  var xstart = URL.lastIndexOf("/")+1;
  var xend = URL.length;
  var hereName = URL.substring(xstart,xend);
  var herePath = URL.substring(0,xstart);
  var path=herePath;
  var pos1 = herePath.search(/file:\/\//);
  if(pos1!=-1) {
    var pos2 = herePath.search(/localhost/);
    var pleng = herePath.length;
    if(pos2!=-1) {
      var keep=herePath.substring(pos2+10,pleng);
      path = "file://" + keep;
    }
  }
  return path;
}

function addPath(fn) {
  var filename = fn;
  var fix1 =  filename.search(/http:/);
  var fix2 =  filename.search(/file:/);
  var path = findPath();
  if((fix1==-1) && (fix2==-1)) filename=path+filename; else filename=fn;
  return filename;
}

QTObject = function(mov, id, w, h) {
  this.mov = mov;
  this.id = id;
  this.width = w;
  this.height = h;
  this.redirect = "";
  this.sq = document.location.search.split("?")[1] || "";
  this.altTxt = "Este contenido requiere el Plugin de QuickTime.<br /><a href='http://www.apple.com/quicktime/download/'>Descargar QuickTime Player</a>.";
  this.bypassTxt = "<p>Ya tienes QuickTime Player? <a href='?detectqt=false&"+ this.sq +"'>Presiona aquí.</a></p>";
  this.params = new Object();
  this.doDetect = getQueryParamValue('detectqt');
}

QTObject.prototype.addParam = function(name, value) {this.params[name] = value;}
QTObject.prototype.getParams = function() {return this.params;}
QTObject.prototype.getParam = function(name) {return this.params[name];}
QTObject.prototype.getParamTags = function() {
  var paramTags = "";
  for(var param in this.getParams()) paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
  if(paramTags=="") paramTags = null;
  return paramTags;
}

QTObject.prototype.getHTML = function() {
  var qtHTML = "";
  if(navigator.plugins && navigator.plugins.length) {
    qtHTML += '<embed type="video/quicktime" src="'+this.mov+'" width="'+this.width+'" height="'+this.height+'" id="'+this.id+'"';
    for(var param in this.getParams()) qtHTML += ' ' + param + '="' + this.getParam(param) + '"';
    qtHTML += '></embed>';
  }
  else {
    qtHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+this.width+'" height="'+this.height+'" id="'+this.id+'">';
    this.addParam("src", this.mov);
    if(this.getParamTags()!=null) qtHTML += this.getParamTags();
    qtHTML += '</object>';
  }
  return qtHTML;
}

QTObject.prototype.getVariablePairs = function() {
  var variablePairs = new Array();
  for(var name in this.getVariables()) variablePairs.push(name + "=" + escape(this.getVariable(name)));
  if(variablePairs.length>0) return variablePairs.join("&");
  else return null;
}

QTObject.prototype.write = function(elementId) {
  if(isQTInstalled() || this.doDetect=='false') {
    if(elementId) document.getElementById(elementId).innerHTML = this.getHTML();
    else document.write(this.getHTML());
  }
  else {
    if(this.redirect!="") document.location.replace(this.redirect);
    else {
      if(elementId) document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
      else document.write(this.altTxt +""+ this.bypassTxt);
    }
  }		
}

function isQTInstalled() {
  var qtInstalled = false;
  qtObj = false;
  if(navigator.plugins && navigator.plugins.length) {
    for(var i=0; i<navigator.plugins.length; i++) {
      var plugin = navigator.plugins[i];
      if(plugin.name.indexOf("QuickTime")>-1) qtInstalled = true;
    }
  }
  else {
    execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
    qtInstalled = qtObj;
  }
  return qtInstalled;
}

function getQueryParamValue(param) {
  var q = document.location.search;
  var detectIndex = q.indexOf(param);
  var endIndex = (q.indexOf("&", detectIndex)!=-1)?q.indexOf("&", detectIndex):q.length;
  if(q.length>1 && detectIndex!=-1) return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
  else return "";
}

// QuickTime Plugin
QTObject = function(mov, id, w, h) {
  this.mov = mov;
  this.id = id;
  this.width = w;
  this.height = h;
  this.redirect = "";
  this.sq = document.location.search.split("?")[1] || "";
  this.altTxt = "Este contenido requiere el Plugin de QuickTime.<br /><a href='http://www.apple.com/quicktime/download/'>Descargar QuickTime Player</a>.";
  this.bypassTxt = "<p>Ya tienes QuickTime Player? <a href='?detectqt=false&"+ this.sq +"'>Presiona aquí.</a></p>";
  this.params = new Object();
  this.doDetect = getQueryParamValue('detectqt');
}

QTObject.prototype.addParam = function(name, value) {this.params[name] = value;}
QTObject.prototype.getParams = function() {return this.params;}
QTObject.prototype.getParam = function(name) {return this.params[name];}
QTObject.prototype.getParamTags = function() {
  var paramTags = "";
  for(var param in this.getParams()) paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
  if(paramTags=="") paramTags = null;
  return paramTags;
}

QTObject.prototype.getHTML = function() {
  var qtHTML = "";
  if(navigator.plugins && navigator.plugins.length) {
    qtHTML += '<embed type="video/quicktime" src="'+this.mov+'" width="'+this.width+'" height="'+this.height+'" id="'+this.id+'"';
    for(var param in this.getParams()) qtHTML += ' ' + param + '="' + this.getParam(param) + '"';
    qtHTML += '></embed>';
  }
  else {
    qtHTML += '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="'+this.width+'" height="'+this.height+'" id="'+this.id+'">';
    this.addParam("src", this.mov);
    if(this.getParamTags()!=null) qtHTML += this.getParamTags();
    qtHTML += '</object>';
  }
  return qtHTML;
}

QTObject.prototype.getVariablePairs = function() {
  var variablePairs = new Array();
  for(var name in this.getVariables()) variablePairs.push(name + "=" + escape(this.getVariable(name)));
  if(variablePairs.length>0) return variablePairs.join("&");
  else return null;
}

QTObject.prototype.write = function(elementId) {
  if(isQTInstalled() || this.doDetect=='false') {
    if(elementId) document.getElementById(elementId).innerHTML = this.getHTML();
    else document.write(this.getHTML());
  }
  else {
    if(this.redirect!="") document.location.replace(this.redirect);
    else {
      if(elementId) document.getElementById(elementId).innerHTML = this.altTxt +""+ this.bypassTxt;
      else document.write(this.altTxt +""+ this.bypassTxt);
    }
  }		
}

function isQTInstalled() {
  var qtInstalled = false;
  qtObj = false;
  if(navigator.plugins && navigator.plugins.length) {
    for(var i=0; i<navigator.plugins.length; i++) {
      var plugin = navigator.plugins[i];
      if(plugin.name.indexOf("QuickTime")>-1) qtInstalled = true;
    }
  }
  else {
    execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript');
    qtInstalled = qtObj;
  }
  return qtInstalled;
}

function getQueryParamValue(param) {
  var q = document.location.search;
  var detectIndex = q.indexOf(param);
  var endIndex = (q.indexOf("&", detectIndex)!=-1)?q.indexOf("&", detectIndex):q.length;
  if(q.length>1 && detectIndex!=-1) return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
  else return "";
}