JS_BASE = "http://www.sellstudentstuff.com/"
JS_BASE_SECURE = "https://www.sellstudentstuff.com/"
JS_UMBRELLA_BASE = "http://www.sellstudentstuff.com/"
JS_UMBRELLA_BASE_SECURE = "https://www.sellstudentstuff.com/"

// Simple Set Clipboard System
// Author: Joseph Huckaby

var ZeroClipboard = {
	
	version: "1.0.7",
	clients: {}, // registered upload clients on page, indexed by id
	moviePath: 'ZeroClipboard.swf', // URL to movie
	nextId: 1, // ID of next movie
	
	$: function(thingy) {
		// simple DOM lookup utility function
		if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
		if (!thingy.addClass) {
			// extend element with a few useful methods
			thingy.hide = function() { this.style.display = 'none'; };
			thingy.show = function() { this.style.display = ''; };
			thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
			thingy.removeClass = function(name) {
				var classes = this.className.split(/\s+/);
				var idx = -1;
				for (var k = 0; k < classes.length; k++) {
					if (classes[k] == name) { idx = k; k = classes.length; }
				}
				if (idx > -1) {
					classes.splice( idx, 1 );
					this.className = classes.join(' ');
				}
				return this;
			};
			thingy.hasClass = function(name) {
				return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
			};
		}
		return thingy;
	},
	
	setMoviePath: function(path) {
		// set path to ZeroClipboard.swf
		this.moviePath = path;
	},
	
	dispatch: function(id, eventName, args) {
		// receive event from flash movie, send to client		
		var client = this.clients[id];
		if (client) {
			client.receiveEvent(eventName, args);
		}
	},
	
	register: function(id, client) {
		// register new client to receive events
		this.clients[id] = client;
	},
	
	getDOMObjectPosition: function(obj, stopObj) {
		// get absolute coordinates for dom element
		var info = {
			left: 0, 
			top: 0, 
			width: obj.width ? obj.width : obj.offsetWidth, 
			height: obj.height ? obj.height : obj.offsetHeight
		};

		while (obj && (obj != stopObj)) {
			info.left += obj.offsetLeft;
			info.top += obj.offsetTop;
			obj = obj.offsetParent;
		}

		return info;
	},
	
	Client: function(elem) {
		// constructor for new simple upload client
		this.handlers = {};
		
		// unique ID
		this.id = ZeroClipboard.nextId++;
		this.movieId = 'ZeroClipboardMovie_' + this.id;
		
		// register client with singleton to receive flash events
		ZeroClipboard.register(this.id, this);
		
		// create movie
		if (elem) this.glue(elem);
	}
};

ZeroClipboard.Client.prototype = {
	
	id: 0, // unique ID for us
	ready: false, // whether movie is ready to receive events or not
	movie: null, // reference to movie object
	clipText: '', // text to copy to clipboard
	handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
	cssEffects: true, // enable CSS mouse effects on dom container
	handlers: null, // user event handlers
	
	glue: function(elem, appendElem, stylesToAdd) {
		// glue to DOM element
		// elem can be ID or actual DOM element object
		this.domElement = ZeroClipboard.$(elem);
		
		// float just above object, or zIndex 99 if dom element isn't set
		var zIndex = 99;
		if (this.domElement.style.zIndex) {
			zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
		}
		
		if (typeof(appendElem) == 'string') {
			appendElem = ZeroClipboard.$(appendElem);
		}
		else if (typeof(appendElem) == 'undefined') {
			appendElem = document.getElementsByTagName('body')[0];
		}
		
		// find X/Y position of domElement
		var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
		
		// create floating DIV above element
		this.div = document.createElement('div');
		var style = this.div.style;
		style.position = 'absolute';
		style.left = '' + box.left + 'px';
		style.top = '' + box.top + 'px';
		style.width = '' + box.width + 'px';
		style.height = '' + box.height + 'px';
		style.zIndex = zIndex;
		
		if (typeof(stylesToAdd) == 'object') {
			for (addedStyle in stylesToAdd) {
				style[addedStyle] = stylesToAdd[addedStyle];
			}
		}
		
		// style.backgroundColor = '#f00'; // debug
		
		appendElem.appendChild(this.div);
		
		this.div.innerHTML = this.getHTML( box.width, box.height );
	},
	
	getHTML: function(width, height) {
		// return HTML for movie
		var html = '';
		var flashvars = 'id=' + this.id + 
			'&width=' + width + 
			'&height=' + height;
			
		if (navigator.userAgent.match(/MSIE/)) {
			// IE gets an OBJECT tag
			var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
			html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
		}
		else {
			// all other browsers get an EMBED tag
			html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
		}
		return html;
	},
	
	hide: function() {
		// temporarily hide floater offscreen
		if (this.div) {
			this.div.style.left = '-2000px';
		}
	},
	
	show: function() {
		// show ourselves after a call to hide()
		this.reposition();
	},
	
	destroy: function() {
		// destroy control and floater
		if (this.domElement && this.div) {
			this.hide();
			this.div.innerHTML = '';
			
			var body = document.getElementsByTagName('body')[0];
			try { body.removeChild( this.div ); } catch(e) {;}
			
			this.domElement = null;
			this.div = null;
		}
	},
	
	reposition: function(elem) {
		// reposition our floating div, optionally to new container
		// warning: container CANNOT change size, only position
		if (elem) {
			this.domElement = ZeroClipboard.$(elem);
			if (!this.domElement) this.hide();
		}
		
		if (this.domElement && this.div) {
			var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
			var style = this.div.style;
			style.left = '' + box.left + 'px';
			style.top = '' + box.top + 'px';
		}
	},
	
	setText: function(newText) {
		// set text to be copied to clipboard
		this.clipText = newText;
		if (this.ready) this.movie.setText(newText);
	},
	
	addEventListener: function(eventName, func) {
		// add user event listener for event
		// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
		eventName = eventName.toString().toLowerCase().replace(/^on/, '');
		if (!this.handlers[eventName]) this.handlers[eventName] = [];
		this.handlers[eventName].push(func);
	},
	
	setHandCursor: function(enabled) {
		// enable hand cursor (true), or default arrow cursor (false)
		this.handCursorEnabled = enabled;
		if (this.ready) this.movie.setHandCursor(enabled);
	},
	
	setCSSEffects: function(enabled) {
		// enable or disable CSS effects on DOM container
		this.cssEffects = !!enabled;
	},
	
	receiveEvent: function(eventName, args) {
		// receive event from flash
		eventName = eventName.toString().toLowerCase().replace(/^on/, '');
				
		// special behavior for certain events
		switch (eventName) {
			case 'load':
				// movie claims it is ready, but in IE this isn't always the case...
				// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
				this.movie = document.getElementById(this.movieId);
				if (!this.movie) {
					var self = this;
					setTimeout( function() { self.receiveEvent('load', null); }, 1 );
					return;
				}
				
				// firefox on pc needs a "kick" in order to set these in certain cases
				if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
					var self = this;
					setTimeout( function() { self.receiveEvent('load', null); }, 100 );
					this.ready = true;
					return;
				}
				
				this.ready = true;
				this.movie.setText( this.clipText );
				this.movie.setHandCursor( this.handCursorEnabled );
				break;
			
			case 'mouseover':
				if (this.domElement && this.cssEffects) {
					this.domElement.addClass('hover');
					if (this.recoverActive) this.domElement.addClass('active');
				}
				break;
			
			case 'mouseout':
				if (this.domElement && this.cssEffects) {
					this.recoverActive = false;
					if (this.domElement.hasClass('active')) {
						this.domElement.removeClass('active');
						this.recoverActive = true;
					}
					this.domElement.removeClass('hover');
				}
				break;
			
			case 'mousedown':
				if (this.domElement && this.cssEffects) {
					this.domElement.addClass('active');
				}
				break;
			
			case 'mouseup':
				if (this.domElement && this.cssEffects) {
					this.domElement.removeClass('active');
					this.recoverActive = false;
				}
				break;
		} // switch eventName
		
		if (this.handlers[eventName]) {
			for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
				var func = this.handlers[eventName][idx];
			
				if (typeof(func) == 'function') {
					// actual function reference
					func(this, args);
				}
				else if ((typeof(func) == 'object') && (func.length == 2)) {
					// PHP style object + method, i.e. [myObject, 'myMethod']
					func[0][ func[1] ](this, args);
				}
				else if (typeof(func) == 'string') {
					// name of function
					window[func](this, args);
				}
			} // foreach event handler defined
		} // user defined handler for event
	}
	
};


