var mins
var secs;

function cd() {
 	mins = 1 * m("7"); // change minutes here
 	secs = 0 + s(":01"); // change seconds here (always add an additional second to your total)
 	redo();
}

function m(obj) {
 	for(var i = 0; i < obj.length; i++) {
  		if(obj.substring(i, i + 1) == ":")
  		break;
 	}
 	return(obj.substring(0, i));
}

function s(obj) {
 	for(var i = 0; i < obj.length; i++) {
  		if(obj.substring(i, i + 1) == ":")
  		break;
 	}
 	return(obj.substring(i + 1, obj.length));
}

function dis(mins,secs) {
 	var disp;
 	if(mins <= 9) {
  		disp = " 0";
 	} else {
  		disp = " ";
 	}
 	disp += mins + ":";
 	if(secs <= 9) {
  		disp += "0" + secs;
 	} else {
  		disp += secs;
 	}
 	return(disp);
}

function redo() {
 	if(count==122)return;
   secs--;
 	if(secs == -1) {
  		secs = 59;
  		mins--;
 	}
 	document.cd.disp.value = dis(mins,secs); // setup additional displays here.
 	//mins = 0;  secs = 0;
 	if((mins == 0) && (secs == 0)) {
  		window.alert("Time's up! Let's see how you did."); 
  		showMissed(); 
 	} else {
 		cd = setTimeout("redo()",1000);
 	}
}

function init() {
  cd();
}
window.onload = init;

var count=0;
var found=new Array();
var cssproperties=new Array(
'azimuth',
'background',
'background-attachment',
'background-color',
'background-image',
'background-position',
'background-repeat',
'border',
'border-collapse',
'border-color',
'border-spacing',
'border-style',
'border-top',
'border-right',
'border-bottom',
'border-left',
'border-top-color',
'border-right-color',
'border-bottom-color',
'border-left-color',
'border-top-style',
'border-right-style',
'border-bottom-style',
'border-left-style',
'border-top-width',
'border-right-width',
'border-bottom-width',
'border-left-width',
'border-width',
'bottom',
'caption-side',
'clear',
'clip',
'color',
'content',
'counter-increment',
'counter-reset',
'cue',
'cue-after',
'cue-before',
'cursor',
'direction',
'display',
'elevation',
'empty-cells',
'float',
'font',
'font-family',
'font-size',
'font-size-adjust',
'font-stretch',
'font-style',
'font-variant',
'font-weight',
'height',
'left',
'letter-spacing',
'line-height',
'list-style',
'list-style-image',
'list-style-position',
'list-style-type',
'margin',
'margin-top',
'margin-right',
'margin-bottom',
'margin-left',
'marker-offset',
'marks',
'max-height',
'max-width',
'min-height',
'min-width',
'orphans',
'outline',
'outline-color',
'outline-style',
'outline-width',
'overflow',
'padding',
'padding-top',
'padding-right',
'padding-bottom',
'padding-left',
'page',
'page-break-after',
'page-break-before',
'page-break-inside',
'pause',
'pause-after',
'pause-before',
'pitch',
'pitch-range',
'play-during',
'position',
'quotes',
'richness',
'right',
'size',
'speak',
'speak-header',
'speak-numeral',
'speak-punctuation',
'speech-rate',
'stress',
'table-layout',
'text-align',
'text-decoration',
'text-indent',
'text-shadow',
'text-transform',
'top',
'unicode-bidi',
'vertical-align',
'visibility',
'voice-family',
'volume',
'white-space',
'widows',
'width',
'word-spacing',
'z-index'
);
function checkProperties(fld){
if(fld.value.length>0){
for(var i=0;i<cssproperties.length;i++){
   if(fld.value.toLowerCase()==cssproperties[i].toLowerCase()){
    found[found.length]=cssproperties[i];
    found.sort();
    cssproperties.splice(i,1);
    fld.value="";
    count++;
    var msg="";
    for(var x=0;x<found.length;x++){
      msg+=found[x]+", ";
//      if((x+1)%5==0)msg+="<br />";
    }
    document.getElementById("found").innerHTML=msg;
    var remainmsg=" CSS properties remain";
    if(count==90)remainmsg=" element remains";
    document.getElementById("remain").innerHTML=(122-count)+remainmsg;
    if(count==122){
      		window.alert("Way to go, you got them all!"); 
    }
  }
  }
  }else{
  if(fld.value==" ")fld.value="";
  }
 }
 
 
function showMissed(){
    var msg="";
    msg+='<h2 class="swatch2">You forgot:</h2><p class="swatch2">';
    for(var x=0;x<cssproperties.length;x++){
      msg+=cssproperties[x]+", ";
//      if((x+1)%5==0)msg+="<br />";
    }
    msg+='</p>';
    document.getElementById("properties_results").innerHTML=msg;
    document.getElementById("share").style.display = 'block';
    document.getElementById("mingle2_badge_score").innerHTML = count;
    $('code_textarea').value = $('code_textarea').value.replace('[[score]]',count);
 }
