function check_www()
{
var _location = document.location.href;
if (_location.indexOf('www.ebook30.com') > -1){
document.location = "http://ebook30.com/";
}
}
if (top != self) top.location = self.location;
check_www();
function CollapseAll(maxID)
{
document.getElementById("alls_action").innerHTML = "Expand All";
var id=1;
for (id=1; id <= maxID; id++)
{
HideDetails(id);
}
}
function ExpandAll(maxID)
{
document.getElementById("alls_action").innerHTML = "Collapse All";
var id=1;
for (id=1; id <= maxID; id++)
{
ShowDetails(id);
}
}
function ShowDetails(id)
{
document.getElementById("show_" + id).innerHTML = "Hide program details";
document.getElementById(id).style.display = "block";
}
function HideDetails(id)
{
document.getElementById("show_" + id).innerHTML = "Show program details";
document.getElementById(id).style.display = "none";
}
function printBeforeSave(id)
{
return ' Save';}
function printAfterSave(id)
{
return 'saved to My Ebook | Remove';
}
function printSave(id)
{
document.writeln('');
var saved = get_cookie("sv");
if(saved == null)
saved = '';
if(saved.indexOf(id + ',') == -1)
document.writeln(printBeforeSave(id));
else
document.writeln(printAfterSave(id));
document.writeln('');
}
function printSoftwareBasket()
{
var basket = '
'
document.writeln(basket);
}
function printMoreSoftwareLink()
{
var moreLink = ' ';
//document.writeln(moreLink);
}
function printLoaded()
{
var softwareNo = getNumSavedSoftware();
if(softwareNo > 0)
{
var saved = get_cookie("sv");
var splitSaved = saved.split(',');
var len = splitSaved.length - 1;
if (len == 1)
{
getSavedSoftware(splitSaved[0]);
}
if (len >=2)
{
getSavedSoftware(splitSaved[0]);
getSavedSoftware(splitSaved[1]);
}
//load 2 cai dau tien
} else {
document.writeln("You do not have any ebooks in your basket. Please press Save next to ebook's title to save it into your basket.
");
}
}
function getNumSavedSoftware()
{
var saved = get_cookie("sv");
if(saved == null)
return 0;
var splitSaved = saved.split(',');
return splitSaved.length - 1;
}
function saveSoftware(id) {
//now we have saved software, remove this prompt text
if(document.getElementById("NoSave") != null)
document.getElementById("NoSave").style.display = "none";
var saved = get_cookie("sv");
if(saved == null)
saved = '';
if(saved.indexOf(id + ',') > -1)
{
alert('This software is already in My Ebook');
return;
}
//new cookie
saved += id + ',';
set_cookie("sv",saved,2010,12,31,"/",'ebook30.com');
document.getElementById("ss-" + id).innerHTML = printAfterSave(id);
//display total of saved software in software basket
var numSaved = getNumSavedSoftware();
if(document.getElementById("NumMySoft") != null)
document.getElementById("NumMySoft").innerHTML = numSaved;//extra , at the end
if(document.getElementById("NumMySoft1") != null)
document.getElementById("NumMySoft1").innerHTML = numSaved;//extra , at the end
//if have more than 2 software, then displaying the 'more' link
if(numSaved > 2)
{
if(document.getElementById("SavedSoftwareMore") != null)
document.getElementById("SavedSoftwareMore").style.display = '';
return;
}
getSavedSoftware(id);
}
function getSavedSoftware(id)
{
if(document.getElementById("loading") != null)
document.getElementById("loading").style.display = "";
var xmlHttpReq = false;
// Mozilla/Safari
if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
try
{
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
}
}
xmlHttpReq.open("GET","/LoadSaved.php?ssid=" + id,true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
if(document.getElementById("frametest") != null)
document.getElementById("frametest").innerHTML += xmlHttpReq.responseText;
if(document.getElementById("loading") != null)
document.getElementById("loading").style.display = "none";
}
}
xmlHttpReq.send(null);
}
function removeSoftware(id)
{
var saved = get_cookie("sv");
if(saved == null)
return;
if(saved.indexOf(id + ',') == -1)
return;
saved = saved.replace(id + ',', '');
set_cookie("sv",saved,2010,12,31,"/",'ebook30.com');
if(saved == '' && document.getElementById("NoSave") != null)//displaying the prompt (you have no saved software blah blah)
document.getElementById("NoSave").style.display = "";
var split = saved.split(',');
if(document.getElementById("NumMySoft") != null)
document.getElementById("NumMySoft").innerHTML = split.length - 1;//extra , at the end
if(document.getElementById("NumMySoft1") != null)
document.getElementById("NumMySoft1").innerHTML = split.length - 1;//extra , at the end
if(document.getElementById("ss-" + id) != null)
document.getElementById("ss-" + id).innerHTML = printBeforeSave(id);
if(document.getElementById("rd-" + id) != null)
document.getElementById("rd-" + id).style.display='none';
//link to view more saved software
if(split.length <= 3 && document.getElementById("SavedSoftwareMore") != null)
document.getElementById("SavedSoftwareMore").style.display = 'none';
//making this software display to be invisible and display the next one in the que
//if it is listed
if(document.getElementById(id) != null)
{
document.getElementById(id).style.display = 'none';
document.getElementById(id).id = '-' + id;
if(split.length >= 3)
getSavedSoftware(split[1]);//displaying the next one in the queue
}
}
function set_cookie ( name, value, exp_y, exp_m, exp_d,path,domain,secure)
{
var cookie_string = name + "=" + escape ( value );
if ( exp_y )
{
var expires = new Date ( exp_y, exp_m, exp_d );
cookie_string += "; expires=" + expires.toGMTString();
}
if ( path ) cookie_string += "; path=" + escape ( path );
if ( domain ) cookie_string += "; domain=" + escape ( domain );
if ( secure ) cookie_string += "; secure";
document.cookie = cookie_string;
}
function get_cookie ( cookie_name )
{
var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
if ( results )
return ( unescape ( results[1] ) );
else
return null;
}
function printText(text)
{
document.writeln(text);
}
function printRemoveAll()
{
var text = '';
text += '';
printText(text);
}
function RemoveAllEbooks()
{
var saved = get_cookie("sv");
if(saved == null)
return;
// saved_ = saved.replace(id + ',', '');
set_cookie("sv",'',2010,12,31,"/",'ebook30.com');
if(saved == '' && document.getElementById("NoSave") != null)//displaying the prompt (you have no saved software blah blah)
document.getElementById("NoSave").style.display = "";
var split = saved.split(',');
if(document.getElementById("NumMySoft") != null)
document.getElementById("NumMySoft").innerHTML = 0;//extra , at the end
if(document.getElementById("NumMySoft1") != null)
document.getElementById("NumMySoft1").innerHTML = 0;//extra , at the end
document.getElementById("frametest").innerHTML = '';
document.location = document.location;
// end of function
}