function brightenOnFocus(focused, el, fcs_cls, default_text) {
	if(focused) {
		el.className = fcs_cls;
		
		if(el.value == default_text)
			el.value = "";
	} else  {
		if(el.value == "")
			el.value = default_text;
		if(el.value == default_text)
			el.className = 'unfocused';
	}
}

function forceFormSubmit(id) {
	//fix for ie6
	
	document.myAnonymousFunction = function() {

		document.getElementById(id).submit();
	
	}
	
	setTimeout("document.myAnonymousFunction();", 50);
}

function openWebSupportWindow() { 
	 window.open(JS_UMBRELLA_BASE+'support/ca_webchat.php','_blank','width=470,height=335,toolbar=no,location=no,status=no,menubar=no,scrollbars=0,resizable=0');
}

function urlRedirect(url) { 
	setTimeout("top.location.href = '" + url +"'",1);
}
function urlRedirectBAM(url) { 
	setTimeout("self.location.href = '" + url +"'",1);
}
function bookmarksite(title,url){
    if (window.sidebar) // firefox
    	window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
    } 
	else if(document.all)// ie
    	window.external.AddFavorite(url, title);
}
function delbookmark(type,id) {
	
	var pars = 'aj_action=true&action=del_bookmark';	
	pars += '&type='+type;
	pars += '&id='+id;
	
	var targ = JS_BASE+'global/account/bookmarks.php';
    var myAjax = new Ajax.Updater({success: "bookmark_"+type+"_"+id},targ,{method: 'post', parameters: pars, evalScripts: true});	
}

function showhideset(option, test){
	if(test=="hide"){
		getObject(option).style.display="none";
	} else if(test=="show"){
		getObject(option).style.display="block";
	}

}

var nmHaschanged = false;
function textOnNewMessSubmittedNotice() {
	if(nmHaschanged == false){
		nmHaschanged = true;
		getObject('textonnmnoticebutton').disabled = false;
	} else {
		nmHaschanged = false;
		getObject('textonnmnoticebutton').disabled = true;
	}
}


function proceedToCheckout(base) {
	var args = "";
	var buymeatree = $('buy_tree');
	if(buymeatree) {
		args += '?bt='+buymeatree.value;
	}
	
	urlRedirect(base+'checkout/checkout.php'+args);
}


function get_radio_value(el)
{
	var rad_val = "";
	for (var i=0; i < el.length; i++)
   {
   	  if (el[i].checked)
      {
      	rad_val = el[i].value;
      	break;
      }
   }
   
   return rad_val;
}


function quickRegisterValidateQ(theForm)
{

	
	if (theForm.title.value == "")
	{
		alert("Please select your Title");
		return false;
	}

	if (theForm.FirstName.value == "")
	{
		alert("Please enter your First Name");
		return false;
	}

	if (theForm.LastName.value == "")
	{
		alert ("Please enter your Last Name");
		return false;
	}

//	if(theForm.telephone.value != ""){
//		//alert("Telephone is wrong");
//		/* Check numeric */
//		var i;
//		for(i=0;i<theForm.telephone.value.length;i++){
//			if(!(	((theForm.telephone.value.charAt(i) <= '9') && (theForm.telephone.value.charAt(i) >= '0')) ||
//			(theForm.telephone.value.charAt(i) == ' ') || (theForm.telephone.value.charAt(i) == '.') || (theForm.telephone.value.charAt(i) == '-'))){
//				alert("Telephone should be numeric only (no spaces, letters or symbols)");
//				return(false);
//			}
//		}
//		if (theForm.telephone.value.indexOf(" ") > -1) {
//			alert("Telephone should be numeric only (no spaces, letters or symbols)");
//			return false;
//		}
//		/* Check length */
//		//check min length
//		if (theForm.telephone.value.length < 10)
//		{
//			alert("The mobile number is too short");
//			return false;
//		}
//		//check max length
//		if (theForm.telephone.value.length > 12)
//		{
//			alert("The mobile number is too long");
//			return false;
//		}
//		//check it starts with '07'
//		if ((theForm.telephone.value.charAt(0) != "0")&&(theForm.telephone.value.charAt(0) != "7"))
//		{
//			alert("Please enter a valid UK mobile number (e.g. 07123456789)");
//			return false;
//		}
//		// check spacebar
//
//	}
//
//	if(theForm.telephone.value == "")
//	{
//		alert("You must enter a valid UK mobile number");
//		return false;
//	}

	if (theForm.email.value.search("@") == -1 || theForm.email.value.search("[.*]") == -1)
	{
		alert ("Please enter a valid E-mail address");
		return false;
	}
		
	if (theForm.Password.value == "")
	{
		alert("Please enter your Password");
		return false;
	}
	if (theForm.Password.value != theForm.Cpassword.value)
	{
		alert("Your passwords did not match, please input them again");
		return false;
	}	
		
	return true;
}





