activeitem = 1;
rotactive = 1;
totalitems = 4;

function featRot() {
	if(rotactive == 1) {
		if((activeitem + 1) <= totalitems) {
			setTimeout("transition('" + activeitem + "', '" + (activeitem+1) + "' , 100);", 5000);
			activeitem++;
		} else {
			setTimeout("transition('" + activeitem + "', '1', 100);", 5000);
			activeitem = 1;			
		}
	}
}

function transition(from, to, alpha) {
	if(alpha == 100) {
		document.getElementById("whiletheylast" + to).style.display = "block";
		document.getElementById("whiletheylast" + to).style.opacity = 0;	
		document.getElementById("whiletheylast" + to).style.filter = "alpha(opacity=0);";		
	}
	if(alpha >= 0) {
		alpha = alpha - 4;
		if(!document.all) {
			document.getElementById("whiletheylast" + to).style.opacity = ((alpha * -1) + 100)/100;
			document.getElementById("whiletheylast" + from).style.opacity = alpha/100;
		} else {
			document.getElementById("whiletheylast" + to).style.filter = "alpha(opacity=" + ((alpha * -1) + 100) + ");";
			document.getElementById("whiletheylast" + from).style.filter = "alpha(opacity=" + alpha + ");";
		}

		setTimeout("transition('" + from + "', '" + to + "' , '" + alpha + "');", 25);
	} else {
		document.getElementById("whiletheylast" + from).style.display = "none";
		featRot();
	}
}

rotate = 0;

function Rot(id) {
	if(id == 0)
		rotate = 1;
	if(id == 1)
		rotate = 0;
}

function rotateStores(total) {
	totalstores = total;
	startRotation();	
}

function startRotation() {
	if(rotate != 1) {
		for(id=1;id<totalstores;id++){
			
			sf = document.getElementById("store_" + id);
			
			if(sf.offsetTop < (39 * -1))  {
				sf.style.top = (39 * (totalstores - (id + 1))) + "px";
			} else {
				sf.style.top = (parseInt(sf.style.top) - 1) + "px";
			}
		}
	}
	setTimeout("startRotation();", 25);	
}

function changeCell(el, opt) { 
	el.style.background = '#FEF2D6'; 
	el.style.border = '1px solid #CCCCCC';
	el.onmouseout=function() { 
		el.style.background = '#FFFFFF';
		el.style.border = '1px solid #FFFFFF';
	} 
}

function getURL(site) {
	window.open(site, null);
}

function blockError(){return true;}
window.onerror = blockError;

function checkEnter(e){ //e is event object passed from function invocation
	
	var characterCode;
	
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		ajax_search_class();
		return false;
	} else {
		return true;
	}

}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function ajax_search_class() {
	searchterm = document.getElementById("srchbox").value;
	var adid = document.getElementById("adid").value;
	if(searchterm == "" && adid == "") { // Don't allow blank searches
		document.getElementById("ajax_result_set").style.display = "none";
		document.getElementById("ajax_result_set").innerHTML = "<div align='center'><br><img src='images/warn.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Please Enter a Search Term.</span><br><br></div>";
		document.getElementById("ajax_result_set").style.display = "block";
	} else {
		document.getElementById("ajax_result_set").style.display = "none";
		document.getElementById("ajax_result_set").innerHTML = "<div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Performing Search, Please Wait.</span><br><br></div>";
		document.getElementById("ajax_result_set").style.display = "block";

		// check for advanced settings
		if(searchOpen == 1) {
			// do advanced ajax search		
			advsrchclass = document.getElementById("adv_class").value;
			advenddate = document.getElementById("adv_enddate").value;
			advvideo= document.getElementById("adv_video").checked;
			advphoto = document.getElementById("adv_photo").checked;

			http.open('get', 'includes/ajax.php?action=cs&adv=1&class=' + advsrchclass + '&enddate=' + advenddate + '&video=' + advvideo + '&photo=' + advphoto + '&adid=' + adid + '&random=' + Math.round(Math.random()*9999) + '&query=' + searchterm);
			http.onreadystatechange = csearchpback;
			http.send(null);
		} else {
			// do ajax search		
			http.open('get', 'includes/ajax.php?action=cs&random=' + Math.round(Math.random()*9999) + '&query=' + searchterm);
			http.onreadystatechange = csearchpback;
			http.send(null);
		}
	}
} 

