if(top.location != location){
top.location.href = document.location.href ;
}


function ascundeSelect1(){
	document.getElementById("myselect1").style.visibility = "hidden";
	document.getElementById("myselect1").display = "none";
}
function arataSelect1(){
	document.getElementById("myselect1").style.visibility = "visible";
	document.getElementById("myselect1").display = "block";
}

function ascundeSelect2(){
	document.getElementById("myselect2").style.visibility = "hidden";
	document.getElementById("myselect2").display = "none";
}
function arataSelect2(){
	document.getElementById("myselect2").style.visibility = "visible";
	document.getElementById("myselect2").display = "block";
}


function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}


function floatme(){
var ScrollTop = document.body.scrollTop;
if (ScrollTop == 0)
{
    if (window.pageYOffset)
        ScrollTop = window.pageYOffset;
    else
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
}
if(ScrollTop<310){
document.getElementById("floatdiv").style.visibility = "hidden";
document.getElementById("floatdiv").style.display = "none";
document.getElementById("floatdiv").style.position = "fixed";
document.getElementById("floatdiv").style.top = "0px";		
}else{
document.getElementById("floatdiv").style.visibility = "visible";
document.getElementById("floatdiv").style.display = "block";
document.getElementById("floatdiv").style.position = "fixed";
document.getElementById("floatdiv").style.top = "-216px";
}
}
setInterval("floatme()", 0);


function getCookie(c_name){
if (document.cookie.length>0){
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1){
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function toggle(x) {
	var ele = document.getElementById("toggleText"+x);
	var text = document.getElementById("displayText"+x);
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = "<span class='lightblue'>show details</span>";
  	}else{
		ele.style.display = "block";
		text.innerHTML = "<span class='lightblue'>hide details</span>";
	}
} 


function toggleall() {
var showallx = document.getElementById("showall");
for (i=1;i<=100;i++){
var eleg = document.getElementById("toggleText"+i);
var textg = document.getElementById("displayText"+i);
	if(eleg.style.display == "block") {
    	eleg.style.display = "none";
		showallx.innerHTML = "<img src='images/show_all.gif' border='0' />";
		setCookie('showcookie','',365);
  	}else{
		eleg.style.display = "block";
		showallx.innerHTML = "<img src='images/results_r2_c10.jpg' border='0' />";
		setCookie('showcookie','yes',365);
	}
} 
}


function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}


$(document).ready(function() {
	$("#registers").validate({
  rules: {
    d3: { equalTo: "#d4" },
    d5: { equalTo: "#d6" }
          } });
	$("#registers2").validate({
  rules: {
          } });
	$("#registers3").validate({
  rules: {
    d3: { equalTo: "#d2" },
    d5: { equalTo: "#d4" }
          } });
	$("#registers4").validate({
  rules: {
          } });
	$("#registerb").validate({
  rules: {

          } });
	$("#registerf").validate({
  rules: {

          } });
});



function MultiSelector( list_target, max ){
	this.list_target = list_target;
	this.count = 0;
	this.id = 0;
	if( max ){
		this.max = max;
	} else {
		this.max = -1;
	};
	this.addElement = function( element ){
		if( element.tagName == 'INPUT' && element.type == 'file' ){
			element.name = 'uploadedfile_' + this.id++;
			element.multi_selector = this;
			element.onchange = function(){
				var new_element = document.createElement( 'input' );
				new_element.type = 'file';
				this.parentNode.insertBefore( new_element, this );
				this.multi_selector.addElement( new_element );
				this.multi_selector.addListRow( this );
				this.style.position = 'absolute';
				this.style.left = '-1000px';

			};
			if( this.max != -1 && this.count >= this.max ){
				element.disabled = true;
			};
			this.count++;
			this.current_element = element;
			
		} else {
			alert( 'Error: not a file input element' );
		};

	};
	this.addListRow = function( element ){
		var new_row = document.createElement( 'div' );
		var new_row_button = document.createElement( 'input' );
		new_row_button.type = 'image';
		new_row_button.src = 'images/delete.png';
		new_row.element = element;
		new_row_button.onclick= function(){
			this.parentNode.element.parentNode.removeChild( this.parentNode.element );
			this.parentNode.parentNode.removeChild( this.parentNode );
			this.parentNode.element.multi_selector.count--;
			this.parentNode.element.multi_selector.current_element.disabled = false;
			return false;
		};
		new_row.innerHTML = element.value;
		new_row.appendChild( new_row_button );
		this.list_target.appendChild( new_row );
		
	};

};


function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}

function resizeFrame(f) {
  f.style.height = f.contentWindow.document.body.scrollHeight + "px";
}


/* incepe showChenar */
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(dud) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
dud.style.left = (((cX)/2)-80) + "px";
dud.style.top = (cY+30) + "px";
}
function AssignPositionM(dud) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
dud.style.marginLeft = "124px";
dud.style.top = (rY+90) + "px";
}
function HideChenar(dud) {
if(dud.length < 1) { return; }
document.getElementById(dud).style.display = "none";
}
function ShowChenar(dud) {
if(dud.length < 1) { return; }
var ddud = document.getElementById(dud);
AssignPosition(ddud);
ddud.style.display = "block";
}
/* se termina showChenar */



function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
document.getElementById(d).style.top = "-1000px";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPositionM(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
if(dd.style.display == "none") { 
dd.style.display = "block"; 
dd.style.position = "absolute";
} else { 
dd.style.display = "none"; 
dd.style.top = "-1000px";
}
}