function quickRegisterValidate(theForm)
{

	if (get_radio_value(theForm.Type) == "")
	{
		alert ("Are you a Landlord, Student or Other? Please choose...");
		return false;
	}
	
	if (theForm.title.value == "")
	{
		alert("Please select your Title");
		return false;
	}

	if (theForm.FirstName.value == "")
	{
		alert("Please enter your First Name");
		return false;
	}

	if (theForm.LastName.value == "")
	{
		alert ("Please enter your Last Name");
		return false;
	}


//	if (theForm.Username.value == "")
//	{
//		alert ("Please enter your Username");
//		return false;
//	}

	if (theForm.Password.value == "")
	{
		alert("Please enter your Password");
		return false;
	}
	if (theForm.Password.value != theForm.Cpassword.value)
	{
		alert("Your passwords did not match, please input them again");
		return false;
	}
		

//	if(theForm.telephone.value != ""){
//		//alert("Telephone is wrong");
//		/* Check numeric */
//		var i;
//		for(i=0;i<theForm.telephone.value.length;i++){
//			if(!(	((theForm.telephone.value.charAt(i) <= '9') && (theForm.telephone.value.charAt(i) >= '0')) ||
//			(theForm.telephone.value.charAt(i) == ' ') || (theForm.telephone.value.charAt(i) == '.') || (theForm.telephone.value.charAt(i) == '-'))){
//				alert("Telephone should be numeric only (no spaces, letters or symbols)");
//				return(false);
//			}
//		}
//		if (theForm.telephone.value.indexOf(" ") > -1) {
//			alert("Telephone should be numeric only (no spaces, letters or symbols)");
//			return false;
//		}
//		/* Check length */
//		//check min length
//		if (theForm.telephone.value.length < 10)
//		{
//			alert("The mobile number is too short");
//			return false;
//		}
//		//check max length
//		if (theForm.telephone.value.length > 12)
//		{
//			alert("The mobile number is too long");
//			return false;
//		}
//		//check it starts with '07'
//		if ((theForm.telephone.value.charAt(0) != "0")&&(theForm.telephone.value.charAt(0) != "7"))
//		{
//			alert("Please enter a valid UK mobile number (e.g. 07123456789)");
//			return false;
//		}
//		// check spacebar
//
//	}
//
//	if(theForm.telephone.value == "")
//	{
//		alert("You must enter a valid UK mobile number");
//		return false;
//	}


	if (theForm.email.value.search("@") == -1 || theForm.email.value.search("[.*]") == -1)
	{
		alert ("Please enter a valid E-mail address");
		return false;
	}
	
	
	
	
	if( theForm.captcha.value =="") {
		alert("Please confirm the word shown in the image.");
		return false;		
	}
	
	if ((theForm.tandc.checked != true))
	{
		alert("Please confirm you have read and agree to our Terms & Conditions!");
		return false;
	}
	
	return true;
}

/**
	Ensure the given field (object) is filled in by the user. If not
	a message is displayed quoting the given name (string).
**/
function ensureFilled(field, name) {
	var valid = (field && field.value);
	if(!valid) {
		alert('Please enter a '+name);
	}
	
	return valid;
}

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

/** Anything beyond this point is DEPRECATED - DO NOT USE **/

function getObject(name) {
	var ns4 = (document.layers) ? true : false;
	var w3c = (document.getElementById) ? true : false;
	var ie4 = (document.all) ? true : false;
	if (ns4) return eval('document.' + name);
	if (w3c) return document.getElementById(name);
	if (ie4) return eval('document.all.' + name);
	return false;

}

function bgRequest(url) {

	// Internet Explorer
	try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e) {
		try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(oc) { req = null; }
	}

	// Mozailla/Safari
	if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); }

	// Call the processChange() function when the page has loaded
	if (req != null) {

		req.open("GET", url, true);
		req.send(null);
	}

}

function selectAll() {
	d = document.act_form;
	for (i = 0; i < d.elements.length; i++) {
		if (d.elements[i].type == "checkbox") {
			d.elements[i].checked = true;
		}
	}
}

function deselectAll() {
	d = document.act_form;
	for (i = 0; i < d.elements.length; i++) {
		if (d.elements[i].type == "checkbox") {
			d.elements[i].checked = false;
		}
	}
}
/*accMod.php*/
function accModValidate1(theForm)
{

	if (theForm.title.value == "")
	{
		alert("Please select your Title");
		return false;
	}

	if (theForm.FirstName.value == "")
	{
		alert("Please enter your First Name");
		return false;
	}
	if (theForm.FirstName.value.match(/\W/)) 
	{ 
		alert ("Your name should only contain letters!");
		return false;
		}
	if (theForm.LastName.value == "")
	{
		alert ("Please enter your Surname");
		return false;
	}
	if (theForm.LastName.value.match(/\W/)) 
	{ 
		alert ("Your name should only contain letters!");
		return false;
		}

	if (theForm.Password.value != theForm.Cpassword.value)
	{
		alert("Your passwords did not match, please input them again");
		return false;
	}


	return true;
}


