(function() { var UA = navigator.userAgent; isGecko = /gecko/i.test( UA ); isOpera = /opera/i.test( UA ); isMac = /mac_powerpc/i.test( UA ); isIE = /msie/i.test( UA ) && !isGecko && !isOpera && !isMac; isIE5 = isIE && /msie 5\.[^5]/i.test( UA ); isNN4 = document.layers ? true : false; })(); var countryId = 0, categoryId = -1, categoryAllowed = true; function $( id ) { return document.getElementById( id ); } function changeInputType( oldElm, iType, iValue, iClass, blankValue, noFocus ) { if (!oldElm || !oldElm.parentNode || !document.createElement) return; var newElm = document.createElement( "input" ); newElm.type = iType; newElm.className = iClass; if (oldElm.name) newElm.name = oldElm.name; if (oldElm.id) newElm.id = oldElm.id; newElm.onfocus = function() { if (this.hasFocus) return; var newElm = changeInputType( this, "password", iValue, "normal-l", (this.value.toLowerCase() == iValue.toLowerCase()) ? true : false ); if (newElm) newElm.hasFocus=true; } newElm.onblur = function() { if (this.hasFocus) { if (this.value == "") { changeInputType( this, "text", iValue, "login-form", false, true ); } } } newElm.hasFocus = false; oldElm.parentNode.replaceChild( newElm, oldElm ); if (!blankValue) newElm.value = iValue; if (!noFocus || typeof noFocus == "undefined") { window.tempElm = newElm; setTimeout( "tempElm.hasFocus = true; tempElm.focus();", 1 ); } return newElm; } function login() { $( "login" ).submit(); } function search() { $( "searchForm" ).submit(); } function addToFavorites() { var title = "Inner-Live.com"; var url = window.location; if (isGecko) { window.sidebar.addPanel( title, url, "" ); } else if (isIE) { window.external.AddFavorite( url, title ); } else { alert( "Sorry! Your browser doesn't support this function." ); } } window.onload = function() { // if there is the login form only if ($( "login" )) { changeInputType( $( "password" ), "text", "Password", "login-form", false, true ); // text-color effects $( "username" ).onfocus = function() { if (this.value == "Username") { this.value = ""; this.className = "normal-l"; } } $( "username" ).onblur = function() { if (this.value == "") { this.value = "Username"; this.className = "login-form"; } else { this.className = "normal-l"; } } } // text-color effects too $( "search" ).onfocus = function() { if (this.value == "Search" && this.className == "searchfield") { this.value = ""; this.className = "normal-s"; } } $( "search" ).onblur = function() { if (this.value == "") { this.value = "Search"; this.className = "searchfield"; } else { this.className = "normal-s"; } } } // favorites combo function favorites() { countryId = -2; categoryAllowed = true; $( "category" ).className = "category"; // get country categories (ajax) getCategories( true ); $( "country" ).firstChild.innerHTML = "Favorites"; } document.onclick = function( e ) { e = e || window.event; targetElement = e.target || e.srcElement; if (targetElement.nodeType == 3) { targetElement = targetElement.parentNode; } // we need an element with id while (!targetElement.id && targetElement.nodeName != "BODY") { targetElement = targetElement.parentNode; } // country selector $( "box1" ).className = (targetElement.id == "country") ? "visible" : "hide"; // category selector $( "box2" ).className = (targetElement.id == "category" && categoryAllowed) ? "visible" : "hide"; //$( "box3" ).className = (targetElement.id == "tvshow") ? "visible" : "hide"; //$( "box4" ).className = (targetElement.id == "lang") ? "visible" : "hide"; // country selector value if (/^c\d+$/i.test( targetElement.id )) { countryId = targetElement.id.replace( /[^\d]/g, "" ); if (countryId != -1) { categoryAllowed = true; $( "category" ).className = "category"; // get country categories (ajax) getCategories( false ); } else { categoryAllowed = false; $( "category" ).className = "category alpha"; } $( "country" ).firstChild.innerHTML = targetElement.innerHTML; } // category selector value if (/^cc\d+$/i.test( targetElement.id )) { categoryId = targetElement.id.replace( /[^\d]/g, "" ); $( "category" ).firstChild.innerHTML = targetElement.innerHTML; // with IE redirect's bug fix setTimeout( "window.location = '/index.php?task=channels" + (countryId == -2 ? "&action=favorites" : "&country_id=" + countryId) + "&category_id=" + categoryId + "'", 1 ); } } document.onkeyup = function( e ) { e = e || window.event; targetElement = e.target || e.srcElement; if (targetElement.nodeType == 3) { targetElement = targetElement.parentNode; } // login for IE (without sumbit button) if (!e.ctrlKey && ((e.keyCode && e.keyCode == 13) || (e.which && e.which == 13)) && targetElement.parentNode.parentNode.id == "login") { login(); return; } // and search if (!e.ctrlKey && ((e.keyCode && e.keyCode == 13) || (e.which && e.which == 13)) && targetElement.parentNode.id == "searchForm") { search(); return; } } document.onmouseover = function ( e ) { e = e || window.event; targetElement = e.target || e.srcElement; if (targetElement.nodeType == 3) { targetElement = targetElement.parentNode; } } // create category ajax request try { getCategoriesRequest = new XMLHttpRequest(); } catch (trymicrosoft) { try { getCategoriesRequest = new ActiveXObject( "Msxml2.XMLHTTP" ); } catch (othermicrosoft) { try{ getCategoriesRequest = new ActiveXObject( "Microsoft.XMLHTTP" ); } catch (failed) { getCategoriesRequest = false; } } } function getCategories( favorites ) { categoryAllowed = false; getCategoriesRequest.open( "GET", "/index.php?task=category_selector&country_id=" + ((favorites) ? -2 : countryId), true ); getCategoriesRequest.onreadystatechange = showCategories; getCategoriesRequest.send( null ); } function showCategories() { if (getCategoriesRequest.readyState == 4) { if(getCategoriesRequest.status == 200) { // draw category selector $("categorySelector" ).innerHTML = getCategoriesRequest.responseText; categoryAllowed = true; } } }