function csearchpback() {
	 if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
			document.getElementById("ajax_result_set").innerHTML = "";
			
			var divtext;
			var results;
			
			results = "";
			divtext = "";
			

			
			totalsrch = update[update.length - 1];
			query = update[update.length - 2];
			
			for(i=0;i<update.length-2;i++) {
	            results += update[i];
			}
			
			if(totalsrch < 10) {
				total = totalsrch;
			} else {
				total = 10;				
			}
			if(totalsrch != 0) {
				divtext = "<div class=\"ajax_result\" align=\"left\"><div align='center' class='srchlink'>Displaying (1 - " + total + ") of " + totalsrch + " Results<br><a href=\"javascript:pullResults('" + query + "');\">View All Results</a>&nbsp;&nbsp;<a href='javascript:clearSrch();'>Clear Search</a></div></div>";
				document.getElementById("ajax_result_set").innerHTML = divtext;
				document.getElementById("ajax_result_set").innerHTML += results;
			} else {
				document.getElementById("ajax_result_set").innerHTML = "<div align='center'><br><img src='images/warn.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>No Results Returned.</span><br><br></div>";
			}
						
        }
    }
}

function clearSrch() {
	document.getElementById("ajax_result_set").style.display = "none";
	document.getElementById("ajax_result_set").innerHTML = "";
	document.getElementById("srchbox").value = "";
}

function pullAd(id) {
	document.location = '#top';
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Ad..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=view&random=' + Math.round(Math.random()*9999) + '&id=' + id);
	http.onreadystatechange = cpullad;
	http.send(null);
} 

function cpullad() {
	 if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');

			for(i=0;i<update.length;i++) {
	            document.getElementById("result_set").innerHTML = update[i];
			}							
        }
    }
}

function pullClass(id) {
	document.location = '#top';
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Classification..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=class&random=' + Math.round(Math.random()*9999) + '&class=' + id);
	http.onreadystatechange = cpullclass;
	http.send(null);
} 

function cpullclass() {
	 if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
			update = response.split('|');
			
			document.getElementById("result_set").innerHTML = "";
			
			if(response == "none") {
				document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/warn.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>There are no active ads in that classification.</span><br><br></div></div>";							
			} else {
				for(i=0;i<update.length;i++) {
					document.getElementById("result_set").innerHTML += update[i];
				}	
			}
        }
    }
}

function pullResults(query) {
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Search Results..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=srch&random=' + Math.round(Math.random()*9999) + '&query=' + query);
	http.onreadystatechange = cpullsrch;
	http.send(null);
} 

function cpullsrch() {
	 if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
			update = response.split('|');
			document.getElementById("result_set").innerHTML = "";

			for(i=0;i<update.length;i++) {
				document.getElementById("result_set").innerHTML += update[i];
			}	
        }
    }
}

function showVideo(id, src) {
	document.location = '#top';
	document.getElementById("video_player").style.display = "block";
	pullVidContent(id);
	var mymovie=window.document.ajaxplayer;

	mymovie.LoadMovie(0, "flash/player.swf?moviepath=BatchEncodedVideos/" + src);
}

function closeVideo(alpha) {
		
	if(!alpha) {
		alpha = document.getElementById("video_player").offsetHeight;
		flashmovie=window.document.ajaxplayer;
	}
	
	document.getElementById("video_player").style.height = alpha + "px";
	var movement;
	movement = (alpha / 4);
	alpha = alpha - movement;
	if(alpha > 1) {
		setTimeout("closeVideo(" + alpha + ")", 25);
	} else {
		flashmovie.LoadMovie(0, "/");
		document.getElementById("video_player").style.display = "none";		
		document.getElementById("video_player").style.height = "";			
		 // use as reference point
	}

}