function accModValidate2(theForm)
{
	

	if (theForm.day.value == "")
	{
		alert("Please complete your Date of Birth");
		return false;
	}
	if (theForm.month.value == "")
	{
		alert("Please complete your Date of Birth");
		return false;
	}
	if (theForm.year.value == "")
	{
		alert("Please complete your Date of Birth");
		return false;
	}

	if(theForm.mobile.value != ""){
		
		var i;
		for(i=0;i<theForm.mobile.value.length;i++){
			if(!(	((theForm.mobile.value.charAt(i) <= '9') && (theForm.mobile.value.charAt(i) >= '0')) ||
			(theForm.mobile.value.charAt(i) == ' ') || (theForm.mobile.value.charAt(i) == '.') || (theForm.mobile.value.charAt(i) == '-'))){
				alert("Mobile number should be numeric only (no spaces, letters or symbols)");
				return(false);
			}
		}
		if (theForm.mobile.value.indexOf(" ") > -1) {
			alert("Mobile number should be numeric only (no spaces, letters or symbols)");
			return false;
		}
		/* Check length */
		//check min length
		if (theForm.mobile.value.length < 10)
		{
			alert("The mobile number is too short");
			return false;
		}
		//check max length
		if (theForm.mobile.value.length > 12)
		{
			alert("The mobile number is too long");
			return false;
		}
		//check it starts with '07'
		if ((theForm.mobile.value.charAt(0) != "0")&&(theForm.telephone.value.charAt(0) != "7"))
		{
			alert("Please enter a valid UK mobile number (e.g. 07123456789)");
			return false;
		}
		// check spacebar

	}

	if(theForm.mobile.value == "")
	{
		alert("You must enter a valid UK mobile number");
		return false;
	}

	
	if(!validateAddress(theForm)){
		alert("Please enter a valid address and postcode");
		return false;
	}
	
	
	
	if(theForm.phone.value != ""){
		
		var i;
		for(i=0;i<theForm.phone.value.length;i++){
			if(!(	((theForm.phone.value.charAt(i) <= '9') && (theForm.phone.value.charAt(i) >= '0')) ||
			(theForm.phone.value.charAt(i) == ' ') || (theForm.phone.value.charAt(i) == '.') || (theForm.phone.value.charAt(i) == '-'))){
				alert("Telephone number should be numeric only (no spaces, letters or symbols)");
				return(false);
			}
		}
		if (theForm.phone.value.indexOf(" ") > -1) {
			alert("Telephone number should be numeric only (no spaces, letters or symbols)");
			return false;
		}
		/* Check length */
		//check min length
		if (theForm.phone.value.length < 10)
		{
			alert("The phone number is too short");
			return false;
		}
		//check max length
		if (theForm.phone.value.length > 12)
		{
			alert("The phone number is too long");
			return false;
		}
		
		

	}



//	if (theForm.email.value.search("@") == -1 || theForm.email.value.search("[.*]") == -1)
//	{
//		alert ("Please enter a valid E-mail address");
//		return false;
//	}
}
function validateNewProp(theForm){
	
	var form = $(theForm);
	var code1 = form['subdivided'];
	var code2 = form['propertyTypeID'];
	
	subdivided = $F(code1);
	propertyType = $F(code2);
	

	
	
	if(!validateAddress(theForm)){
		
		return false;
	}
		if(propertyType=='0'){
		alert("Please select the type of property");
		return false;
	}
	
		if(propertyType!='6'){
			if(subdivided=='0'){
			alert("Please select the number of rooms");
			return false;
		}
	}
	
	
	
	return true;
	
}
function accModValidateUniNagger(theForm) {
	
	if (theForm.occupation.value == "" || theForm.occupation.value == "Please choose...")
	{
		alert("Please select your group");
		return false;
	}
	
	if(theForm.occupation.value == "Student" || theForm.occupation.value == "Graduate") {
		if (theForm.uni.value == "" && theForm.uni_other && theForm.uni_other.value == "")
		{
			alert("Please select your University");
			return false;
		}
		
		
		if ((theForm.subj.value == "0" || theForm.subj.value == "") && theForm.subject_other && theForm.subject_other.value == "")
		{
			alert("Please select your Subject");
			return false;
		}
	}
	
	return true;
}
function accModValidatePersNagger(theForm) {
	
	if (theForm.PostCode1.value == "")
	{
		alert("Please complete your address");
		return false;
	}
	
	if (theForm.PostCode2.value == "")
	{
		alert("Please complete your address");
		return false;
	}
	if (theForm.regday.value == "")
	{
		alert("Please complete your Date of Birth");
		return false;
	}
	if (theForm.regmonth.value == "")
	{
		alert("Please complete your Date of Birth");
		return false;
	}
	if (theForm.regyear.value == "")
	{
		alert("Please complete your Date of Birth");
		return false;
	}
	
	
	
	return true;
}

