if(screen.width < 1280) 
  document.write("<link rel='stylesheet' href='http://bigporntv.com/js/style1024.css' type='text/css'>");

$(document).ready(
  function()
  {
	$("i#href_pop_y").each(function(){
		$(this).replaceWith("<a href='/popular/'>best videos</a>");
		});
	$("i#href_pop_n").each(function(){
		$(this).replaceWith("<a href='#'>best videos</a>");
		});		
		
	$("i#href_lat_y").each(function(){
		$(this).replaceWith("<a href='/latest/'>new videos (<span>+700</span>)</a>");
		});
	$("i#href_lat_n").each(function(){
		$(this).replaceWith("<a href='#'>new videos (<span>+700</span>)</a>");
		});             		
  }
);

$(document).ready(
  function()
  {
	$("i#rep").each(function(){
		$(this).replaceWith("<a href='" + $(this).attr("title") + "'>" + $(this).text() + "</a>");
		});
		
	$("i#rep1").each(function(){
		$(this).replaceWith("<a href='" + $(this).attr("title") + "'>" + $(this).text() + "</a>");
		});	

	$("i#rep2").each(function(){
		$(this).replaceWith("<a href='" + $(this).attr("title") + "'>" + $(this).text() + "</a>");
		});
    
    
	$("i#rep3").each(function(){
		$(this).replaceWith("<a href='" + $(this).attr("title") + "'>" + $(this).text() + "</a>");
		});
		
	$("i#rep4").each(function(){
		$(this).replaceWith("<a href='" + $(this).attr("title") + "'>" + $(this).text() + "</a>");
		});	

	$("i#rep5").each(function(){
		$(this).replaceWith("<a href='" + $(this).attr("title") + "'>" + $(this).text() + "</a>");
		});    	    	
  }
);

function add_favorite(a) { 
  title=document.title; 
  url=document.location; 
  try {  
    window.external.AddFavorite(url, title); 
  } 
  catch (e) { 
    try {  
      window.sidebar.addPanel(title, url, ""); 
    } 
    catch (e) {  
      if (typeof(opera)=="object") { 
        a.rel="sidebar"; 
        a.title=title; 
        a.url=url; 
        return true; 
      } 
      else { 
        alert('Press Ctrl-D for add to bookmarks'); 
      } 
    } 
  } 
  return false; 
}

var catSelects = Array();

function prepareHTTPRequest(){
	var HttpRequest;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		HttpRequest = new XMLHttpRequest();
		if (HttpRequest.overrideMimeType) {
			HttpRequest.overrideMimeType('text/xml');
			// See note below about this line
		}
	} 
	else if (window.ActiveXObject) { // IE
		// assume IE6 or older
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
										"MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
		// try every prog id until one works
		for (var i=0; i<XmlHttpVersions.length && !HttpRequest; i++){
		  try{ 
			// try to create XMLHttpRequest object
			HttpRequest = new ActiveXObject(XmlHttpVersions[i]);
		  }catch (e){} // ignore potential error
		}
	}

	if (!HttpRequest){
		alert('Cannot create an XMLHTTP instance');
		return false;
	}
	return HttpRequest;
}

function loadcat(xml)
{
	var el=document.getElementById('catlist');
	if (catSelects[xml] != true)
	{
		loading = document.createElement('div');
		loading.appendChild(document.createTextNode('Loading...'));
		el.appendChild(loading);
		
		httpRequest = prepareHTTPRequest()
		httpRequest.onreadystatechange = function() { 
			if (httpRequest.readyState == 4){
				if (httpRequest.status == 200){
					try{
						el.removeChild(loading);
						el.innerHTML=httpRequest.responseText;
					}catch(e){alert('Error:' + e)}
				}
			}
		}
		httpRequest.open('GET', xml, true);
		httpRequest.send(null);
		catSelects[xml]=true;
	}
	el.style.display='block';
}
function hideCategories(e)
{
	if(!e)e = window.event;
	var clickedEl = e.target ? e.target : e.srcElement;
	if (clickedEl.id != 'catsel')
	{
		var el=document.getElementById('catlist');
		el.style.display='none';
	}
}
document.onclick = hideCategories;