function pullVidContent(id) {
	document.getElementById("vid_ad_content").innerHTML = "<div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px; cursor:default;'>Loading Ad..</span><br><br></div>";
	http.open('get', 'includes/ajax.php?action=vid&random=' + Math.round(Math.random()*9999) + '&id=' + id);
	http.onreadystatechange = placeVidContent;
	http.send(null);
	
}

function placeVidContent() {
	 if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');

			for(i=0;i<update.length;i++) {
	            document.getElementById("vid_ad_content").innerHTML = update[i];
			}							
        }
    }
}

function parseVid(filename) {
	vidfilename = filename;
	http.open('get', 'parsevid.php?random=' + Math.round(Math.random()*9999));
	http.onreadystatechange = parseResponse;
	http.send(null);
}	

function parseResponse() {
	if(http.readyState == 4) {
		document.getElementById("ParseDetails").innerHTML = '<div align="center" class="classItem" id="ParseDetails"><br /><br />Video Compression Completed.<br /><br />Your video has been submitted into the approval queue. It will be reviewed and if it <br>meets our standards, posted within 24 hours.<br><br>[ <a href="ad.php">Return to Ad Management</a> ]<br><br><br></div>';
    }	
}

function writeVideo(file) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="240" height="210" id="ajaxplayer">');
	document.write('<param name="movie" value="flash/player.swf?moviepath=BatchEncodedVideos/' + file + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<embed src="flash/player.swf?moviepath=BatchEncodedVideos/' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="240" height="210" name="ajaxplayer" swLiveConnect="true" wmode="opaque"></embed>');
	document.write('</object>');
}

function reviewVideo(videoname, id) {
	document.location = '#top';
	flashmovie=window.document.ajaxplayer;
	flashmovie.LoadMovie(0, "flash/player.swf?moviepath=BatchEncodedVideos/" + videoname);
	document.getElementById("video_options").innerHTML = "<a href=\"javascript:approveVideo('" + id + "', 100);\">Approve Video</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"javascript:declineVideo('" + id + "', 100);\">Decline Video</a>";
}

function reviewPhoto(videoname, id) {
	window.open("classphotos/" + videoname, "_a" + id);
}

function declineVideo(id, alpha) {
	document.getElementById("view_ad_" + id).style.opacity = alpha/100;
	document.getElementById("view_ad_" + id).style.filter = "alpha(opacity=" + alpha + ");";
	alpha = alpha - 5;
	if(alpha > 0) {
		setTimeout("declineVideo('" + id + "', " + alpha + ")", 25);
	} else {
		document.getElementById("view_ad_" + id).style.display = "none";	
		document.getElementById("sep_" + id).style.display = "none";	
		
		http.open('get', 'includes/ajax.php?action=delvideo&random=' + Math.round(Math.random()*9999) + '&id=' + id);
		http.send(null);		
	}
}

function approveVideo(id, alpha) {
	document.getElementById("view_ad_" + id).style.opacity = alpha/100;
	document.getElementById("view_ad_" + id).style.filter = "alpha(opacity=" + alpha + ");";
	alpha = alpha - 5;
	if(alpha > 0) {
		setTimeout("approveVideo('" + id + "', " + alpha + ")", 25);
	} else {
		document.getElementById("view_ad_" + id).style.display = "none";	
		document.getElementById("sep_" + id).style.display = "none";	
		
		http.open('get', 'includes/ajax.php?action=appvideo&random=' + Math.round(Math.random()*9999) + '&id=' + id);
		http.send(null);		
	}
}

function declinePhoto(id, alpha) {
	document.getElementById("view_ph_" + id).style.opacity = alpha/100;
	document.getElementById("view_ph_" + id).style.filter = "alpha(opacity=" + alpha + ");";
	alpha = alpha - 5;
	if(alpha > 0) {
		setTimeout("declinePhoto('" + id + "', " + alpha + ")", 25);
	} else {
		document.getElementById("view_ph_" + id).style.display = "none";	
		document.getElementById("sepph_" + id).style.display = "none";	
		
		http.open('get', 'includes/ajax.php?action=delph&random=' + Math.round(Math.random()*9999) + '&id=' + id);
		http.send(null);		
	}
}