function accModValidateConNagger(theForm)
{

	if(theForm.phone.value != ""){
		//alert("Telephone is wrong");
		/* Check numeric */
		var i;
		for(i=0;i<theForm.phone.value.length;i++){
			if(!(	((theForm.phone.value.charAt(i) <= '9') && (theForm.phone.value.charAt(i) >= '0')) ||
			(theForm.phone.value.charAt(i) == ' ') || (theForm.phone.value.charAt(i) == '.') || (theForm.phone.value.charAt(i) == '-'))){
				alert("Phone number should be numeric only (no spaces, letters or symbols)");
				return(false);
			}
		}
		if (theForm.phone.value.indexOf(" ") > -1) {
			alert("Phone number should be numeric only (no spaces, letters or symbols)");
			return false;
		}
		/* Check length */
		//check min length
		if (theForm.phone.value.length < 10)
		{
			alert("The phone number is too short");
			return false;
		}
		//check max length
		if (theForm.phone.value.length > 12)
		{
			alert("The phone number is too long");
			return false;
		}
		//check it starts with '07'
		if ((theForm.phone.value.charAt(0) != "0")&&(theForm.telephone.value.charAt(0) != "7"))
		{
			alert("Please enter a valid UK phone number (e.g. 07123456789)");
			return false;
		}
		// check spacebar

	}

	

	
		if(theForm.mobile.value != ""){
		//alert("Telephone is wrong");
		/* Check numeric */
		var i;
		for(i=0;i<theForm.mobile.value.length;i++){
			if(!(	((theForm.mobile.value.charAt(i) <= '9') && (theForm.mobile.value.charAt(i) >= '0')) ||
			(theForm.mobile.value.charAt(i) == ' ') || (theForm.mobile.value.charAt(i) == '.') || (theForm.mobile.value.charAt(i) == '-'))){
				alert("mobile number should be numeric only (no spaces, letters or symbols)");
				return(false);
			}
		}
		if (theForm.mobile.value.indexOf(" ") > -1) {
			alert("mobile number should be numeric only (no spaces, letters or symbols)");
			return false;
		}
		/* Check length */
		//check min length
		if (theForm.mobile.value.length < 10)
		{
			alert("The mobile number is too short");
			return false;
		}
		//check max length
		if (theForm.mobile.value.length > 12)
		{
			alert("The mobile number is too long");
			return false;
		}
		//check it starts with '07'
		if ((theForm.mobile.value.charAt(0) != "0")&&(theForm.telephone.value.charAt(0) != "7"))
		{
			alert("Please enter a valid UK mobile number (e.g. 07123456789)");
			return false;
		}
		// check spacebar

	}

	if(theForm.mobile.value == "")
	{
		alert("You must enter a valid UK mobile number");
		return false;
	}
	
	
	
	
	
	

	if (theForm.email.value.search("@") == -1 || theForm.email.value.search("[.*]") == -1)
	{
		alert ("Please enter a valid E-mail address");
		return false;
	}
	
	return true;
}


function accModValidate3(theForm) {
	if (theForm.occupation.value == "" || theForm.occupation.value == "Please choose...")
	{
		alert("Please select your group");
		return false;
	}
	
	if(theForm.occupation.value == "Student" || theForm.occupation.value == "Graduate") {
		if (theForm.uni.value == "" )
		{
			alert("Please select your University");
			return false;
		}
		
		
		if ((theForm.subj.value == "0" || theForm.subj.value == "") && theForm.subject_other && theForm.subject_other.value == "")
		{
			alert("Please select your Subject");
			return false;
		}
	}
	
	return true;
}




function validatePostCode(PostCode1, PostCode2){ //check postcode format is valid
	test1 = PostCode1.value;
	size1 = test1.length;
	test2 = PostCode2.value;
	size2 = test2.length;
	test1 = test1.toUpperCase(); //Change to uppercase
	test2 = test2.toUpperCase(); //Change to uppercase
  if(test1 != '412') {
  	if ((size1 + size2) < 5 || (size1 + size2) > 8){ //Code length rule
  		alert(test1 + " " + test2 + " is not a valid postcode - wrong length");
  		//PostCode1.focus();
  		return false;
  	}
  	if (!(isNaN(test1.charAt(0)))){ //leftmost character must be alpha character rule
  		alert(test1 + " " + test2 + " is not a valid postcode - cannot start with a number");
  		//PostCode1.focus();
  		return false;
  	}
  }

	return true;
}

/*
Checks the postcode plus the presence of a first address line - returns true or false

*/
function validateAddress(formName){
	var form = $(formName);
	var pcode1 = form['PostCode1'];
	var pcode2 = form['PostCode2'];
	var addr1 = form['addressLine1'];
	var addr2 = form['addressLine2'];
	var addrTown = form['Town'];
	var addrCounty = form['County'];
		
	postCode1 = $F(pcode1);
	postCode2 = $F(pcode2);
	addressLine1 = $F(addr1);
	addressLine2 = $F(addr2);

	
	if($F(addr1).search("@") != -1 || $F(addr2).search("@")!= -1 || $F(addrTown).search("@")!= -1 ||$F(addrCounty).search("@")!= -1){
		alert("No email addresses allowed");
		return false;
	}
	if(newValidatePostcode(postCode1,postCode2)&&(addressLine1)){
		return true;
	}
	alert("Please enter a valid address and postcode");
	return false;
	
	
	
}

function newValidatePostcode(PostCode1, PostCode2){
	
	
	size1 = PostCode1.length;
	size2 = PostCode2.length;
	test1 = PostCode1.toUpperCase(); //Change to uppercase
	test2 = PostCode2.toUpperCase(); //Change to uppercase
	if ((size1 + size2) < 5 || (size1 + size2) > 8){ //Code length rule
		
		return false;
	}
	if (!(isNaN(test1.charAt(0)))){ //leftmost character must be alpha character rule
		
		return false;
	}

	return true;
	
}

function recalcBasket() {
	
	var fields = $$(".basket_quantity_field");
	
	var pars = 'aj_action=true&action=recalcbasket';	
	var buymeatree = $('buy_tree');
	if(buymeatree) {
		pars += '&buy_tree='+buymeatree.value;
	}
	for(var i = 0; i < fields.length; i++) {
		var pid = fields[i].id;
		pid = pid.substr(pid.lastIndexOf('_')+1);
		
		pars += '&'+pid+'='+fields[i].value;
	}
	
	showSpinnerIn($('editbasketform'));
	var targ = JS_UMBRELLA_BASE+'g/classes/Basket.class.php';
    var myAjax = new Ajax.Updater({success: "editbasketform"},targ,{method: 'post', parameters: pars, evalScripts: true});	
}


function updateMiniBasket() {
	
	var pars = 'aj_action=true&action=showminibasket';
	var targ = JS_UMBRELLA_BASE+'g/classes/Basket.class.php';
    var myAjax = new Ajax.Updater({success: "basket_container"},targ,{method: 'post', parameters: pars, evalScripts: true});
	
}

function recalcWLBasket() {
	
	var fields = $$(".basket_quantity_field");
	
	var pars = 'aj_action=true&action=recalcWLbasket';	
	var buymeatree = $('buy_tree');
	if(buymeatree) {
		pars += '&buy_tree='+buymeatree.value;
	}
	for(var i = 0; i < fields.length; i++) {
		var pid = fields[i].id;
		pid = pid.substr(pid.lastIndexOf('_')+1);
		
		pars += '&'+pid+'='+fields[i].value;
	}
	
	showSpinnerIn($('editbasketform'));
	var targ = JS_UMBRELLA_BASE+'g/classes/Basket.class.php';
    var myAjax = new Ajax.Updater({success: "editbasketform"},targ,{method: 'post', parameters: pars, evalScripts: true});	
}


