/* Javascript Functionality for crowdSPRING.com */var CS = new Class({		initialize: function(){				if($('projectCreation')){			if(!$('projectCreation').hasClass('confirm')){				new ProjectCreation();			}			}		for(var i=0; i < $$('select.dropDown').length; i++){			$$('select.dropDown')[i].addEvent('change', this.ddChange.bindWithEvent(this));		}				for(var i=0; i < $$('a.homepageTab').length; i++){			 $$('a.homepageTab')[i].addEvent('click', this.homepageTabs.bindWithEvent(this,  $$('a.homepageTab')[i]));		}				for(var i=0; i < $$('img.zoomThis').length; i++){			new ZoomTool($$('img.zoomThis')[i]);		}				for(var i=0; i < $$('a.pickAward').length; i++){			new CS_PopUp($$('a.pickAward')[i], {				'classname' : 'awardSelection',				'width'		: 475,				'height'	: 300,				'fade' 		: true,				'drag'		: false,				'overlay'	: true			});		}				for(var i=0; i < $$('li.buyerRating').length; i++){			if(!$$('li.buyerRating')[i].getParent().hasClass('score') && !$$('li.buyerRating')[i].getParent().hasClass('withdrawn')){				new CS_Rating($$('li.buyerRating')[i], 'buyer');			}		}				for(var i=0; i < $$('li.crowdRating').length; i++){			if(!$$('li.buyerRating')[i].getParent().hasClass('withdrawn')){				new CS_Rating($$('li.crowdRating')[i], 'crowd');			}		}		if($('mainsearch').getFirst()){			$('mainsearch').getFirst().addEvent('focus', function(){				$('mainsearch').getFirst().setStyle('border-color', '#4f4f4f');				if(this.value == 'Search'){					this.value = '';				}			});			$('mainsearch').getFirst().addEvent('blur', function(){				$('mainsearch').getFirst().setStyle('border-color', '#3c3c3c');				if(this.value == ''){					this.value = 'Search';				}			});		} 				if($('ezcoa-12_user_account_login')){			//this.vaildUsername($('ezcoa-12_user_account_login'), document.Register);		}						for(var i=0; i < $$('input.clickClear').length; i++){			this.clickClear($$('input.clickClear')[i]);		}				for(var i=0; i < $$('textarea.clickClear').length; i++){			this.clickClear($$('textarea.clickClear')[i]);		}				if($('flashMessage')){			var hash = location.hash;			if(hash == '#0'){				$('flashMessage').setStyle('display', 'none');			} else {				$('flashMessage').setStyle('display', 'block');				this.flashMessage.delay(3000);			}		}				for(var i=0; i < $$('a.readMore').length; i++){			if($$('a.readMore')[i].href.contains('#0')){				$$('a.readMore')[i].addEvent('click', this.expandText.bindWithEvent(this));			} else if ($$('a.readMore')[i].href.contains('#1')){				$$('a.readMore')[i].addEvent('click', this.collapseText.bindWithEvent(this));			}		}				if($('newComment') && $('commentBox')){			this.commentBox();		}				if($('newUpdate') && $('updateBox')){			this.updateBox();		}				if($('helpTopics')){			this.helpLinkToggle();		}				for(var i=0; i < $$('a.toggleHandle').length; i++){			var handle = $$('a.toggleHandle')[i];			var drawer = $('toggleDrawer_' + handle.id.replace('toggleHandle_', ''));			this.toggleDrawer(handle, drawer);		}				if($('searchToggle')){			this.toggleDrawer($('searchToggle'), $('searchFilter'));			this.searchFilterBox();		}				if($('messageTextForward')){			var orgTxt = document.private_message_form.messageTextForward.value;			var orgFrom = document.private_message_form.orgFrom.value;			var orgSubject = document.private_message_form.orgSubject.value;			var orgDate = document.private_message_form.orgDate.value;			document.private_message_form.messageTextForward.value = "\n\n" + "On " + orgDate + " " + orgFrom + " wrote:" + "\n\n" + orgTxt;		}				if($('messageTextReply')){			var orgTxt = document.private_message_form.messageTextReply.value;			var orgFrom = document.private_message_form.orgFrom.value;			var orgSubject = document.private_message_form.orgSubject.value;			var orgDate = document.private_message_form.orgDate.value;			document.private_message_form.messageTextReply.value = "\n\n" + "On " + orgDate + " " + orgFrom + " wrote:" + "\n\n" + orgTxt;		}				for(var i=0; i < $$('a.popUpWatchlist').length; i++){			new CS_PopUp($$('a.popUpWatchlist')[i], {				'classname' : 'watchlistPopUp',				'width'		: 400,				'height'	: 150,				'fade' 		: true,				'drag'		: false,				'overlay'	: true			});		}				for(var i=0; i < $$('a.popUpContract').length; i++){			new CS_PopUp($$('a.popUpContract')[i], {				'classname' : 'contractPopUp',				'width'		: 670,				'height'	: 750,				'fade' 		: true,				'drag'		: false,				'overlay'	: true			});		}				for(var i=0; i < $$('a.popUpDelete').length; i++){			new CS_PopUp($$('a.popUpDelete')[i], {				'classname' : 'deletePopUp',				'width'		: 450,				'height'	: 225,				'fade' 		: true,				'drag'		: false,				'overlay'	: true			});		}				for(var i=0; i < $$('div.wrapupHidden').length; i++){			this.toggleWrapup($$('div.wrapupHidden')[i], $$('a.wrapupToggle')[i]);		}				for(var i=0; i < $$('div.sliderArea').length; i++){			this.sliderWrapup($$('div.sliderArea')[i], $$('div.sliderKnob')[i], $$('input.sliderValue')[i], $$('div.sliderAmount')[i], $$('div.amountDesc')[i], $$('input.sliderMoved')[i]);		}				if($('projectTitle')){			$('projectTitle').addEvent('keyup', this.characterCount.bindWithEvent(this, {'target' : $('projectTitle'), 'max' : 100, 'update' : $('titleCount')}));			$('projectTitle').addEvent('blur', this.characterCount.bindWithEvent(this, {'target' : $('projectTitle'), 'max' : 100, 'update' : $('titleCount')}));			this.characterCount(this, {'target' : $('projectTitle'), 'max' : 100, 'update' : $('titleCount')});		}				if($('projectDescription')){						$('projectDescription').addEvent('keyup', this.characterCount.bindWithEvent(this, {'target' : $('projectDescription'), 'max' : 5000, 'update' : $('descriptionCount')}));			$('projectDescription').addEvent('blur', this.characterCount.bindWithEvent(this, {'target' : $('projectDescription'), 'max' : 5000, 'update' : $('descriptionCount')}));			this.characterCount(this, {'target' : $('projectDescription'), 'max' : 5000, 'update' : $('descriptionCount')});					}				for(var i=0; i < $$('a.wrapupBuyerActions').length; i++){			$$('a.wrapupBuyerActions')[i].addEvent('click', function(e){				new Event(e).stop();				var split = this.href.split('#_')[1];				var type = split.split('_')[0];				var id = split.split('_')[1];								switch(type){					case 'accept':						$('wrapupActionSubmit_' + id).setText('Accept');						$('wrapupActionSubmit_' + id).name = 'accept';						$('wrapupActionSubmit_' + id).className = 'submit';						$('commentType_' + id).value = 'accept';					break;					case 'decline':						$('wrapupActionSubmit_' + id).setText('Decline');						$('wrapupActionSubmit_' + id).name = 'decline';						$('wrapupActionSubmit_' + id).className = 'negative';						$('commentType_' + id).value = 'decline';					break;					case 'question':						if($('fileUpload_' + id)){							$('fileUpload_' + id).setStyle('display', 'none');						}						$('wrapupActionSubmit_' + id).setText('Submit');						$('wrapupActionSubmit_' + id).name = 'question';						$('wrapupActionSubmit_' + id).className = 'standard';						$('commentType_' + id).value = 'comment';					break;					case 'file':						$('fileUpload_' + id).setStyle('display', 'block');						$('wrapupActionSubmit_' + id).setText('Send new file');						$('wrapupActionSubmit_' + id).name = 'file';						$('wrapupActionSubmit_' + id).className = 'submit';						$('commentType_' + id).value = 'file';					break;				}								var links = $('wrapupActions_' + id).getElementsByTagName('a');				for(var i=0; i < links.length; i++){					if(links[i].hasClass('wrapupBuyerActions')){						links[i].className = 'wrapupBuyerActions';						if(links[i] == this){							links[i].addClass('active');						}					}				}								new Fx.Style($('wrapupForm_' + id), 'height').start($('wrapupForm_' + id).getCoordinates().height, 210)							});		}				for(var i=0; i < $$('a.viewLarge').length; i++){			var id = $$('a.viewLarge')[i].id.replace('viewLarge_', '');			var size = id.split('_');			new CS_PopUp($$('a.viewLarge')[i], {				'classname' : 'viewLargePop',				'width'		: size[0].toInt() + 3,				'height'	: size[1].toInt() + 3,				'fade' 		: true,				'drag'		: false,				'overlay'	: true			});		}				if($$('h3.guaranteeTip')[0]){			new Tips($$('h3.guaranteeTip')[0], {				'maxTitleChars' : 200,				'className' : 'guarantee'			});		}				for(var i=0; i < $$('.verificationTip').length; i++){			new Tips($$('.verificationTip')[i], {				'maxTitleChars' : 200,				'className' : 'verification' 			});		}				for(var i=0; i < $$('.screen').length; i++){			this.screen($$('.screen')[i], .5);		}				/*for(var i=0; i < $$('a.editInline').length; i++){			$$('a.editInline')[i].addEvent('click', this.editInline.bindWithEvent(this));		}*/			},		screen: function(el, opacity){		el.setOpacity(opacity);		el.addEvent('mouseover', function(){			el.setOpacity(1);		});		el.addEvent('mouseleave', function(){			el.setOpacity(opacity);		}); 	},		vaildUsername: function(input, form){		var username = '';		var errors = false;		form.onsubmit = function(e){			new Event(e).stop();			username = input.value;			if(!username.test(/^[A-z0-9_]*$/)){				alert('Username must only contain letters and numbers.');				errors = true;			} else {				errors = false;			}				if(username.length > 20){				alert('Username must be less than 20 characters.');				errors = true;			} else {				errors = false;			}			if($('ezcoa-12_user_account_password').value != $('ezcoa-12_user_account_password_confirm').value || $('ezcoa-12_user_account_password').value == ''){				alert('Password\'s must match.');				errors = true;			} else {				errors = false;			}			if(errors == false){				this.submit();			} 		}	},		clickClear: function(el){		var fieldValue = el.value;		el.addEvent('focus', function(){			if(this.value == fieldValue){				this.value = '';			}		});		el.addEvent('blur', function(){			if(this.value == ''){				this.value = fieldValue;			}		});	},		setDesc: function(step){		var desc = '';		if(step >= 0 && step <= 20){			desc = 'Poor';		} else if(step >= 21 && step <= 40){			desc = 'Below Average';		} else if(step >= 41 && step <= 60){			desc = 'Average';		} else if(step >= 61 && step <= 80){			desc = 'Above Average';		} else if(step >= 81 && step <= 100){			desc = 'Excellent';		}		return desc;	},		sliderWrapup: function(area, knob, value, amount, desc, moved){		var _self = this;		new Slider(area, knob, {			'steps' : 100,			onChange: function(step){				value.value = step;				amount.setHTML(step);				desc.setHTML(_self.setDesc(step));			}		}).set(0);		knob.addEvent('click', function(){			if(moved.value != "true"){				moved.value = "true";			}		});		knob.addEvent('mouseover', function(){			if(moved.value != "true"){				moved.value = "true";			}		});		knob.addEvent('mouseleave', function(){			if(moved.value != "true"){				moved.value = "true";			}		});	},		toggleWrapup: function(container, handle){		var toggle = new Fx.Slide(container, {duration: 200});		toggle.toggle();		handle.addEvent('click', function(e){			new Event(e).stop();			toggle.toggle();			this.toggleClass('minus');		});	},		helpLinkToggle: function(){		var accordion = new Accordion('h3.helpLink', 'div.helpText', {			'opacity': false, 'start': true, 'duration': 100, 'alwaysHide' : true,			onActive: function(toggler, element){				toggler.setStyles({					'color' : '#ed2590',					'font-weight' : 'bold'				});				toggler.setStyle('background', '#efefef');			},			onBackground: function(toggler, element){				toggler.setStyles({					'color' : '#000',					'font-weight' : 'normal'				});				toggler.setStyle('background', 'none');			}		});	},		toggleDrawer: function(handle, drawer){		var toggle = new Fx.Slide(drawer, {duration: 200});		toggle.toggle();		handle.addEvent('click', function(e){			drawer.setStyle('display', 'block');			new Event(e).stop();			toggle.toggle();			handle.toggleClass('minus');		});	},		searchFilterBox: function(){		var links = $('massCheck').getChildren();		for(var i=0; i < links.length; i++){			if(links[i].getFirst().href.contains("#all")){				links[i].getFirst().addEvent('click', function(e){					new Event(e).stop();					for(var j=0; j < $('seachFilterForm').getElementsByTagName('input').length; j++){						if($('seachFilterForm').getElementsByTagName('input')[j].type == 'checkbox'){							$('seachFilterForm').getElementsByTagName('input')[j].checked = true;						}					}				})			} else if(links[i].getFirst().href.contains("#none")){				links[i].getFirst().addEvent('click', function(e){					new Event(e).stop();					for(var j=0; j < $('seachFilterForm').getElementsByTagName('input').length; j++){						if($('seachFilterForm').getElementsByTagName('input')[j].type == 'checkbox'){							$('seachFilterForm').getElementsByTagName('input')[j].checked = false;						}					}				})			}		}	},		commentBox: function(){		var toggle = new Fx.Slide($('commentBox'), {duration: 200});		toggle.toggle();		if(!$('newComment').hasClass('buyer')){			$('newComment').addEvent('click', function(e){				$('commentBox').setStyle('display', 'block');				new Event(e).stop();				toggle.toggle();			})			$('commentBox').addEvent('submit', function(e){				new Event(e).stop();				if($('commentBox').getFirst().value != ''){					$('commentBox').submit();				}			});		}	},		updateBox: function(){		var toggle = new Fx.Slide($('updateBox'), {duration: 200});		toggle.toggle();		$('newUpdate').addEvent('click', function(e){			$('updateBox').setStyle('display', 'block');			new Event(e).stop();			toggle.toggle();		})		$('updateBox').addEvent('submit', function(e){			new Event(e).stop();			if($('updateBox').getFirst().value != ''){				$('updateBox').submit();			}		});	},		flashMessage: function(){		location.hash = '#0';		new Fx.Styles($('flashMessage'), {duration: 500, transition: Fx.Transitions.linear}).start({			'opacity' : [1, 0]		});	},		homepageTabs: function(e, el){		new Event(e).stop();				var loading = new Element('div', {			'class' : 'loading'		}).setText('Loading...');				new Ajax(el.href, {			'update' : $('homepageContent'),			onRequest: function(){				$('homepageContent').empty();				loading.injectInside($('homepageContent'));			},			onFailure: function(){				location = '/';			},			onSuccess: function(){				for(var i=0; i < $$('a.homepageTab').length; i++){					if($$('a.homepageTab')[i] == el){						$$('a.homepageTab')[i].addClass('active');					} else {						$$('a.homepageTab')[i].removeClass('active');					}				}			}		}).request();	},		expandText: function(event){		var _self = this;		new Event(event).stop();		var params = event.target.href.split('#0_')[1];		var id = params.split('&')[0];		var classIdentifier = params.split('&')[1];		new Ajax('/submission/comment', {			'method' : 'post',			'data' : {				'node_id' : id,				'length' : 'full',				'class': classIdentifier			},			'update' : $('message_' + id),			onComplete: function(){					var a = new Element('a', {'class' : 'readMore', 'href' : '#1_' + id + '&' + classIdentifier}).setText('less');					a.addEvent('click', _self.collapseText.bindWithEvent(_self));					$('message_' + id).appendText(' (');					a.injectInside($('message_' + id));					$('message_' + id).appendText(')');			}		}).request();	},		collapseText: function(event){		var _self = this;		new Event(event).stop();		var params = event.target.href.split('#1_')[1];		var id = params.split('&')[0];		var classIdentifier = params.split('&')[1];				new Ajax('/submission/comment', {			'method' : 'post',			'data' : {				'node_id' : id,				'length' : 30,				'class' : classIdentifier			},			'update' : $('message_' + id),			onComplete: function(){					var a = new Element('a', {'class' : 'readMore', 'href' : '#0_' + id + '&' + classIdentifier}).setText('more');					a.addEvent('click', _self.expandText.bindWithEvent(_self));					$('message_' + id).appendText(' ...(');					a.injectInside($('message_' + id));					$('message_' + id).appendText(')');			}		}).request();	},		ddChange: function(e){		new Event(e).stop();		location = e.target.options[e.target.selectedIndex].value;	},		characterCount: function(e, options){		var count = options.target.value.length;		options.update.setText(options.target.value.length);		if(count > options.max){			options.update.addClass('error');		} else {			options.update.removeClass('error');		}	},		editInline: function(e){		var _self = this;				new Event(e).stop();		var save = new Element('a', {			'href' : '#',			'class' : 'inlineButtons'		}).setText('Save');		var cancel = new Element('a', {			'href' : '#',			'class' : 'inlineButtons'		}).setText('Cancel');		var input = new Element('input', {			'class' : 'inlineEdit'		});				cancel.addEvent('click', function(e){			new Event(e).stop();						cancel.remove();			save.remove();						var a = new Element('a', {				'href' : '#',				'class' : 'editInline'			}).setText(text);						a.addEvent('click', _self.editInline.bindWithEvent(_self));						input.replaceWith(a);		});				save.addEvent('click', function(e){			new Event(e).stop();						new Ajax(url, {				'method' : 'post',				'data' : {					'title' : input.value,					'id' : id				},				onSuccess: function(response){					cancel.remove();					save.remove();					var a = new Element('a', {						'id' : 'editInline_' + id,						'href' : url,						'class' : 'editInline'					}).setText(response);					a.addEvent('click', _self.editInline.bindWithEvent(_self));					input.replaceWith(a);				}			}).request(); 					});				var text = e.target.getText();		var url = e.target.href;		var id = e.target.id.replace('editInline_', '');		input.value = text;		e.target.replaceWith(input);		save.injectAfter(input);		cancel.injectAfter(save);	}	});var ProjectCreation = new Class({		initialize: function(){		if($('awardAdd')){			$('awardAdd').addEvent('click', this.addAward.bindWithEvent(this));		}		for(var i=0; i < $$('input.award').length; i++){			$$('input.award')[i].addEvent('keyup', this.inputAward.bindWithEvent(this));			$$('input.award')[i].addEvent('focus', this.amountIndicator.bindWithEvent(this));		}		for(var i=0; i < $$('a.deleteAward').length; i++){			$$('a.deleteAward')[i].addEvent('click', this.deleteAward.bindWithEvent(this));		}		this.totalAward();				for(var i=0; i < $$('input.file').length; i++){			$$('input.file')[i].addEvent('change', this.addFile.bindWithEvent(this));		}				this.calendar();		if($('otherFiles')){			$('otherFiles').addEvent('click', this.addOtherFiles.bindWithEvent(this));		}				for(var i=0; i < $$('input.projectContract').length; i++){			$$('input.projectContract')[i].addEvent('click', this.changeContract.bindWithEvent(this));		}		this.changeContract();				for(var i=0; i < $$('a.popUp').length; i++){			new CS_PopUp($$('a.popUp')[i], {				'classname' : 'contractPopUp',				'width'		: 670,				'height'	: 750,				'fade' 		: true,				'drag'		: false,				'overlay'	: true			});		}				for(var i=0; i < $$('dl.helpText').length; i++){			this.helpInfo($$('dl.helpText')[i]);		}				if($$('li.projectFileName').length >= 1){			$('projectFiles').setStyle('display', 'block');		} else {			if($('projectFiles')){				$('projectFiles').setStyle('display', 'none');			}		}				for(var i=0; i < $$('a.deleteFile').length; i++){				$$('a.deleteFile')[i].addEvent('click', this.deleteFile.bindWithEvent(this));		}				if($('otherFiles') && $('otherFiles').className == 'remove'){			$('otherFiles').addEvent('click', this.removeOtherFiles.bindWithEvent(this));		}				if($$('a.deleteContract')[0]){			$$('a.deleteContract')[0].addEvent('click', this.deleteContract.bindWithEvent(this));		}				var _self = this;		for(var i=0; i < $$('form.validate').length; i++){			$$('form.validate')[i].onsubmit = function(){				for(var j=0; j < $$('fieldset.validate').length; j++){					_self.validateField($$('fieldset.validate')[j], this);				}				return false;			}		}			},		amountIndicator: function(e){				if(e.target.tagName == 'INPUT' && e.target.value !=''){						var input = e.target;						input.addEvent('blur', function(){				if(bar.getParent()){					bar.remove();					input.setStyles({						'margin-bottom' : 0					});				}			});						if(!input.getNext()){				var bar = new Element('div', {					'class' : 'amountIndicatorBar'				}).injectAfter(input);			} else {				var bar = input.getNext();			}						input.setStyles({				'margin-bottom' : 30			});					var value = input.value.toInt();			var text;			var low = $$('.projectAwards')[0].id.split('_')[1].toInt();			var med;			var high;						switch(low){				case 150:					high = 600;					med = 300;				break;				case 250:					high = 750;					med = 500;				break;				case 300:					high = 1250;					med = 750;				break;			}						if(value >= 0 && value < low){				text = '';				bar.className = 'amountIndicatorBar';			} else if(value >= low && value < med) {				text = '';				bar.className = 'amountIndicatorBar good';			} else if(value >= med && value < high){				text = '';				bar.className = 'amountIndicatorBar better';			} else {				text = '';				bar.className = 'amountIndicatorBar best';			}						bar.setText(text);					}	},		addAward: function(e){		new Event(e).stop();				var awardCounts = $$('tr.awardCount');		var count = awardCounts.length;		var tr = new Element('tr', {			'class' : 'awardCount',			'id' : 'awardCount_' + (count + 1)		});		var td = new Element('td');		var input = new Element('input', {			'class' : 'text award',			'type' : 'type', 			'name' : 'projectAward[]'		});		var a = new Element('a', {			'class' : 'deleteAward',			'href' : '#_' + (count + 1)		}).setText('delete');				input.addEvent('keyup', this.inputAward.bindWithEvent(this));		input.addEvent('focus', this.amountIndicator.bindWithEvent(this));		a.addEvent('click', this.deleteAward.bindWithEvent(this));				td.clone().setText('Award ' + (count + 1)).injectInside(tr);		td.clone().setText('$').injectInside(tr);		var inputTd = td.clone();		inputTd.addClass('awardAmounts');		input.injectInside(inputTd);		inputTd.injectInside(tr);		var del = td.clone();		del.className = 'delete';		a.injectInside(del);		del.injectInside(tr);		tr.injectAfter($('awardCount_' + count));			},		inputAward: function(e){		var val = '';		var chars = e.target.value.split('');		for(var i=0; i < chars.length; i++){			if(chars[i] >= 0 && chars[i] <= 9){				val += chars[i];				e.target.value = val;				if(i == chars.length - 1){					val = val.toInt();					this.totalAward();					this.amountIndicator(e);				}			}		}		if(e.target.value == ''){			this.totalAward();			this.amountIndicator(e);		}	},		deleteAward: function(e){		new Event(e).stop();		$('awardCount_' + e.target.href.split('#_')[1]).remove();		for(var i=0; i < $$('tr.awardCount').length; i++){			$$('tr.awardCount')[i].id = 'awardCount_' + (i + 1);			$$('tr.awardCount')[i].getChildren()[3].getFirst().href = '#_' + (i + 1);		}		this.totalAward();	},		totalAward: function(){		var amounts = $$('input.award');		var total = 0;				for(var i=0; i<amounts.length; i++){			if(amounts[i].value != '' && amounts[i].value != '.'){				amounts[i].value = amounts[i].value.toInt().round();				total += amounts[i].value.toFloat();			}		}				var projectfee = total.toFloat() * .15;		total = total.toFloat() + projectfee.toFloat();		projectfee = projectfee.round(2);		total = total.round(2);				if(projectfee.toString().split('.').length > 1 && projectfee.toString().split('.')[1].length == 1){				projectfee += '0';		}				if(total.toString().split('.').length > 1 && total.toString().split('.')[1].length == 1){				total += '0';		}				if($('projectFee')){			$('projectFee').setText(projectfee);		}		if($('awardTotal')){			$('awardTotal').setText(total);		}	},		addFile: function(e){		new Event(e).stop();		for(var i=0; i < $$('input.file').length; i++){			$$('input.file')[i].setStyles({				'position' : 'absolute',				'left' : -9999			})		}		var input = new Element('input', {			'class' : 'file',			'type': 'file',			'name' : 'projectFile[]',			'id' : 'projectFile_' + ($$('input.file').length + 1)		});		var a = new Element('a', {			'class' : 'deleteFile',			'href' : '#_' + ($$('input.file').length)		}).setText('delete');				var filename = e.target.value.split('/');		filename = filename[filename.length - 1];		if(filename.length > 45){			filename = filename.substring(0, 20) + '...' + filename.substring(filename.length - 20);		}				var li = new Element('li', {			'class' : 'projectFileName',			'id' : 'projectFileName_' + ($$('input.file').length)		}).setText(filename);				a.addEvent('click', this.deleteFile.bindWithEvent(this));				input.addEvent('change', this.addFile.bindWithEvent(this));		input.injectBefore($('projectFiles'));		a.injectInside(li);		li.injectInside($('projectFiles'));						if($$('li.projectFileName').length >= 1){			$('projectFiles').setStyle('display', 'block');		} else {			$('projectFiles').setStyle('display', 'none');		}					},		deleteFile: function(e){		new Event(e).stop();		if(e.target.href.contains('deleteMe')){			new Ajax('/create/delete', {				'method' : 'post',				'data' : {					'object_id' : e.target.href.split('#deleteMe_')[1]				},				onComplete : function(){					e.target.getParent().remove();					if($$('li.projectFileName').length >= 1){						$('projectFiles').setStyle('display', 'block');					} else {						$('projectFiles').setStyle('display', 'none');					}				}			}).request();		} else {			$('projectFile_' + e.target.href.split('#_')[1]).remove();			$('projectFileName_' + e.target.href.split('#_')[1]).remove();						for(var i=0; i < $$('input.file').length; i++){				if($$('input.file')[i]) $$('input.file')[i].setProperty('id', 'projectFile_' + (i + 1));				if($$('li.projectFileName')[i]) $$('li.projectFileName')[i].setProperty('id', 'projectFileName_' + (i + 1));				if($$('a.deleteFile')[i]) $$('a.deleteFile')[i].setAttribute('href', '#_' + (i + 1));			}		}			if($$('li.projectFileName').length >= 1){			$('projectFiles').setStyle('display', 'block');		} else {			$('projectFiles').setStyle('display', 'none');		}					},		calendar: function(){		if($('projectDays')){			if($('projectDays').value == ''){				$('projectDays').value = 7;			}			this.updateCalendar();			$('calendarButton').addEvent('click', this.openCalendar.bindWithEvent(this));			$('projectDate').addEvent('focus', this.updateDay.bindWithEvent(this));			$('projectDays').addEvent('keyup', this.updateCalendar.bindWithEvent(this));		}	},		openCalendar: function(){		displayDatePicker('projectDate', false, 'mdy', '-');	},		updateCalendar: function(){		if($('projectDays').value != ''){			if($('projectDays').value.toInt() > 14){				$('projectDays').value = 14;			} else if($('projectDays').value.toInt() <= 0){				$('projectDays').value = 7;			}			var nowDate = new Date();			var endDate = new Date();			endDate.setDate(nowDate.getDate() + $('projectDays').value.toInt());			$('projectDate').value = (endDate.getMonth() + 1) + '-' + endDate.getDate() + '-' + endDate.getFullYear();					switch(endDate.getMonth() + 1){				case 1: month = 'Jan'; break;				case 2: month = 'Feb'; break;				case 3: month = 'Mar'; break;				case 4: month = 'Apr'; break;				case 5: month = 'May'; break;				case 6: month = 'Jun'; break;				case 7: month = 'Jul'; break;				case 8: month = 'Aug'; break;				case 9: month = 'Sep'; break;				case 10: month = 'Oct'; break;				case 11: month = 'Nov'; break;				case 12: month = 'Dec'; break;			}			var year = endDate.getFullYear().toString();			year =  year.substring(2);			$('friendlyDate').setText(endDate.getDate() + '-' + month + '-' + year);					} else {			$('friendlyDate').setText('');		}	},		updateDay: function(){		if($('projectDate').value != ''){			var date = $('projectDate').value.split('-');			var nowDate = new Date();			var endDate = new Date(date[2].toInt(), (date[0].toInt() - 1), date[1].toInt(), nowDate.getHours(), nowDate.getMinutes(), nowDate.getSeconds());			var diff = endDate - nowDate;			diff = Math.round(diff/1000/60/60/24);			$('projectDays').value = diff;			this.updateCalendar();		}	},		addOtherFiles: function(e){		new Event(e).stop();		var input = new Element('input', {			'type' : 'text',			'name' : 'projectFileTypeExtra',			'class' : 'text'		});		var a = new Element('a', {			'href' : '#',			'id' : 'otherFiles',			'class' : 'remove'		}).setText('Cancel');		var small = new Element('small').setText("Separate multiple file types with commas (,).");		a.addEvent('click', this.removeOtherFiles.bindWithEvent(this));		e.target.replaceWith(input);		small.injectInside($$('li.other')[0]);		a.injectInside($$('li.other')[0]);			$$('li.other')[0].setStyle('display', 'block');	},		removeOtherFiles: function(e){		new Event(e).stop();		var a = new Element('a', {			'href' : '#',			'id' : 'otherFiles'		}).setText('add my own');		a.addEvent('click', this.addOtherFiles.bindWithEvent(this));		$$('li.other')[0].empty();		a.injectInside($$('li.other')[0]);		$$('li.other')[0].setStyle('display', 'inline');			},		changeContract: function(){		for(var i=0; i < $$('input.projectContract').length; i++){			if($$('input.projectContract')[i].checked == true){				var contractType = $$('input.projectContract')[i].value;			}		}				switch(contractType){			case 'cs_contract':				$('csContract').removeClass('hidden');				$('myContract').addClass('hidden');			break;			case 'private_contract':				$('myContract').removeClass('hidden');				$('csContract').addClass('hidden');			break;			case 'no_contract':				$('myContract').addClass('hidden');				$('csContract').addClass('hidden');			break;		}					},		deleteContract: function(e){		new Event(e).stop();		$('customContract').removeClass('customContractFile');		var file = new Element('input', {			'type' : 'file',			'name' : 'customContract'		});		var a = new Element('a', {			'class' : 'deleteContract', 			'href' : '#delete'		}).setText('delete');		a.addEvent('click', this.deleteContract.bindWithEvent(this));		file.addEvent('change', function(){			var filename = $('customContract').getFirst().value.split('/');			filename = filename[filename.length - 1];			if(filename.length > 45){				filename = filename.substring(0, 20) + '...' + filename.substring(filename.length - 20);			}			$('customContract').getFirst().setStyles({				'position' : 'absolute',				'left' : -9999			});			$('customContract').appendText(filename);			a.injectInside($('customContract'));			$('customContract').addClass('customContractFile');		});				$('customContract').empty();		file.injectInside($('customContract'));	},		helpInfo: function(el){		el.getFirst().getFirst().addEvent('click', function(e){			new Event(e).stop();			for(var i=0; i < $$('dl.helpText').length; i++){				if(this.getParent().getParent() != $$('dl.helpText')[i]){					$$('dl.helpText')[i].getLast().setStyle('display', 'none');				}			}			if(this.getParent().getParent().getLast().getStyle('display') == 'none'){				this.getParent().getParent().getLast().setStyle('display', 'block');			} else {				this.getParent().getParent().getLast().setStyle('display', 'none');			}		});	},		validateField: function(el, form){		var getElement = function(parent, tagName, index){			if(!index) index = 0;			return parent.getElementsByTagName(tagName)[index];		}				var errors = function(el, type, form){			var errors = false;			switch(type){				case true:					el.addClass('error');				break;				default:					el.removeClass('error');			}			for(var i=0; i < $$('fieldset.validate').length; i++){				if(getElement($$('fieldset.validate')[i], 'LABEL').hasClass('error')){					errors = true;				}			}						if(errors == true){				$('displayErrors').setStyle('display', 'block');			} else {				form.submit();			}		}				var isEmpty = function(val){			if(val.length <= 0 || val == ''){				return true;			} else {				return false;			}		}				var checkCardLength = function(val, type){			if(type == 8){				if(val.length != 15){					return false;;				} else {					return true;				}			} else {				if(val.length != 16){					return false;				} else {					return true;				}			}		}				switch(el.id){						case 'cardName':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'cardNumber':				var input = getElement(el, 'INPUT');				if(isEmpty(input.value) || !checkCardLength(input.value, getElement($('cardType'), 'SELECT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'cardVerificationNumber':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'firstName':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'lastName':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;				case 'address':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'city':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'state':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'zip':				if(isEmpty(getElement(el, 'INPUT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;			case 'country':				if(isEmpty(getElement(el, 'SELECT').value)){					errors(getElement(el, 'LABEL'), true, form);				} else {					errors(getElement(el, 'LABEL'), false, form);				}			break;					}			}			});var CS_PopUp = new Class({		initialize: function(obj, options){		this.obj = obj;		this.setOptions(options);		this.obj.addEvent('click', this.open.bindWithEvent(this));	},		open: function(e){		new Event(e).stop();			this.popUp = new Element('div', {			'class' : this.options.classname		});		this.container = new Element('div', {			'class' : 'container'		})		this.close = new Element('div', {			'class' : 'close'		});		this.content = new Element('div', {			'class' : 'content'		});		this.loader = new Element('div', {			'class' : 'preloader'		});				if(this.options.closeText){			this.close.setText(this.options.closeText);		}				this.close.addEvent('click', this.closePop.bindWithEvent(this));				//this.container.setStyle('background', '#fff');				if(window.ie6){			this.iFrame = new Element('iframe', {				'styles' : {					'border' : 'none',					'opacity' : .01,					'position' : 'absolute',					'top' : 0,					'left' : 0,					'width' : '100%',					'height' : window.getScrollHeight()				}			});			this.updateiFrame.periodical(20, this);			this.iFrame.injectInside(document.body);		}				if(this.options.overlay == true){			this.overlay = new Element('div', {				'id' : 'popOverlay',				'styles' : {					'background' : '#000',					'opacity' : .75,					'position' : 'absolute',					'top' : 0,					'left' : 0,					'width' : '100%',					'height' : window.getScrollHeight()				}			});			this.updateOverlay.periodical(20, this);			this.overlay.addEvent('click', this.closePop.bindWithEvent(this));			this.overlay.injectInside(document.body);		}				this.close.injectInside(this.container);		this.content.injectInside(this.container);		this.loader.injectInside(this.container);		this.container.injectInside(this.popUp);		this.popUp.injectInside(document.body);				new PNGFix();				if(this.options.position){			this.left = e.target.getLeft() + this.options.position.x;			this.top =   e.target.getTop() + this.options.position.y;		} else {			this.left = (window.getWidth() - this.options.width) / 2;			this.top =  ((window.getHeight() - this.options.height) / 2) + window.getScrollTop();		}				this.popUp.setStyles({			'position' : 'absolute',			'top' : this.top,			'left' : this.left,			'width' : this.options.width,			'height' : this.options.height		});				this.loader.setStyles({			'position' : 'absolute',			'top' : (this.options.height - this.loader.getCoordinates().height) / 2,			'left' : (this.options.width - this.loader.getCoordinates().width) / 2		})				this.content.setStyle('opacity', 0);				if(this.options.drag == true){			this.container.makeDraggable();		}		this.preload();	},		preload: function(){				var _self = this;		new Ajax(this.obj.href, {			'update' : this.content,			onComplete: function(){				_self.loader.remove();				if(_self.options.fade == true) {					new Fx.Style(_self.content, 'opacity').start(0, 1);				} else {					_self.content.setStyle('opacity', 1);				}			}		}).request();	},		closePop: function(e){		new Event(e).stop();		var _self = this;		if(this.options.fade == true){			new Fx.Style(this.popUp, 'opacity', {				onComplete: function(){					_self.popUp.remove();					if(_self.overlay) _self.overlay.remove();					if(_self.iFrame) _self.iFrame.remove();				}			}).start(1, 0);		} else {			this.popUp.remove();			if(this.overlay) this.overlay.remove();			if(this.iFrame) this.iFrame.remove();		}	}, 		updateOverlay: function(){		this.overlay.setStyles({			'height' : window.getScrollHeight()		});	},		updateiFrame: function(){		this.iFrame.setStyles({			'height' : window.getScrollHeight()		});	}	});CS_PopUp.implement(new Options);var PNGFix = new Class({		initialize: function(){		if(window.ie6){			var el = $$('*');			for(var i=0; i < el.length; i++){				var imgURL = el[i].getStyle('background-image');			 	if (imgURL.contains('.png')){			 		el[i].setStyles({			 			'background': '',			 			'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale', src=" + imgURL.match(/\((.+)\)/)[1] + ")"			 		});			 	};			}		}	}	});var ZoomTool = new Class({		initialize: function(img){		var _self = this;		this.isLoaded = false;		this.isLocked = false;		this.img = img;		this.imgLarge = '/submission/zoom/' + img.id.replace('zoom_', '') + '/zoom';		this.zoomIcon = new Element('div', {			'class' : 'zoomIcon',			'styles' : {				'opacity' : .60,				'display' : 'none'			}		}).setText('zoom');				this.zoomIcon.addEvents({			'mouseover' : this.overHandler.bindWithEvent(this),			'mouseleave' : this.leaveHandler.bindWithEvent(this),			'click' : this.clickHandler.bindWithEvent(this)		});				this.zoomIcon.injectAfter(this.img.getParent());				this.img.addEvents({			mouseover : function(e){					_self.zoomIcon.setStyle('display', 'block');					clearInterval(this.hideDelay);			},			mouseleave : function(){				if(_self.isLocked == false){					_self.hideDelay = _self.hideTab.delay(100, _self);				}			}		});	},		hideTab: function(){		this.zoomIcon.setStyle('display', 'none');		clearInterval(this.hideDelay);	},		overHandler: function(){		clearInterval(this.hideDelay);		this.zoomIcon.setStyle('display', 'block');		if(this.isLocked == false){			this.delay = this.start.delay(300, this);		}	},		leaveHandler: function(){		clearInterval(this.delay);		if(this.zoomContainer && this.isLocked == false){			this.close();		}	},		clickHandler: function(){		this.zoomContainer.makeDraggable();		//this.zoomIcon.setStyle('background-position', '0 -14px');		this.zoomIcon.setText('close');		if(this.isLocked == true){			this.close();		} else {			this.isLocked = true;			}	},		start: function(){		if(!this.zoomContainer){			this.zoomContainer = new Element('div', {				'class' : 'zoomContainer',				'styles' : {					'display' : 'none'				} 			});			this.containerTop = new Element('div', {				'class' : 'top'			});			this.containerRight = new Element('div', {				'class' : 'right'			});			this.containerBottom = new Element('div', {				'class' : 'bottom'			});			this.containerLeft = new Element('div', {				'class' : 'left'			});			this.div = new Element('div');			this.closeButton = new Element('div', {				'class' : 'zoomClose'			}).setText('');			this.closeButton.addEvent('click', this.close.bindWithEvent(this));			this.zoomContainer.addEvents({				'click' : this.adjustDepth.bindWithEvent(this)			});			/*var info = eval(this.img.alt);					this.moreInfo = new Element('div', {				'class' : 'zoomInfo',				'styles' : {					'opacity' : 0				}			}).setHTML('<h3>' + info[0] + '</h3><h4>by <a href="../../../../crowdspring/design/crowdspring/javascript/' + this.img.getParent().getParent().getNext().getChildren()[0].href + '">' + info[1] + '</a></h4>');									this.moreInfoButton = new Element('div', {				'class' : 'zoomInfoButton'			}).setHTML('<div></div>');			var _self = this;						this.moreInfoButton.addEvent('click', function(){				if(_self.moreInfo.getStyle('opacity') == 0){					_self.showMoreInfo();				} else {					_self.hideMoreInfo();				}			});						this.moreInfoButton.addEvent('mouseover', function(){				this.setStyle('visibility', 'visible');			}); */					this.div.clone().injectInside(this.containerTop)			this.div.clone().injectInside(this.containerRight);			this.div.clone().injectInside(this.containerBottom);			this.div.clone().injectInside(this.containerLeft);			this.containerTop.injectInside(this.zoomContainer);			this.containerRight.injectInside(this.zoomContainer);			this.containerBottom.injectInside(this.zoomContainer);			this.containerLeft.injectInside(this.zoomContainer);			this.closeButton.injectInside(this.zoomContainer);			//this.moreInfo.injectInside(this.zoomContainer);			//this.moreInfoButton.injectInside(this.zoomContainer);			this.zoomContainer.injectInside(document.body);						new PNGFix();		}								if(this.isLoaded == true){			this.display();		} else {			this.load();		} 					},		load: function(){		var _self = this;	/*	this.image = new Asset.image(this.imgLarge, {			onload: function(){				_self.isLoaded = true;				_self.height = this.height;				_self.width = this.width;				_self.display();			}		}); */				this.image = new Element('div');				new Ajax(this.imgLarge, {			onComplete: function(){				_self.isLoaded = true;				_self.height = _self.image.getFirst().height;				_self.width = _self.image.getFirst().width;				_self.display();			},			'update' : this.image		}).request();				//this.zoomIcon.setStyle('background-position', '0 -43px');		this.zoomIcon.setText('loading');		/*this.image.addEvents({			'mouseover' : this.containerOver.bindWithEvent(this),			'mouseleave' : this.containerLeave.bindWithEvent(this)		});*/		this.image.injectInside(this.zoomContainer);			},		display: function(){		//this.zoomIcon.setStyle('background-position', '0 -28px');		this.zoomIcon.setText('click to lock');		var zoomCoords = this.zoomIcon.getCoordinates();		var top = zoomCoords.top - this.height + 40;		var left = zoomCoords.left - this.width - 20;				if(top <= window.getScrollTop()){			top = zoomCoords.top + zoomCoords.height - 40;		}				if(left <= 0){			left = zoomCoords.left + zoomCoords.width + 40;		}				this.zoomContainer.setStyles({			'display' : 'block',			'top' : top,			'left' : left,			'display' : 'block'		});				if(window.ie6){			$$('div.right')[0].remove();			$$('div.left')[0].remove();			$$('div.bottom')[0].remove();			$$('div.top')[0].remove();			this.zoomContainer.setStyles({				'width' : this.width,				'height' : this.height,				'border' : '5px solid #161616'			});			this.zoomContainer.getElementsByTagName('img')[0].setStyles({				'z-index' : -1,				'top' : 0			});		}		this.adjustDepth();	},		close: function(){		this.isLocked = false;		//this.zoomIcon.setStyle('background-position', '0 0');		this.zoomIcon.setText('zoom');		this.zoomContainer.setStyle('display', 'none');	},		adjustDepth: function(){		for(var i=0; i < $$('div.zoomContainer').length; i++){			$$('div.zoomContainer')[i].setStyle('z-index', 0);		}		this.zoomContainer.setStyle('z-index', 1);	},		containerOver: function(){		this.moreInfoButton.setStyle('visibility', 'visible');	},		containerLeave: function(){		this.moreInfoButton.setStyle('visibility', 'hidden');		this.moreInfo.setStyle('opacity', 0);		this.moreInfo.setStyle('visibility', 'hidden');	},		showMoreInfo: function(){		new Fx.Style(this.moreInfo, 'opacity', {'duration' : 300}).start(this.moreInfo.getStyle('opacity'), 1);	}, 		hideMoreInfo: function(){		this.moreInfo.setStyle('opacity', 0);		this.moreInfo.setStyle('visibility', 'hidden');	}	});var CS_Rating = new Class({		initialize: function(el, type){		this.el = el;		this.type = type;		this.parent = this.el.getParent();		var split = this.parent.id.split('_');		this.projectId = split[1]		this.submissionId = split[2];		this.status = split[3];		this.comment = null;				if(this.el.getParent().hasClass('submission')){			this.image = this.el.getParent().getParent().getFirst().getFirst().getFirst().src.replace('_submissionlarge', '_gridview');		} else {			this.image = this.el.getParent().getParent().getParent().getFirst().getFirst().getFirst().src;		}				if(this.status == 1 && this.type == 'crowd'){			this.el.setStyle('cursor', 'default');		} else if(this.status == 2 && this.type == 'buyer'){			this.el.setStyle('cursor', 'default');		} else if(this.status == 3) {			this.el.setStyle('cursor', 'default');		} else {			this.el.addEvent('click', this.start.bindWithEvent(this));		}				if(this.type == 'buyer' && $('newComment') && $('newComment').hasClass('buyer')){			$('newComment').addEvent('click', this.start.bindWithEvent(this));		}	},	updateOverlay: function(){		this.overlay.setStyles({			'height' : window.getScrollHeight()		});	},	start: function(e){		new Event(e).stop();		this.overlay = new Element('div', {			'styles' : {				'background' : '#000',				'opacity' : .75,				'position' : 'absolute',				'top' : 0,				'left' : 0,				'width' : '100%',				'height' : window.getScrollHeight()			}		});		this.updateOverlay.periodical(20, this);				if(this.type != 'buyer'){			this.overlay.addEvent('click', this.close.bindWithEvent(this));		}				this.wrapper = new Element('div',{			'styles' : {				'background' : '#000',				'opacity' : .5,				'padding' : 5			}		});				this.rating = new Element('div', {			'class' : this.type + 'Stars'		});				if(this.status != 3){			if(this.status == 1 && this.type == 'buyer' || this.status == 2 && this.type == 'crowd'){								var column = new Element('div', {					'class' : 'clearfix'				}).injectInside(this.rating);				var ul = new Element('ul').injectInside(column);				if(this.type == 'crowd'){					var p = new Element('p').setText('Your score only counts once, but you can change it as often as you like.');					p.injectInside(column);				}				for(var i=1; i < 6; i++){					var _self = this;					var currentStar = new Element('li').injectInside(ul).setText(i);					currentStar.addEvent('mouseover', function(){						_self.change(this.getText().toInt());					});					currentStar.addEvent('click', function(){						if(_self.type == 'crowd'){							_self.save(this.getText().toInt());						} else {							_self.set(this.getText().toInt());						}					})				}								new Element('h3').setText('Score:').injectTop(column);				if(this.type == 'buyer'){					new Element('h3').setText('Comment:').injectInside(column);					this.comment = new Element('textarea').injectInside(column);					new Element('a', {						'class' : 'cancel'					}).setText('Cancel').addEvent('click', this.close.bindWithEvent(this)).injectInside(column);									new Element('a', {						'class' : 'submit'					}).setText('Submit').addEvent('click', function(){						_self.save($('scoreValue').value);					}).injectInside(column);								}								new Element('img', {					'src' : this.image,					'styles' : {						'width' : 75,						'height' : 75					}				}).injectTop(this.rating);			} else {				this.message = new Element('div', {					'class' : 'message'				});				this.message.setHTML('Sorry, you must be <a href="/login">signed in</a> to score this entry.');				this.message.injectInside(this.rating);							}						this.overlay.injectInside(document.body);			this.wrapper.injectInside(document.body);			this.rating.injectInside(document.body);						if(this.type == 'buyer'){				this.width = 325;				this.height = 260;			} else {				this.width = 325;				this.height = 95;			}						this.left = (window.getWidth() - this.width) / 2;			this.top =  ((window.getHeight() - this.height) / 2) + window.getScrollTop();			this.wrapper.setStyles({				'visibility' : 'visible',				'position' : 'absolute',				'top' : this.top - 5,				'left' : this.left - 5,				'width' : this.width,				'height' : this.height			});						this.rating.setStyles({				'visibility' : 'visible',				'position' : 'absolute',				'top' : this.top,				'left' : this.left,				'width' : this.width,				'height' : this.height			});			if(this.el.getText().toInt() > 0 && this.type == 'buyer'){				this.change(this.el.getText().toInt());			}						this.hiddenValue = new Element('input', {				'type' : 'hidden',				'id' : 'scoreValue'			});			this.hiddenValue.injectInside(this.rating);		}	}, 		change: function(amount){		if(this.type == 'buyer'){			switch(amount){				case 1: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -71px'); break;				case 2: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -53px'); break;				case 3: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -35px'); break;				case 4: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -17px'); break;				case 5: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 1px'); break;			}		} else if(this.type == 'crowd'){			switch(amount){				case 1: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -180px'); break;				case 2: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -162px'); break;				case 3: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -144px'); break;				case 4: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -126px'); break;				case 5: this.rating.getFirst().getNext().getFirst().getNext().setStyle('background-position', '0 -108px'); break;			}		}	},		save: function(amount){		var comment = '';		if(this.comment != null && this.type == 'buyer'){			comment = this.comment.value;		}				var _self = this;		this.ajaxSubmit = new Ajax('/submission/rate', {			'method' : 'post',			'data' : {				'type' : this.type,				'amount' : amount,				'submission_id' : this.submissionId,				'project_id' : this.projectId,				'comment' : comment			},			evalResponse : true,			onSuccess: function(response){				_self.rating.removeClass('loader');				if(response == 'false'){					_self.error();				} else {					if(response != 'true'){						_self.update(response.trim());					}					_self.success();				}			},			onFailure: function(){				_self.error();			}		}).request(); 				this.rating.empty();		this.rating.addClass('loader');	},		set: function(amount){		$('scoreValue').value = amount;	},		update: function(amount){		this.el.setText(amount);		this.el.className = this.type + "Rating " + this.type + "_" + amount;	},		error: function(){		this.message = new Element('div', {			'class' : 'message'		});				if(this.rating.getFirst()) var img = this.rating.getFirst();		if(this.rating.getFirst().getNext()) var div = this.rating.getFirst().getNext();		img.remove();		div.remove()				this.message.setHTML('Opps, sorry there was a error. Please try again.');		this.message.injectInside(this.rating);				this.close.delay(2000, this);	},		success: function(){			this.message = new Element('div', {				'class' : 'message'			});			if(this.type == 'crowd'){				this.message.setHTML('Thanks! Your score has been counted.');			} else {				this.message.setHTML('Thanks!');			}			this.message.injectInside(this.rating);			if(this.rating.getFirst()) var img = this.rating.getFirst();			if(this.rating.getFirst().getNext()) var div = this.rating.getFirst().getNext();			if(this.type == 'buyer' && this.parent.hasClass('submission') && this.comment.value.trim() != ''){				location.href = location.href;			}						this.close.delay(2000, this);		},		close: function(){		if(this.wrapper) this.wrapper.remove();		if(this.overlay) this.overlay.remove();		if(this.rating) this.rating.remove();		if(this.message) this.message.remove();	}	});var CS_Slider = new Class({	initialize: function(container, submissionId, projectId, offset){				this.direction = null;		this.submissionId = submissionId;		this.projectId = projectId;		this.amount = 9;		this.container = container;		this.offset = offset;				this.loading = new Element('div', {			'class' : 'loading',			'styles' : {				'opacity' : .5			}		}).setText('Loading...');				this.loadThumbs();		this.createControls();		this.loading.injectInside(this.container);	},		loadThumbs: function(){				_self = this;				var ul = new Element('ul', {			'class' : 'thumbs', 			'styles' : {				'visibility' : 'hidden'			}			});				if($$('li.next')[0]){			ul.injectBefore($$('li.next')[0]);		} else {			ul.injectInside(this.container);		}				new Ajax('/submission/slider/' +this.projectId + '/' + this.submissionId + '/' + this.offset, {			'method' : 'post',			'update' : $$('ul.thumbs')[$$('ul.thumbs').length - 1],			onRequest: function(){				_self.loading.setStyle('display', 'block');			},			onComplete : function(){								_self.loading.setStyle('display', 'none');								var show = function(){					$$('ul.thumbs')[$$('ul.thumbs').length - 1].setStyle('visibility', 'visible');				}								show.delay(100);								var slide = new Fx.Style(_self.container.getChildren()[1].getFirst(), 'left', {					onComplete: function(){						_self.container.getChildren()[1].remove();					}				});				var slide2 = new Fx.Style(_self.container.getChildren()[2].getFirst(), 'left');								switch(_self.direction){										case 'next':						slide.start(0 , -(75 * _self.amount));						slide2.start((75 * _self.amount), 0);					break;										case 'previous':						slide.start(0, +(75 * _self.amount));						slide2.start(-(75 * _self.amount), 0);					break;									}							}		}).request();			},		createControls: function(){				if(!this.nextControl){			_self = this;			this.nextControl = new Element('li', {				'class' : 'next'			});			this.nextControl.addEvent('click', function(){								if($$('ul.thumbs')[0].getLast().getFirst().getLast().getFirst().tagName != 'SPAN' ||					$$('ul.thumbs')[0].getLast().getFirst().getLast().getFirst().tagName == 'SPAN' &&					$$('ul.thumbs')[0].getLast().getFirst().getFirst().getFirst().tagName == 'SPAN'){					_self.direction = 'next';					if(_self.offset != ''){						_self.offset = _self.offset.toInt() + _self.amount.toInt();					} else {						_self.offset = + _self.amount.toInt();						}					_self.loadThumbs();				}						});			this.nextControl.injectInside(this.container);		}		if(!this.previousControl){			this.previousControl = new Element('li', {				'class' : 'previous'			});			this.previousControl.addEvent('click', function(){							if($$('ul.thumbs')[0].getLast().getFirst().getFirst().getFirst().tagName != 'SPAN' ||					$$('ul.thumbs')[0].getLast().getFirst().getLast().getFirst().tagName == 'SPAN' &&					$$('ul.thumbs')[0].getLast().getFirst().getFirst().getFirst().tagName == 'SPAN'){					_self.direction = 'previous';					if(_self.offset != ''){						_self.offset = _self.offset.toInt() - _self.amount.toInt();					} else {						_self.offset = - _self.amount.toInt();						}					_self.loadThumbs();				}						});			this.previousControl.injectTop(this.container);		}			}});// Start Up window.addEvent('domready', function(){	var crowdspring = new CS();	if($$('ul.slider')[0]){		var slider = new CS_Slider($$('ul.slider')[0], $$('ul.slider')[0].id.split('_')[2], $$('ul.slider')[0].id.split('_')[1], 0);	}	if ($$('table.sortable')){		if ($('projectsTable1')) {			var projectsTable1 = new sortableTable('projectsTable1');		}		if ($('projectsTable2')) {			var projectsTable2 = new sortableTable('projectsTable2');		}		if ($('projectsTable3')) {			var projectsTable3 = new sortableTable('projectsTable3');		}	}});
