function setActiveStyleSheet(title) {
  
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}
  
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 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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  checkiconstyle(title);
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  checkiconstyle(title);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);



/*script site check property */
 
		$(function() {
            $(".main .jCarouselLite").jCarouselLite({
                btnNext: ".main .next",
                btnPrev: ".main .prev",
                speed: 500,
                easing: "easeinout"
            });

            $(".lavaLampWithImage, .lavaLampNoImage, .lavaLampBottomStyle").lavaLamp({
                fx: "backout",
                speed: 700,
                click: function() {return true;}
            });
            
        });

        $(window).load(function() {
//            $(".entryMetadata").slideDown(800);    
        });

var ver =navigator.appName ;

var barbfixID=1;	
function showhidebarb(){
	if(barbfixID==1){	
	
	if (ver == 'Microsoft Internet Explorer'){document.getElementById('marbarid').style.display="none";}
	document.getElementById('cntbarb').style.paddingTop="0";
	document.getElementById('closebar').style.backgroundPosition="-38px -88px";
	barbfixID=0;
	setCookie('ejjbed',barbfixID,365);
	}
	else{
	
	

	barbfixID=1;
	setCookie('ejjbed',barbfixID,365);
	}
}




function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function checkCookiebar()
{
ejjbed=getCookie('ejjbed');
if (ejjbed==1){barbfixID=0;showhidebarb();}
if (ejjbed==0){barbfixID=1;showhidebarb();}
else {setCookie('ejjbed','1',365);}

}



function checkiconstyle(synsite){

idicstyle=new Array("black","red","yellow","blue","gray");
idvalicstyle=new Array("-47px","-64px","-81px","-99px","-117px");
 for(i=0;i<idicstyle.length;i++) {
	idiconst="ic"+idicstyle[i]; 
    if(synsite==idicstyle[i]){valposiocnst="-16px "+idvalicstyle[i]; document.getElementById(idiconst).style.backgroundPosition=valposiocnst;}
    else{valposiocnst="0 "+idvalicstyle[i];document.getElementById(idiconst).style.backgroundPosition=valposiocnst;}
 }	
}




function changebgover(objrow){objrow.style.backgroundColor='#f5f3e6';}
function changebgout(objrow){objrow.style.backgroundColor='';}


function setHomeEjjbed()
  {
    if (document.all){
     document.body.style.behavior='url(#default#homepage)';
     document.body.setHomePage('http://www.ejjbed.com');

    }
    else if (window.sidebar)
     {
      if(window.netscape)
      {
       try
       {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       }
      catch(e)
      {
      alert("this action was aviod by your browser");
	  }
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage','www.ejjbed.com');
}
}


function changebrdnover(objrow){objrow.style.borderRightColor='#b7982d';}
function changebrdnout(objrow){objrow.style.borderRightColor='#d4b650';}

function mainnews(bxi){
	switch (bxi){
	case 1: 
		$("#mainnews"+bxi).fadeIn("0");
		$("#mainnews2").fadeOut("0");	
		$("#mainnews3").fadeOut("0");
		$("#mainnews4").fadeOut("0");
		$("#mainnews5").fadeOut("0");
		break;
	case 2: 
		$("#mainnews"+bxi).fadeIn("0");
		$("#mainnews1").fadeOut("0");	
		$("#mainnews3").fadeOut("0");
		$("#mainnews4").fadeOut("0");
		$("#mainnews5").fadeOut("0");
		break;
	case 3: 
		$("#mainnews"+bxi).fadeIn("0");
		$("#mainnews1").fadeOut("0");	
		$("#mainnews2").fadeOut("0");
		$("#mainnews4").fadeOut("0");
		$("#mainnews5").fadeOut("0");
		break;
	case 4: 
		$("#mainnews"+bxi).fadeIn("0");
		$("#mainnews1").fadeOut("0");	
		$("#mainnews2").fadeOut("0");
		$("#mainnews3").fadeOut("0");
		$("#mainnews5").fadeOut("0");
		break;
	case 5: 
		$("#mainnews"+bxi).fadeIn("0");
		$("#mainnews1").fadeOut("0");	
		$("#mainnews2").fadeOut("0");
		$("#mainnews3").fadeOut("0");
		$("#mainnews4").fadeOut("0");
		break;
	}
}
var lblliston=1;
function showhidelists(lstnum){
	switch (lstnum){
	case 1: 
		$("#listnews"+lstnum).fadeIn("0");
		$("#listnews2").fadeOut("0");
		document.getElementById("lbllist"+lstnum).style.opacity=1;
		document.getElementById("lbllist"+lstnum).style.filter ="alpha(opacity=100)";
		
		document.getElementById("lbllist2").style.opacity=0.3;
		document.getElementById("lbllist2").style.filter ="alpha(opacity=30)";

		
		break;
	case 2: 
		$("#listnews"+lstnum).fadeIn("0");
		$("#listnews1").fadeOut("0");
		document.getElementById("lbllist"+lstnum).style.opacity=1;
		document.getElementById("lbllist"+lstnum).style.filter ="alpha(opacity=100)";
		
		document.getElementById("lbllist1").style.opacity=0.3;
		document.getElementById("lbllist1").style.filter ="alpha(opacity=30)";
		break;
	}
	
	lblliston=lstnum;
	
}


function overhoverlists(lstnum2){
	
	if(lblliston!=lstnum2){
		document.getElementById("lbllist"+lstnum2).style.opacity=0.6;
		document.getElementById("lbllist"+lstnum2).style.filter ="alpha(opacity=60)";
	}	
}


function outhoverlists(lstnum2){
	
	if(lblliston!=lstnum2){
		document.getElementById("lbllist"+lstnum2).style.opacity=0.3;
		document.getElementById("lbllist"+lstnum2).style.filter ="alpha(opacity=30)";
	}	
}

$(document).ready(function() {
  var options = {
    newsList: "#news",
    startDelay: 5,
    placeHolder1: "_"
  }
  $().newsTicker(options);
});