function updateMiniWLBasket() {
	
	var pars = 'aj_action=true&action=showminiWLbasket';
	var targ = JS_UMBRELLA_BASE+'g/classes/Basket.class.php';
    var myAjax = new Ajax.Updater({success: "basket_container"},targ,{method: 'post', parameters: pars, evalScripts: true});
	
}


function showSpinnerIn(el, nofillwidth, nofillheight) {
	var spinner = '<table cellpadding="0" cellspacing="0" border="0"';

	if(!nofillwidth) {
		spinner += 'width="100%"';
	}
	if(!nofillheight) {
		spinner += 'height="100%"';
	}
	
	spinner += ' ><tr><td valign="middle" align="center"><img src="'+JS_BASE+'images/aj_loading.gif" align="absmiddle" border="0"/></td></tr></table>';
	
	el.innerHTML = spinner;
}
function textCounter(field,cntfield,maxlimit) {
	var textlength = document.getElementById(field);
	if (textlength.value.length > maxlimit) {
		textlength.value = textlength.value.substring(0, maxlimit);
		
	}else {
		cntfield = document.getElementById(cntfield);
		cntfield.value = maxlimit - textlength.value.length;
		
	}
}
function validateLaptop(formRef){
	
	var form = $(formRef);
	var code1 = form['brand'];
	
	
	brand = $F(code1);
	
	
	if(brand=="Please Select..."){
		alert("Please select a brand");
		return false;
	}
	if(!formRef.price.value){
		alert("Please enter a price");
		return false;
	}
	if(!formRef.pAndP.value){
		alert("Please enter the cost of postage and packing");
		return false;
	}
	return true;
	
}
/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var trailimage=["test.gif", 250, 250] //image path, plus width and height
var offsetfrommouse=[15,15] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0 //duration in seconds image should remain visible. 0 for always.
var trailid = "floating_desc";
var imageheight = 0;	
var imagewidth = 0;

function gettrailobj(){
	if($(trailid))	
		return $(trailid).style
	else 
		return null;
}

function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail(){
	gettrailobj().visibility="hidden";
	document.onmousemove="";
	gettrailobj().left="-500px"
	imageheight = 0;
}

