

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var hasDom=true;
var hasAll=document.all;
var hasNSDom=document.layers;

function disguise() {
    var ary=disguise.arguments;
    for(a=0;a<ary.length;a++) {
        var name=ary[a];
        if (hasDom) {
            var lyrStyle=document.getElementById("lyr_"+name).style;
            lyrStyle.display="none";
        }
    }
}

function reveal() {
	var ary=reveal.arguments;
    for(a=0;a<ary.length;a++) {
		var name=ary[a];
        if (hasDom) {
					var lyrStyle=document.getElementById("lyr_"+name).style;
					lyrStyle.display="block";
        }

    }
}

function changestyle(objRow,color) {
  document.getElementById(objRow).className=color;
}

// Pass a 3rd variable across to check for terms agreement
function submitShop(key, name) {
	document.getElementById(key).value=name
	if ( submitShop.arguments.length==3 ) {
		if ( !checkAgree() ){}
		else document.forms['go_shopping'].submit()
	} else document.forms['go_shopping'].submit()
	
}

var curNum = 1;	
function nextResult	( num ) {
	disguise('result_'+curNum)
	reveal('result_'+num)
	curNum=num
}

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

function InsertFlash(name, width, height)
{
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="rotateimages" align="middle" sWmode="opaque">');
  document.write('<param name="allowScriptAccess" value="sameDomain" />');
  document.write('<param name="movie" value="'+name+'" /><param name="quality" value="high" />');
  document.write('<param name="wmode" value="opaque"><param name="bgcolor" value="#ffffff" />');
  document.write('<embed src="'+name+'" quality="high" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="rotateimages" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"  wmode="opaque"/>');
  document.write('</object>\n');
}

function updateBasket(name, id){
	
	if ( window.confirm("Do you want to add this item to your shopping basket?") ) {
		//var searchstring=document.getElementById('search').value;
		var xmlhttp=false; //Clear our fetching variable
	        try {
	                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
	        } catch (e) {
	                try {
	                        xmlhttp = new
	                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
	            } catch (E) {
	                xmlhttp = false;
	                        }
	        }
	        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
	        }
	        var file = '/shopping_basket_contents.php?name='+name+'&id='+id; //This is the path to the file we just finished making *
		    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
		    xmlhttp.onreadystatechange=function() {
		        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
		                var content = xmlhttp.responseText; //The content data which has been retrieved ***
		                if( content ){ //Make sure there is something in the content variable
		                      document.getElementById('shopping_basket_contents').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
		                }
		        }
	        }
	        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
	}
}

function gotoPage(page_number, pg_id, display_book_type){
	
		//var searchstring=document.getElementById('search').value;
		var xmlhttp=false; //Clear our fetching variable
	        try {
	                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
	        } catch (e) {
	                try {
	                        xmlhttp = new
	                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
	            } catch (E) {
	                xmlhttp = false;
	                        }
	        }
	        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
	        }
	        var file = '/generalbook_page.php?pagination='+page_number+'&pg='+pg_id+'&display_book_type='+display_book_type; //This is the path to the file we just finished making *
		    xmlhttp.open('GET', file, true); //Open the file through GET, and add the page we want to retrieve as a GET variable **
		    xmlhttp.onreadystatechange=function() {
		        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
		                var content = xmlhttp.responseText; //The content data which has been retrieved ***
		                if( content ){ //Make sure there is something in the content variable
		                      document.getElementById('shop_display_container').innerHTML = content; //Change the inner content of your div to the newly retrieved content ****
		                }
		        }
	        }
	        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
}