function approvePhoto(id, alpha) {
	document.getElementById("view_ph_" + id).style.opacity = alpha/100;
	document.getElementById("view_ph_" + id).style.filter = "alpha(opacity=" + alpha + ");";
	alpha = alpha - 5;
	if(alpha > 0) {
		setTimeout("approvePhoto('" + id + "', " + alpha + ")", 25);
	} else {
		document.getElementById("view_ph_" + id).style.display = "none";	
		document.getElementById("sepph_" + id).style.display = "none";	
		
		http.open('get', 'includes/ajax.php?action=appph&random=' + Math.round(Math.random()*9999) + '&id=' + id);
		http.send(null);		
	}
}

function saveAd(id) {
	document.getElementById("save_box").style.display = "block";
	if(document.getElementById("save_box_content").style.display == "none") {
		document.getElementById("save_box_content").style.display = "block";	
		document.getElementById("save_box_content").style.height = "";	
		document.getElementById("save_box_content").setAttribute("opened", "1");
		document.getElementById("save_box_content").setAttribute("title", "");		
	}
	
	closeprnt = 1;
	
	http.open('get', 'includes/ajax.php?action=savead&random=' + Math.round(Math.random()*9999) + '&id=' + id);
	http.onreadystatechange = saveSuccess;
	http.send(null);
}

function saveSuccess() {
	// postback here	
	if(http.readyState == 4) {
		var response = http.responseText;
		var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
			if(update[0] != "duplicate") {
		        document.getElementById("save_box_content").innerHTML += update[0];	
				addBasket(update[1], 0);
			} else {
				// Duplicate Record	
			}
        }
	}
}

function addBasket(id, alpha) {
	document.getElementById("print_" + id).style.display = "block";	
	if(!document.all) {
		document.getElementById("print_" + id).style.opacity = alpha/100;
	} else {
		document.getElementById("print_" + id).style.filter = "alpha(opacity=" + alpha + ");";
	}
	alpha = alpha + 5;
	if(alpha <= 100) {
		setTimeout("addBasket('" + id + "', " + alpha + ")", 25);
	} else {
		// faded in		
		totalprintbasket++;
		if(totalprintbasket == 1) {
			document.getElementById("print_basket_status").innerHTML = "Your print basket has <b>" + totalprintbasket + "</b> item ( <a href='javascript:openBasket();'>open basket</a> )";
		} else {
			document.getElementById("print_basket_status").innerHTML = "Your print basket has <b>" + totalprintbasket + "</b> items ( <a href='javascript:openBasket();'>open basket</a> )";
		}
		if(closeprnt == 1) {
			closeprnt = 0;
			setTimeout("hidePrnt()", 150);
		}
	}
}

function delAd(id) {
	http.open('get', 'includes/ajax.php?action=delad&random=' + Math.round(Math.random()*9999) + '&id=' + id);
	http.onreadystatechange = delSuccess;
	http.send(null);
}

function delSuccess() {
	// postback here	
	if(http.readyState == 4) {
		var response = http.responseText;
		var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');		
			remBasket(update[0], 100);
		}
	}
}

function remBasket(id, alpha) {
	
	document.getElementById("print_" + id).style.opacity = alpha/100;
	document.getElementById("print_" + id).style.filter = "alpha(opacity=" + alpha + ");";
	alpha = alpha - 5;
	if(alpha > 0) {
		setTimeout("remBasket('" + id + "', " + alpha + ")", 25);
	} else {
		totalprintbasket--;
		document.getElementById("print_" + id).style.display = "none";
		document.getElementById("print_" + id).innerHTML = "";
		
		document.getElementById("print_" + id).setAttribute("id", "dead_1223");
		
		if(totalprintbasket < 1) {
			document.getElementById("save_box").style.display = "none";
			document.getElementById("save_box_content").innerHTML = "";
		}
		if(totalprintbasket == 1) {
			document.getElementById("print_basket_status").innerHTML = "Your print basket has <b>" + totalprintbasket + "</b> item ( <a href='javascript:openBasket();'>open basket</a> )";
		} else if(totalprintbasket > 1) {
			document.getElementById("print_basket_status").innerHTML = "Your print basket has <b>" + totalprintbasket + "</b> items ( <a href='javascript:openBasket();'>open basket</a> )";
		} else {
			document.getElementById("print_basket_status").innerHTML = "Your print basket is currently empty";	
		}
	}
}