function followmouse(e) {
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]
	
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)
	
	var width = imagewidth + 33;

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < width){
			xcoord = e.pageX - xcoord - width; 
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (imageheight+ 35 )){
			ycoord += e.pageY - Math.max(0,( imageheight+ 35 + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < width){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - width; 
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (imageheight + 35 )){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,( imageheight + 35 + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	
}

function showtrail(desc, title,height, width,border) {
	if(!border )
		border = 10;
	
	document.onmousemove=followmouse;
	
	imageheight = height+border;
	imagewidth = width+border;
	//Logger.info("height: "+height);
	
	var content = !(imageheight && imagewidth) ? '' : '<iframe src="about:blank" scrolling="no" frameborder="0" style="width:'+(imagewidth+12)+'px;height:'+(imageheight+12)+'px;border:none;display:block;z-index:0;position:absolute;"></iframe>';
	content += '<div style="padding: 5px; background-color: #FFFFFF; border: 1px solid #888888;' + (imageheight && imagewidth ? 'width:'+imagewidth+'px;height:'+imageheight+'px;' : '')+'z-index:1;position:absolute;">';
	if(title)
		content += '<strong style="font-size:12px;">'+title+'</strong><br/>';
	content += '<div style="padding: 2px 2px 2px 2px;">' + $(desc).innerHTML + ' </div>';
	content += '</div>';
	
	$(trailid).innerHTML = content;
	gettrailobj().visibility="visible";
}

function showtrailimg(img, imageheight, imagewidth) {
	
	document.onmousemove=followmouse;
	
	//Logger.info("height: "+height);
	
	var content = !(imageheight && imagewidth) ? '' : '<iframe src="about:blank" scrolling="no" frameborder="0" style="width:'+(imagewidth+12)+'px;height:'+(imageheight+12)+'px;border:none;display:block;z-index:0;position:absolute;"></iframe>';
	content += '<div style="padding: 5px; background-color: #FFFFFF; border: 1px solid #888888;z-index:1;position:absolute;">';
	content += '<div style="' + (imageheight && imagewidth ? 'width:'+imagewidth+'px;height:'+imageheight+'px' : '') + '"><img '+(imageheight && imagewidth ? 'width="'+imagewidth+'" height="'+imageheight+'"' : '')+' src="' + img + '" border="0"/></div>';
	content += '</div>';
	
	$(trailid).innerHTML = content;
	gettrailobj().visibility="visible";
}






function showModalWidget(base_url, content, args,response) {
	
	if(!base_url) {
		base_url = JS_BASE;
	}
		
	//alert(window.frames['modal_widget_frame'].document.getElementById('mw_content'));
	
//	$('modal_widget_frame').src = base_url + 'util/modalWidgetContent.php?content='+content+'&title='+title;
	resizeModalWidget(content);
	
	
	loadModalWidgetContent(base_url,content,args,response);
		
}

function postIntoModalWidget(form,content) {
	resizeModalWidget(content);
	
	showSpinnerIn(window.frames['modal_widget_frame'].document.getElementById('mw_content') );
	$(form).target = 'modal_widget_frame';
	$(form).action = JS_BASE+'g/modalwidget/modalWidgetContent.php?static_aj=true&action='+content;
	$(form).method = 'post';
	forceFormSubmit(form);
}

function resizeModalWidget(content,nofade) {
	if(content == 'null' || content == '' ) {
		return;
	}
	
	var dim = getContentSize(content);
	
	var width = dim[0];
	var height = dim[1];
	
	if(!nofade) {
		setOpacity($('modal_widget'),0.0);
//		fireOpacityEffect($('modal_widget'),0.0,0.0);
//		$('modal_widget').style.display = 'none';
	}
	if($('modal_widget_bg').getOpacity() == 1.0) {
		setOpacity($('modal_widget_bg'),0.0);
	}
	$('modal_widget').style.height = (height)+'px';
	$('modal_widget').style.width = (width)+'px';
	
	$('modal_widget_frame').width = width ;
	$('modal_widget_frame').height = height ;
	
	$('modal_widget_border').style.height = (height+22)+'px';
	$('modal_widget_border').style.width = (width+22)+'px';
	
	$('modal_widget_border_frame').style.height = (height+22)+'px';
	$('modal_widget_border_frame').style.width = (width+22)+'px';
	
	var innerWidth = self.innerWidth ? self.innerWidth : $('page_body').clientWidth;
	var innerHeight = self.innerHeight ? self.innerHeight : $('page_body').clientHeight;
	
	
	$('modal_widget').style.left = $('page_body').scrollLeft + innerWidth/2 - width/2;
	$('modal_widget').style.top = $('page_body').scrollTop + innerHeight/2 - height/2;
	
	$('modal_widget_border').style.left = $('page_body').scrollLeft + innerWidth/2 - width/2 - 11;
	$('modal_widget_border').style.top = $('page_body').scrollTop + innerHeight/2 - height/2 - 11;
	
	setOpacity($('modal_widget_border'),0.6);
	
	$('modal_widget_bg').style.top = 0;
	$('modal_widget_bg').style.left = 0;
	$('modal_widget_bg').style.height =  $('page_body').scrollHeight;
	$('modal_widget_bg').style.width =  $('page_body').scrollWidth;
	$('modal_widget_bg_frame').height =  $('page_body').scrollHeight;
	$('modal_widget_bg_frame').width =  $('page_body').scrollWidth;
	
	if(!nofade) {
		new Effect.Appear($('modal_widget'), {duration:.2});
	}
	else {
		setOpacity($('modal_widget'),1.0);
//		$('modal_widget').style.display = 'block';
	}
	if($('modal_widget_bg').getOpacity() == 0.0) {
//	if($('modal_widget_bg').style.display == 'none') {
	
		fireOpacityEffect($('modal_widget_bg'),0.0,0.6);
	}
	
}

function getContentSize(content) {
	var ret = new Array(2); //width,height
	switch (content) {
		case "registered_check":
			ret[0] = 300;
			ret[1] = 110;
			break;
		case "session_timeout":
		case "session_restore":
		case "login":
			ret[0] = 200;
			ret[1] = 200;
			break;
		case "register":
			ret[0] = 595;
			ret[1] = 460;
			break;
		
		case "error":
			ret[0] = 300;
			ret[1] = 300; 
			break;
		default:
			ret = subSiteGetContentSize(content);
			break;
	}
	
	return ret;
}

function close_modal_widget() {
	closeModalWidget();
}

function closeModalWidget() {
	$('modal_widget_bg').style.top = -20000;
	$('modal_widget_bg').style.left = -20000;
	
	$('modal_widget').style.top = -20000;
	$('modal_widget').style.left = -20000;
	
	$('modal_widget_border').style.top = -20000;
	$('modal_widget_border').style.left = -20000;
	
	setOpacity($('modal_widget'),0.0);
	setOpacity($('modal_widget_bg'),0.0);
	setOpacity($('modal_widget_border'),0.0);
	
//	$('modal_widget').style.display = 'none';
//	$('modal_widget_bg').style.display = 'none';
}

function getMwAjaxUrl(base) {
	return base + "g/modalwidget/modalWidgetContent.php";
}

function mwAjUpdateSuccess(req) {
	var fill = window.frames['modal_widget_frame'].document.getElementById('mw_content');
	
	fill.innerHTML = req.responseText;
	
	var resiz = window.frames['modal_widget_frame'].document.getElementById('resize_for_content');
	
	if(resiz) {
		resizeModalWidget(resiz.innerHTML,true);
	}
	
	var scrip = window.frames['modal_widget_frame'].document.getElementById('exec_script');
	
	if(scrip) {
		eval(scrip.innerHTML);
	}
}

function loadModalWidgetContent(base,content, args, response) {
	showSpinnerIn(window.frames['modal_widget_frame'].document.getElementById('mw_content') );
	
	var pars = 'aj_action=true&action='+content;
	if(args) {
		pars += '&'+args;
	}
	var myAjax = new Ajax.Request(getMwAjaxUrl(base),{method: 'post', parameters: pars, onFailure: window.frames['modal_widget_frame'].ajError, onSuccess: mwAjUpdateSuccess, onComplete: response});	

}



function subSiteGetContentSize(content) {
	var ret = new Array(2); //width,height
	switch (content) {
		case "buy_books":
			ret[0] = 250;
			ret[1] = 110;
			break;
		case "save_wl_single":
		case "save_wl":
			ret[0] = 300;
			ret[1] = 190;
			break;		
		case "add_books_to_wl":
			ret[0] = 370;
			ret[1] = 295;		
			break;
		case "book_preview":
			ret[0] = 500;
			ret[1] = 440;	
			break;
		case "royal_mail_info":
			ret[0] = 550;
			ret[1] = 420;			
			break;
		case "sell_books":
			ret[0] = 300;
			ret[1] = 120;		
			break;
		case "register_and_save_wl":
			ret[0] = 595;
			ret[1] = 500;
			break;
			
		case "wl_title_isbn":
			ret[0] = 300;
			ret[1] = 230;		
			break;
			
		case "sell_books_no_contact_details":
			ret[0] = 300;
			ret[1] = 190;
			break;
		case "ebook_info":
			ret[0] = 480;
			ret[1] = 360;			
			break;
		case "ebook_options":
			ret[0] = 520;
			ret[1] = 340;			
			break;
		
		default:
			ret[0] = 300;
			ret[1] = 300; 
			break;
	}
	
	return ret;
}




function swap_image(type, base) {
	switch(type) {
		case 'adv_search_img':
			var newsrc = base+'images/upArrow.gif';
			if($(type).src == base+'images/upArrow.gif') {
				newsrc = base+'images/downArrow.gif';
			}
			setTimeout("$('"+type+"').src = '"+newsrc+"'",500);
//			alert("$('"+type+"').src = '"+newsrc+"'");
			break;
		default:
			alert('unknown image swap '+type);
			break;
	}
}

var uni_select_target ="";
function handleUniIframeSelection(uni_id, uni_name) {
	switch (uni_select_target) {
		case "front_page":
			location.href = JS_BASE+'?u='+uni_id;
			break;
		case "comp_front_page":
			$('comp_uni_div').innerHTML = uni_name;
			$('comp_uni').value = uni_id;
			break;
		case "reg_page":
			$('uni_div').innerHTML = uni_name;
			$('uni').value = uni_id;
			break;
		case "acc_page":
			$('uni_div').innerHTML = uni_name;
			$('uni').value = uni_id;
			break;
		default:
			break;
	}
	closeUniSelector();
}

function showUniSelector(target) {
	uni_select_target = target;
//	uni_select_args = args;
		
	var width = 400;
	var height = 300;
	
	setOpacity($('uni_selecter'),0.0);
	setOpacity($('uni_selecter_bg'),0.0);	
	
	var innerWidth = self.innerWidth ? self.innerWidth : $('page_body').clientWidth;
	var innerHeight = self.innerHeight ? self.innerHeight : $('page_body').clientHeight;
	
	$('uni_selecter').style.height = (height)+'px';
	$('uni_selecter').style.width = (width)+'px';
	
	$('uni_selecter_frame').width = width ;
	$('uni_selecter_frame').height = height ;
	
	$('uni_selecter_bg').style.height =  $('page_body').scrollHeight;
	$('uni_selecter_bg').style.width =  $('page_body').scrollWidth;
	$('uni_selecter_bg_frame').height =  $('page_body').scrollHeight;
	$('uni_selecter_bg_frame').width =  $('page_body').scrollWidth;
	
	$('uni_selecter_border').style.height = (height+22)+'px';
	$('uni_selecter_border').style.width = (width+22)+'px';
	
	$('uni_selecter_border_frame').style.height = (height+22)+'px';
	$('uni_selecter_border_frame').style.width = (width+22)+'px';
	
	window.frames['uni_selecter_frame'].window.reset_uni_selector();
		
	new Effect.Appear($('uni_selecter'), {duration:.5});
	
	fireOpacityEffect($('uni_selecter_bg'),0.0,0.6);
	
	$('uni_selecter').style.left = $('page_body').scrollLeft + innerWidth/2 - width/2;
	$('uni_selecter').style.top = $('page_body').scrollTop + innerHeight/2 - height/2;
	
	$('uni_selecter_border').style.left = $('page_body').scrollLeft + innerWidth/2 - width/2 - 11;
	$('uni_selecter_border').style.top = $('page_body').scrollTop + innerHeight/2 - height/2 - 11;
	
	setOpacity($('uni_selecter_border'),0.6);
	
	$('uni_selecter_bg').style.top = 0;
	$('uni_selecter_bg').style.left = 0;
}

function close_uni_selecter() {
	closeUniSelector();
}

function closeUniSelector() {
	uni_select_target = "";
//	uni_select_args = "";
	
	$('uni_selecter_bg').style.top = -20000;
	$('uni_selecter_bg').style.left = -20000;
	
	$('uni_selecter').style.top = -20000;
	$('uni_selecter').style.left = -20000;
	
	$('uni_selecter_border').style.top = -20000;
	$('uni_selecter_border').style.left = -20000;
	
	setOpacity($('uni_selecter'),0.0);
	setOpacity($('uni_selecter_bg'),0.0);
	setOpacity($('uni_selecter_border'),0.0);
	
	
}


function spinNewsItem(old_id, new_id) {
	
//	new Effect.Fade($('nws_spin_item_'+old_id), {duration: 0.5});
//	new Effect.Appear($('nws_spin_item_'+new_id),{duration: 0.5, delay:0.6});
	$('nws_spin_item_'+old_id).style.display = 'none';
//	new Effect.Hide($('nws_spin_item_'+old_id));
//	new Effect.Morph('nws_spin_item_'+old_id,{
//	  style:'display:none',
//	  duration:0.3
//	});
//	new Effect.Show($('nws_spin_item_'+new_id),{delay:0.6});
//	$('nws_spin_item_'+new_id).style.display = '';
	setTimeout("$('nws_spin_item_"+new_id+"').style.display = '';",600);
	
	var nxt_id = new_id+1;
	if(nxt_id > n_spin_num) {
		nxt_id = 1;
	}
	setTimeout("spinNewsItem("+new_id+", "+nxt_id+")",6000);
}

function quickSubjectSearch(inp, indic, fill, base_url_dyn) {
	if(inp.className == 'unfoc') {
		inp.value = '';
		inp.className = 'foc';
	}
	new Ajax.Autocompleter(inp, fill,base_url_dyn+'misc/bic_ajax_helper.php', { paramName: 'search_str', parameters: 'action=quick_search', minChars: 1, indicator: indic, updateElement: quickSubjectSearchSelect});
	
}
function quickSubjectSearchSelect(li) {
	if(li && li.getAttribute('value') && li.getAttribute('value') != "" ) { 
		urlRedirect(JS_BASE+'books/search.php?search=1&search_bic='+li.getAttribute('value'));
	}
}

function setOpacity(el, op) {
	if(/MSIE/.test(navigator.userAgent) && !window.opera && (!el.currentStyle.hasLayout))
      el.setStyle({zoom: 1});
      
    el.setOpacity(op);
}

function fireOpacityEffect(el, from, to) {
	
	var options = Object.extend({
		from:  from ,
		to: to,
		// force Safari to render floated elements properly
		afterFinishInternal: function(effect) {
		effect.element.forceRerendering();
		},
		beforeSetup: function(effect) {
		effect.element.setOpacity(effect.options.from).show();
		}}, {});
		
	new Effect.Opacity(el, options);
}


function tradedoublerFlashFix() {
	var fl = $('td_flash');
	if(fl && fl.nodeName == 'OBJECT') {
		fl.setAttribute('wmode','transparent');
		
		for(var i = 0; i < fl.childNodes.length; i++) {
			var ch = fl.childNodes[i];
			if(ch.nodeName == 'PARAM' && ch.name == 'wmode') {
				ch.value = 'transparent';
			}
			if(ch.nodeName == 'EMBED') {
				ch.setAttribute('wmode','transparent');
			}
		}
	}
}