
try {
window.addEvent('domready', function() {

    document.getElements('a[rel=blank]').addEvent('click', function() {
		window.open(this.href,'_blank'); return false;
	});    
	
    document.getElements('area[title=blank]').addEvent('click', function() {
		window.open(this.href,'_blank'); return false;
	});    	

});
}catch(e){}


function Home_OnLoad(){
    currentDiv = 0;
    $$(".fader-feature").each(function(el){
        el.setStyles({
		    display:'none',
		    opacity: 0
	    });
        listDiv.push(el);
    });
    listDiv[0].setStyles({
	    display:'block',
	    opacity: 1
    });
    if(listDiv.length > 1)
    {
        setInterval ( 'SwapImages()', 8500 );
    }
}


function SwapImages() {
    listDiv[currentDiv].fx                  = listDiv[currentDiv].effect('opacity', {duration: 1000}).start(0);       
    listDiv[currentDiv].style.display       = "none";
    
    currentDiv                              = (currentDiv + 1) % listDiv.length;
    
    listDiv[currentDiv].style.display       = "block";       
    listDiv[currentDiv].fx                  = listDiv[currentDiv].effect('opacity', {duration: 1000}).start(1);  
}

function soundSample(cdId, pathType)
{
	//alert("/pages/user/windowsMedia-reskin.asp?filename=" + cdId + "&filepath=" + pathType + "  \n " +  "Media Player" + "  \n " + "location=1,status=1,scrollbars=0,width=330,height=130");
    //window.open ("/pages/user/windowsMedia-reskin.asp?filename=" + cdId + "&filepath=" + pathType, "Media Player","location=1,status=1,scrollbars=0,width=330,height=130");
    window.open ("/pages/user/windowsMedia-reskin.asp?filename=" + cdId + "&filepath=" + pathType, "MediaPlayer","location=1,status=1,scrollbars=0,width=330,height=130");
}


function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);   
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}



function addToCart(cdId, type)
{
    var valCurrent  = GetCookie(type);
    valCurrent      = valCurrent == null ? "" : valCurrent;
    DeleteCookie(type);
    valCurrent      = valCurrent == "" ? cdId : valCurrent.indexOf(cdId) == -1 ? valCurrent + ("," + cdId) : valCurrent;
    SetCookie(type, valCurrent);
    show("cart-ack");
    fade("cart-ack", true);
}

function removeFromCart(cdId, type)
{
    var valCurrent      = GetCookie(type);
    DeleteCookie(type);
    valCurrent          = valCurrent.indexOf(cdId + ",") == 0 ? valCurrent.replace(cdId + ",", "") : valCurrent.indexOf("," + cdId) != -1 ? valCurrent.replace("," + cdId, "") : valCurrent.replace(cdId, "")
    SetCookie(type, valCurrent);
    fade(cdId, false);
    //$(cdId).innerHTML = "";
}





function clearProject() {
  DeleteCookie("CD");
  DeleteCookie("T");
  $$('.cart-item').each(function(el, i){
    fade(el.id, false);
  });
}


function show(objId){
    $(objId).style.visibility   = "visible";      
   
}
function fade(objId, display){  
    $(objId).fx                 = $(objId).effect('opacity', {duration: 1000}).start(0).chain(function(){
        if(display)
        {
            $(objId).style.visibility   = "hidden";  
        }
        else
        {
            $(objId).style.display   = "none";
        }
        $(objId).setOpacity(1);
    });    
   
}


var maxItems = 25;
var expDays = 7;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


