/*This code is used based on mooTools library*/

window.addEvent('domready', function(){


/*Rendering the rounded corners using Nifty code*/

if(!NiftyCheck()) return;



//script for the smooth edges (element that needs to have smooth edges, position, inner color, out color, type)

Rounded("div.topCornerR","top","#FCF4F5","#fff","border #cccccc");

Rounded("div.smallBox_L","all","transparent","#fff","big border #cccccc");

Rounded("div.smallBox_R","all","transparent","#fff","big border #cccccc");

Rounded("div#bottomEdgeQ","bottom","#FCF4F5","#fff","border  #cccccc");

Rounded("div.generalUP","tr","transparent","#fff","big border #cccccc");

Rounded("div.generalDOWN","bottom","transparent","#fff","big border #cccccc");

Rounded("div#researchShow","tr bl br","#FCF4F5","#fff","big border #cccccc");

Rounded("div.GreyHeader","top","#FCF4F5","#cc0000","big  border #cccccc");

Rounded("div.top_log","top","#FCF4F5","#fff","big border #cccccc");

Rounded("div.bottom_log","bottom","#FCF4F5","#fff","big border #cccccc");

Rounded("div#topCornerQ","tl tr","transparent","#cc0000","border #cccccc");

Rounded("div#bottomCornerQ","bottom","#FCF4F5","#fff","border  #cccccc");

Rounded("div#bottomCornerR","bl br","#FCF4F5","#fff","border  #cccccc");

Rounded("div.topL","tl tr","#FCF4F5","#fff","border #cccccc");

Rounded("div.bottomL","bottom","#FCF4F5","#cccccc","big");

Rounded("div.topT","tl tr","#FCF4F5","#fff","border #cccccc");

Rounded("div.bottomT","bottom","#FCF4F5","#cccccc","border #cccccc");

/*Call other initialising functions*/




});		




/*Classes*/





/*Functions*/


/*New hidebox function, it will thake as input an element and split the element value in order to find out which action will have to be taken:
This is the format  ex: _Y_H_PERSONALBIG_Y_S_MOBILE
_Y_ is the delimiter, H_ is used to hide an element, S_ to show another.
In this example if this value is selected the element PERSONALBIG will be hidden and MOBILE will be shown. No need to touch this file anymore.
NOTE: if you want to hide an element outhomatically, that use javascript to do so.

*/		
function hideBox(element){
		var elementID=$(element).get('id');
		var val=element.get('value');
		
		var elements = val.split('_Y_'); 
		
		$each(elements, function(value, index){
       
       
		
		if(value.test("S_"))
		{
			
		var	elementToHide=value.split("S_")[1]+"_T";
			
			//if is hidden
			$(elementToHide).setStyle('display','block');
			
		}
		
		if(value.test("H_")){
		var	elementToHide=value.split("H_")[1];
		
		clearField(elementToHide);
		elementToHide=elementToHide+"_T";
	   $(elementToHide).setStyle('display','none');
		}
		}); 
     }		
function hideBox_init(element,eltohide){
	
		
		if(element.value==''){
		eltohide.setStyle('display','none');
		}else{hideBox(element);}
	

     }		
	/*This function will clear any kind of form emlement, once passed the id name of the element, it will switch to the right method*/	
     function clearField(elid)
	 {
	 	
	     var field_type = $(elid).type.toLowerCase();

		switch(field_type) {

		case "text":
		case "password":
		case "textarea":
		case "hidden":

		$(elid).value = "";
		break;

		case "radio":
		case "checkbox":

		if ($(elid).checked) {

		$(elid).checked = false;

		}
		break;

		case "select-one":
		case "select-multi":

		$(elid).selectedIndex = 0;
		break;

		default:
		break;

		}
	 }
/*This function take as attribute a class, and 2 colors and create an highlight effect on the background of all the elements with the same class.*/
function linkHl(myClass,firstColor,secondColor){
	$$(myClass).each(function(item){
									item.addEvent('mouseenter',function(){item.highlight(firstColor, secondColor)});
							        });
						   
						   
	}
	
/**************************************************************

	Script		: Page Loader
	Version		: 1.0
	Authors		: Samuel Birch
	Desc		: load pages via AJAX.
	Licence		: Open Source MIT Licence

**************************************************************/

var pageLoader = new Class({
							  
	getOptions: function(){
		return {
			links: '.loadMe',
			loadInTo: 'content',
			loadFrom: 'content',
			onStart: Class.empty,
			onComplete: Class.empty
		};
	},

	initialize: function(options){
	
		this.setOptions(this.getOptions(), options);
		
		this.links = $$(this.options.links);
		this.links.each(function(el,i){
			el.addEvent('click',function(e){
				if(e != undefined){
					new Event(e).stop();
				}
				this.start(el);
			}.bind(this));
		}.bind(this));
	},
	
	setContent: function(){
		var temp = new Element('div').setProperties({id:'temp'}).setStyles({display:'none'}).inject(document.body);
		temp.set('html',this.content.response.text);
		var newEl = $('temp').getElementById(this.options.loadFrom);
		$(this.options.loadInTo).adopt(newEl);
		//newEl.setProperties({id:this.options.loadInTo});
		temp.remove();
	},
	
	start: function(el){
		//this.options.onStart();
		this.content = new Request.HTML({
								url: el.href,
								onSuccess: this.complete.bind(this)
							}).send();
	},
	
	complete: function(){
		this.setContent();
		//this.options.onComplete();
	}

});
pageLoader.implement(new Events);
pageLoader.implement(new Options);


/*************************************************************/


function InitializeLayout(){

 



/*Scroller footer */

var opt = {

  duration: 1000,

  direction:'h',

  delay: 3000,

  buttons:{next:'footerNext',prev:'footerPrevious'},

  auto:true,

  transition: Fx.Transitions.Back.easeInOut,

  onMouseEnter: function(){this.stop();},

  onMouseLeave: function(){this.play();}

}

 

 

 

var scroller1 = new QScroller('footerScroller',opt);

scroller1.load();

 



var arrows = new Asset.images(['/view/images/1003695/ArrowLeft_02.gif','/view/images/1003695/ArrowRigth_02.gif','/view/images/1003695/ArrowLeft_01.gif','/view/images/1003695/ArrowRigth_01.gif']);

 

 

 

$(opt.buttons.prev).addEvent('mousedown', function(){

               

    

    this.setProperty('src',arrows[0].src);

});

 

$(opt.buttons.next).addEvent('mousedown', function(){

   this.setProperty('src',arrows[1].src);

});

 

$(opt.buttons.prev).addEvent('mouseup', function(){

   this.setProperty('src',arrows[2].src);

});

 

$(opt.buttons.next).addEvent('mouseup', function(){

    this.setProperty('src',arrows[3].src);

});

 

 

 

}


function Validate(theForm){



	if (theForm.username.value == ''){



		alert("Please enter a valid user name.");



		theForm.username.focus();



		return false;



	}//end if



	if (theForm.userPassword.value == ''){



		alert("Please enter a valid password.");



		theForm.userPassword.focus();



		return (false);



	}//end if







	return true;



}//end function







function Submit(theForm){



	if(Validate(theForm)){



		document.formLogin.submit();



	}//end if



}//en dfunction


