function ajaxMixed() {
$('download_window').innerHTML="<img src='_img/loading_red.gif' border='0'/>";


URL = $F('url'); 

if (URL.match(/tvtod.com/)){
 var vidID = URL.between('&video=','&');
 var URL = 'http://tvtod.com/videos/?video='+vidID;
 }
 
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}
URL = URL.trim();
	var sizeofurl = URL.length;
	if(sizeofurl >= 8){
	var check = URL.substring(0, 7); 
	if (check != "http://") {
	URL = "http://" + URL;
	}
}else{
alert('Invalid Video Link Enter. Recheck');
SizeMismatch();
}


var myAjaxReq = new Ajax.Request('token.php', {method:'post',parameters: 'url='+escape(URL), onCreate: checkURL,onSuccess: getResponsesInternal, onFailure: ErrorRequest} );
function getResponsesInternal(oReq) {
  var newdata = oReq.responseText;
var myAjaxUp = new Ajax.Updater({success: 'download_window'}, 'processor.php', {method: 'get', parameters: oReq.responseText, onFailure: ErrorUpdater});

}
}

function ErrorRequest() {
$('download_window').innerHTML="Wrong URL format Enter proper Video Link";
}

function ErrorUpdater() {
$('download_window').innerHTML="No Video Found :(<br>Wrong Video Link ? Cookies Off ? Javascript Off? <br>Might be Site Not Supported <a href='http://kcoolonline.com/guestbook.php'>Report</a>";
}

function SizeMismatch() {
$('download_window').innerHTML="Invalid Link. Check your video link and retry.";
exit;
}




function focusURL(){
document.getElementById('url').focus();
document.getElementById('JavascriptDisabled').style.display = "none";
checkCookie();

}



  function toggleDiv(divid){
   
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
    }else{
      document.getElementById(divid).style.display = 'none';
    }
  }
  


function checkCookie() {

var name = 'Detect';
var value = 'kcoolonline.com';
var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";
	if (document.cookie.indexOf(name+'=') == -1){
	alert("Your Browser Cookie is Disabled! Enable it or site will not function!");
$('cookie').innerHTML="Cookie Disabled";
	
	}
	querystring = location.search.substring(1); 
    var thevalue =querystring.indexOf('nojs=1');
	
     if (thevalue==0) //
    { 
 	alert ('JavaScript Turned On & Cookies is also ON. Thankyou. Redirecting...');
	window.location = "http://www.kcoolonline.com/";
  
     }else{
		}
	document.cookie = name+'=""; expires=Fri, 3 Aug 2001 20:47:11 UTC; path=/'
}


function checkURL()
{
var videoURL = $F('url');
 if (videoURL.match(/youtube.com/)||videoURL.match(/megavideo.com/)||videoURL.match(/dailymotion.com/)||videoURL.match(/metacafe.com/)||videoURL.match(/vimeo.com/)) {
  urlredirect = 'http://kcoolonline.com/java.php?url=';
document.location=urlredirect+videoURL;
   } else {}
}



function createCookie(name,value,days) {

	if (days) {

		var date = new Date();

		date.setTime(date.getTime()+(days*24*60*60*1000));

		var expires = "; expires="+date.toGMTString();

	}

	else var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";

}



function readCookie(name) {

	var nameEQ = name + "=";

	var ca = document.cookie.split(';');

	for(var i=0;i < ca.length;i++) {

		var c = ca[i];

		while (c.charAt(0)==' ') c = c.substring(1,c.length);

		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

	}

	return null;

}



function eraseCookie(name) {

	createCookie(name,"",-1);

	alert('Cookie Removal Complete');

}



function sendtoxbox(url){

	var cookie = readCookie('xboxip');

	if(cookie==null){

		alert("We are about to setup your Xbmc client to allow direct linking from flvstorm.\nThe following should only be done if you are behind a router, DO NOT expose your xbox directly to the internet without caution.\n\nMake sure your Xbmc webserver is enabled, and note your xbox's ip address.");

		var xboxip = prompt('Please enter your xbox ip', '192.168.0.102 ');

		createCookie('xboxip',xboxip,99);

		var cookie = readCookie('xboxip');

		$('download_window').innerHTML='<a href="http://'+cookie+'/xbmcCmds/xbmcHttp?command=playfile&amp;parameter='+url+'" target="_blank">Send</a>';

	}else{

		$('download_window').innerHTML='<a href="http://'+cookie+'/xbmcCmds/xbmcHttp?command=playfile&amp;parameter='+url+'" target="_blank">Send</a>';

	}

}





String.prototype.between = function(prefix, suffix) {
  s = this;
  var i = s.indexOf(prefix);
  if (i >= 0) {
    s = s.substring(i + prefix.length);
  }
  else {
    return '';
  }
  if (suffix) {
    i = s.indexOf(suffix);
    if (i >= 0) {
      s = s.substring(0, i);
    }
    else {
      return '';
    }
  }
  return s;
}