// Advanced Search Box

searchOpen = 0;
inAction = 0;

function showAdvanced(alpha) {
	if(searchOpen == 0) {
		document.getElementById("advanced_search").style.display = "block";
		document.getElementById("advanced_search").style.height = alpha + "px";
		var movement;
		movement = ((109 - alpha) / 4);
		alpha = alpha + movement;
		if(alpha > 108) {
			alpha = 109;	
		}
		if(alpha < 109) {
			inAction = 1;
			setTimeout("showAdvanced(" + alpha + ")", 25);
		} else {
			// Advanced Box Loaded
			inAction = 0;
			searchOpen = 1;
		}		
	} else if(searchOpen == 1) {
		if(alpha == 0) {
			alpha = 109;	
		}
		document.getElementById("advanced_search").style.height = alpha + "px";
		var movement;
		movement = (alpha / 4);
		alpha = alpha - movement;
		if(alpha > 1) {
			inAction = 1;
			setTimeout("showAdvanced(" + alpha + ")", 25);
		} else {
			inAction = 0;
			// Advanced Box Loaded
			document.getElementById("advanced_search").style.display = "none";
			searchOpen = 0;		
		}		
	}
}

function sendAd(id, alpha) { // FIXED: Opening multiple times
	
	if(document.getElementById("send2friend_" + id).getAttribute("title") != "1") {
		
		if(!alpha)
			alpha = 0;
			
		document.getElementById("send2friend_" + id).style.display = "block";
		document.getElementById("send2friend_" + id).style.height = alpha + "px";
		var movement;
		movement = ((27 - alpha) / 4);
		alpha = alpha + movement;
		if(alpha < 26) {
			setTimeout("sendAd('" + id + "', " + alpha + ")", 25);
		} else {	
			document.getElementById("send2friend_" + id).style.height = "27px";	
			document.getElementById("send2friend_" + id).setAttribute("title", "1"); // use as reference point
		}
		
	} else {
		
		if(!alpha)
			alpha = 27;
			
		document.getElementById("send2friend_" + id).style.height = alpha + "px";
		var movement;
		movement = (alpha / 4);
		alpha = alpha - movement;
		if(alpha > 1) {
			setTimeout("sendAd('" + id + "', " + alpha + ")", 25);
		} else {	
			document.getElementById("send2friend_" + id).style.height = "0px";	
			document.getElementById("send2friend_" + id).style.display = "none";	
			document.getElementById("send2friend_" + id).setAttribute("title", "0"); // use as reference point
		}
		
	}
}

function closeSend(id, alpha, inital) { // FIXED: Inconsistant results when closing sent alert
	
	if(inital == 1) {
		document.getElementById("send2friend_" + id).innerHTML = "Classified Ad Sent.";
		setTimeout("closeSend('" + id + "', 26)", 500);
	} else {
		if(!alpha)
			alpha = 27;
			
		document.getElementById("send2friend_" + id).style.height = alpha + "px";
		var movement;
		movement = (alpha / 4);
		alpha = alpha - movement;
		
		if(alpha > 2) {
			setTimeout("closeSend('" + id + "', " + alpha + ")", 25);
		} else {	
			document.getElementById("send2friend_" + id).style.height = "0px";	
			document.getElementById("send2friend_" + id).style.display = "none";				
			document.getElementById("send2friend_" + id).setAttribute("title", "0"); // use as reference point
		}
	}
}

