function captcha_refresh(image) 
{
    var element = document.getElementById(image);
    var posistion = element.src.indexOf("?");
    if (posistion == -1) {
        posistion = element.src.length;   
    }
    element.src = element.src.substring(0, posistion) + "?" + Math.round((Math.random()*10000000));
}

function startSearch(str,type)
{
    document.getElementById('searchField').value = str;
    document.getElementById('searchField').focus();
}
function checkLogin()                      
{
    if (typeof(loadXMLDoc) != "undefined") {
        loadXMLDoc("/signup.html?checklogin=" + escape(document.forms["bigForm"]["login"].value), function(req) {
        	document.forms["bigForm"]["login"].style.borderColor = (req.responseText == "true") ? "#40cc02" : "#ff0000";
        });
    }
}
function readCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0])
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
};

function setCookie(sName, sValue)
{
    document.cookie = escape(sName) + "=" + escape(sValue) + "; path=/";
    return true;


/*
	//we'll keep the cookie for 30 days
    var expires = new Date();
    expires.setTime(expires.getTime()+(30 *24*60*60*1000));
    document.cookie= sName + '=' + sValue +'; expires='+ expires.toGMTString() +'; path=/;' ;
*/
}

function observeElement(element, name, observer) {
	if (element.addEventListener) {
		element.addEventListener(name, observer, false);
	} else if (element.attachEvent) {
		element.attachEvent('on' + name, observer);
	}
}

observeElement(window, 'load', function(){
	var elements = document.getElementsByTagName('span');
	for (var i =0; i < elements.length; i++) {
		if (elements[i].className.length > 0 && elements[i].className.indexOf('song-title') > -1)
			elements[i].onmouseover = function() { this.style.textDecoration = 'underline'; };				
			elements[i].onmouseout = function() { this.style.textDecoration = 'none'; };				
	}
});
var search_state = {word:"", active:false};


/*if (window.location.host.indexOf('ringtone') == -1) {
	window.addEvent('domready', setLinksHandler);
}*/

function swapSize(playerSize, autostart) 
{
    window.onunload();
    var size = playerSize.split('x');
    var swf = "player_" + playerSize + ".swf";
    var buttons = "";
    var content = "";

	if(typeof(autostart) == 'undefined'){
		var autostart = 0;
	}
    
    $$('.n-pad .na').setStyles({
        'border-bottom': '1px dashed #1f527b',
        'color': '#1f527b'
    });
    $('size' + playerSize).setStyles({
        'color': '#8FA9BD',
        'border-bottom': '1px dashed #8FA9BD'
    });
    
    $('size').value = playerSize;
    var att = { 
        data:"/swf/" + swf, 
        width: size[0], 
        height: size[1], 
        id: "player_obj", 
        name: "actionext_flash_player",
        allowNetworking: 'all',
        allowFullScreen: 'true'
    };
    var par = { 
        flashvars: "autoplay="+autostart, 
        allowFullScreen: 'true'
    };
    if (Browser.Engine.name != "presto") par["wmode"] = 'transparent';
    swfobject.createSWF(att, par, "player_obj");

  
}

function testSessionCookie () {
  document.cookie ="testSessionCookie=Enabled";
  if (getCookieValue ("testSessionCookie")=="Enabled")
    return true 
  else
    return false;
}

function writeSessionCookie (cookieName, cookieValue) {
  if (testSessionCookie()) {
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + "; path=/";
    return true;
  }
  else return false;
}