function s2f(id) {
	var emailaddy = document.getElementById("s2f_" + id).value;
	http.open("get", "includes/ajax.php?action=s2f&random=" + Math.round(Math.random()*9999) + "&id=" + id + "&email=" + emailaddy);
	http.onreadystatechange = sentfriend;
	http.send(null);
}

function sentfriend() { // FIXME: need to write the code again
	if(http.readyState == 4) {
		var response = http.responseText;
		var nupdate = new Array();

        if(response.indexOf('|' != -1)) {
            nupdate = response.split('|');		
			closeSend(nupdate[0], 27, 1);
		}
	}
}

function writeTrinav() {
	  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="404" height="32">');
	  document.write('<param name="movie" value="flash/tri_nav.swf" />');
	  document.write('<param name="quality" value="high" />');
	  document.write('<param name="wmode" value="transparent" />');
	  document.write('<embed src="flash/tri_nav.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="404" height="32" wmode="transparent"></embed>');
	  document.write('</object>');
}

function openBasket() {
	window.open("pbasket.php", "_pb", "width=800,top=20");	
}

function hidePrnt(alpha) { // shrink the print basket
	
	if(document.getElementById("save_box_content").title == "") {
		document.getElementById("save_box_content").setAttribute("title", document.getElementById("save_box_content").offsetHeight);
	}

	if(document.getElementById("save_box_content").getAttribute("opened") == "1") {
		
		if(!alpha) {
			alpha = document.getElementById("save_box_content").offsetHeight;
		}
		
		document.getElementById("save_box_content").style.height = alpha + "px";
		var movement;
		movement = (alpha / 4);
		alpha = alpha - movement;
		if(alpha > 1) {
			setTimeout("hidePrnt(" + alpha + ")", 25);
		} else {	
			document.getElementById("save_box_content").style.height = "0px";
			document.getElementById("save_box_content").style.display = "none";
			document.getElementById("save_box_content").setAttribute("opened", "0");
			document.getElementById("hideprnt").innerHTML = '<a href="javascript:hidePrnt();">[ + ]</a>';
			 // use as reference point
		}
		
	} else {
		if(!alpha)
			alpha = 0;
		
		var bigsize = document.getElementById("save_box_content").title;
		document.getElementById("save_box_content").style.display = "block";
		
		document.getElementById("save_box_content").style.height = alpha + "px";
		var movement;
		movement = ((bigsize - alpha) / 4);
		alpha = alpha + movement;
		if(alpha < (bigsize - 1)) {
			setTimeout("hidePrnt(" + alpha + ")", 25);
		} else {
			document.getElementById("save_box_content").style.height = "";
			document.getElementById("save_box_content").setAttribute("opened", "1");
			document.getElementById("save_box_content").setAttribute("title", "");
			document.getElementById("hideprnt").innerHTML = '<a href="javascript:hidePrnt();">[ - ]</a>';
		}		
	}
}

function browseNext(id, page) {
	document.location = '#top';
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Next Page..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=class&random=' + Math.round(Math.random()*9999) + '&class=' + id + '&page=' + page);
	http.onreadystatechange = cpullclass;
	http.send(null);
}

function browsePrevious(id, page) {
	document.location = '#top';
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Previous..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=class&random=' + Math.round(Math.random()*9999) + '&class=' + id + '&page=' + page);
	http.onreadystatechange = cpullclass;
	http.send(null);
}

function browseSNext(query, page) {
	document.location = '#top';
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Next Page..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=srch&random=' + Math.round(Math.random()*9999) + '&query=' + query + '&page=' + page);
	http.onreadystatechange = cpullsrch;
	http.send(null);
}

function browseSPrevious(query, page) {
	document.location = '#top';
	document.getElementById("result_set").innerHTML = "<div class='classItem' align='center'><div align='center'><br><img src='images/indicator.gif'>&nbsp;&nbsp;<span style='vertical-align:4px;'>Loading Previous..</span><br><br></div></div>";
	http.open('get', 'includes/ajax.php?action=srch&random=' + Math.round(Math.random()*9999) + '&query=' + query + '&page=' + page);
	http.onreadystatechange = cpullsrch;
	http.send(null);
}
