/* <![CDATA[ */
$j(document).ready(function() {


		/*$j("#tradedoubler").hide();
		$j(window).load(function () {
			$j.ajax({
			  url: "http://impse.tradedoubler.com/imp?g(17040862)a(1154108)",
			  dataType: 'script',
			  success: function(msg) {
			  	$("#europatipset").html(msg);
			  }
			});
			$j.ajax({
			  url: "http://impse.tradedoubler.com/imp?g(17040904)a(1154108)",
			  dataType: 'script',
			  success: function(msg) {
			  	$j("#stryktipset").html(msg);
			  }
			});
			$j.ajax({
			  url: "http://impse.tradedoubler.com/imp?g(17040878)a(1154108)",
			  dataType: 'script',
			  success: function(msg) {
			  	$j("#bomben").html(msg);
			  }
			});
			$j.ajax({
			  url: "http://impse.tradedoubler.com/imp?g(17040882)a(1154108)",
			  dataType: 'script',
			  success: function(msg) {
			  	$j("#oddsetlive").html(msg);
			  }
			});
			$j.ajax({
			  url: "http://impse.tradedoubler.com/imp?g(17040888)a(1154108)",
			  dataType: 'script',
			  success: function(msg) {
			  	$j("#matchen").html(msg);
			  }
			});
			$j.ajax({
			  url: "http://impse.tradedoubler.com/imp?g(17040876)a(1154108)",
			  dataType: 'script',
			  success: function(msg) {
			  	$j("#oddset").html(msg);
			  }
			});
			//$j("#tradedoubler").show();
		});	*/

	$j('#playAmount').keyup(function()	{
		var amount = $j('#playAmount').val();
		var winPos;
		if(isNaN(amount)){
			alert("Du måste ange en insats större än 0");
			winPos = 0;	
		}	else	{
			var odds = $j(".totalOdds").html();	
			 winPos = odds*amount;
		}
		$j("#winPos").html(winPos);
	});
	$j('.tipsRowU').dblclick(function()	{
		$j(this).attr("checked", false);
	});	
	$j('.tipsRow').click(function()	{
		updateOdds();
	});
	$j('form[name=stryktipset] .tipsRow').click(function()	{
		updateStryktipset();
	});
});

function updateStryktipset(){
	//$j('.tipsRowU').attr("disabled", true);
	var a; var b; var c;
	var total = 1;
	var i = 0;
	var rowSum = 0;
	var row = 1;
	var helGarderingar = 0;
	var halvGarderingar = 0;
	$j('.tipsRow').each(function(index) {
		if($j(this).is(':checked')){
			if(i == 0){ // etta
				//$j(this).parent().find(".").html();
				a = 1;
				rowSum++;
			} 
			else if(i == 1){ //kryss
				//val = $j(this).parent().parent().prev().find("#kryss").html();
				b = 1;
				rowSum++;

			} else {
				//val = $j(this).parent().parent().prev().find("#tva").html();
				c = 1;
				rowSum++;
			}	
		}
				
		i = i + 1;
		
		if(i % 3 == 0){
			i = 0;
			if(rowSum > 0)
				total = total*rowSum;

			if(rowSum == 3)
				helGarderingar++;
			else if(rowSum == 2)
				halvGarderingar++;
				
	/*		if(rowSum == 3){
				$j('#utfall_u_1_'+row).removeAttr('disabled');
				$j('#utfall_u_x_'+row).removeAttr('disabled');
				$j('#utfall_u_2_'+row).removeAttr('disabled');
			}
			else if(rowSum == 2) {
				if(a == 1){
					$j('#utfall_u_1_'+row).removeAttr('disabled');
				}	else	{
					$j('#utfall_u_1_'+row).attr("checked", false);
				}
				if(b == 1){
					$j('#utfall_u_x_'+row).removeAttr('disabled');
				}	else	{
					$j('#utfall_u_x_'+row).attr("checked", false);
				}
				if(c == 1){
					$j('#utfall_u_2_'+row).removeAttr('disabled');
				}	else	{
					$j('#utfall_u_2_'+row).attr("checked", false);
				}
			}	else	{
				$j("[name='row_value_u_["+row+"]']").attr("checked", false);
			}	*/
			
			rowSum = 0; a = 0; b = 0; c = 0;
			row++;
		}
	});
		
		//total = Math.round(total*100)/100;

		$j("#totalSumma").html(total);
		$j("#totalHel").html(helGarderingar);
		$j("#totalHalv").html(halvGarderingar);
}

function updateOdds(){
	var total = 1;
	var arr = new Array();
	var i = 0;
	var val = 1;

	$j('.tipsRow').each(function(index) {
	 		arr[index] = new Array();
		if($j(this).is(':checked')){
			if(i == 0){ // etta
				val = $j(this).parent().parent().prev().find("#ett").html();
			} 
			else if(i == 1){ //kryss
				val = $j(this).parent().parent().prev().find("#kryss").html();
			} else {
				val = $j(this).parent().parent().prev().find("#tva").html();
			}	
		}
		
		i = i + 1;
		if(i % 3 == 0){
			i = 0;
			if (val > 1)
				total = val*total;
			val = 1;
		}
		});
		
		total = Math.round(total*100)/100;

		$j(".totalOdds").html(total);
}

/* ]]> */
			function getPoints(pImage)
			{
				if(pImage.src == 'http://www.maharajah.racing/ext/graphics/box_black.gif' || pImage.src == 'http://www.maharajah.racing/ext/graphics/box_black_g.gif')
					return 1;
				else
					return 0;
			}

			function isCorrect(pImage)
			{
				if(pImage.src == 'http://www.maharajah.racing/ext/graphics/box_black_g.gif')
					return 1;
				else
					return 0;
			}	
			
			function calcStryketRows()
			{
				t1_1  = document.getElementById('1_1');	t1_x  = document.getElementById('1_x');	t1_2  = document.getElementById('1_2');
				t2_1  = document.getElementById('2_1');	t2_x  = document.getElementById('2_x');	t2_2  = document.getElementById('2_2');
				t3_1  = document.getElementById('3_1');	t3_x  = document.getElementById('3_x');	t3_2  = document.getElementById('3_2');
				t4_1  = document.getElementById('4_1');	t4_x  = document.getElementById('4_x');	t4_2  = document.getElementById('4_2');
				t5_1  = document.getElementById('5_1');	t5_x  = document.getElementById('5_x');	t5_2  = document.getElementById('5_2');
				t6_1  = document.getElementById('6_1');	t6_x  = document.getElementById('6_x');	t6_2  = document.getElementById('6_2');
				t7_1  = document.getElementById('7_1');	t7_x  = document.getElementById('7_x');	t7_2  = document.getElementById('7_2');
				t8_1  = document.getElementById('8_1');	t8_x  = document.getElementById('8_x');	t8_2  = document.getElementById('8_2');
				t9_1  = document.getElementById('9_1');	t9_x  = document.getElementById('9_x');	t9_2  = document.getElementById('9_2');
				t10_1 = document.getElementById('10_1');	t10_x = document.getElementById('10_x');	t10_2 = document.getElementById('10_2');
				t11_1 = document.getElementById('11_1');	t11_x = document.getElementById('11_x');	t11_2 = document.getElementById('11_2');
				t12_1 = document.getElementById('12_1');	t12_x = document.getElementById('12_x');	t12_2 = document.getElementById('12_2');
				t13_1 = document.getElementById('13_1');	t13_x = document.getElementById('13_x');	t13_2 = document.getElementById('13_2');

				t1  = (getPoints(t1_1)  +  getPoints(t1_x)  + getPoints(t1_2));if(t1 == 0) t1 = 1;    if(t1 == 2);
				t2  = (getPoints(t2_1)  +  getPoints(t2_x)  + getPoints(t2_2));if(t2 == 0) t2 = 1;    if(t1 == 2);
				t3  = (getPoints(t3_1)  +  getPoints(t3_x)  + getPoints(t3_2));if(t3 == 0) t3 = 1;    if(t1 == 2);
				t4  = (getPoints(t4_1)  +  getPoints(t4_x)  + getPoints(t4_2));if(t4 == 0) t4 = 1;    if(t1 == 2);
				t5  = (getPoints(t5_1)  +  getPoints(t5_x)  + getPoints(t5_2));if(t5 == 0) t5 = 1;    if(t1 == 2);
				t6  = (getPoints(t6_1)  +  getPoints(t6_x)  + getPoints(t6_2));if(t6 == 0) t6 = 1;    if(t1 == 2);
				t7  = (getPoints(t7_1)  +  getPoints(t7_x)  + getPoints(t7_2));if(t7 == 0) t7 = 1;    if(t1 == 2);
				t8  = (getPoints(t8_1)  +  getPoints(t8_x)  + getPoints(t8_2));if(t8 == 0) t8 = 1;    if(t1 == 2);
				t9  = (getPoints(t9_1)  +  getPoints(t9_x)  + getPoints(t9_2));if(t9 == 0) t9 = 1;    if(t1 == 2);
				t10 = (getPoints(t10_1) + getPoints(t10_x)  + getPoints(t10_2));if(t10 == 0) t10 = 1; if(t1 == 2);
				t11 = (getPoints(t11_1) + getPoints(t11_x)  + getPoints(t11_2));if(t11 == 0) t11 = 1; if(t1 == 2);
				t12 = (getPoints(t12_1) + getPoints(t12_x)  + getPoints(t12_2));if(t12 == 0) t12 = 1; if(t1 == 2);
				t13 = (getPoints(t13_1) + getPoints(t13_x)  + getPoints(t13_2));if(t13 == 0) t13 = 1; if(t1 == 2);
								
				tPoints = t1 * t2 * t3 * t4 * t5 * t6 * t7 * t8 * t9 * t10 * t11 * t12 * t13;

				return tPoints;
			}

			function countCorrectRows()
			{
				t1_1  = document.getElementById('1_1');	t1_x  = document.getElementById('1_x');	t1_2  = document.getElementById('1_2');
				t2_1  = document.getElementById('2_1');	t2_x  = document.getElementById('2_x');	t2_2  = document.getElementById('2_2');
				t3_1  = document.getElementById('3_1');	t3_x  = document.getElementById('3_x');	t3_2  = document.getElementById('3_2');
				t4_1  = document.getElementById('4_1');	t4_x  = document.getElementById('4_x');	t4_2  = document.getElementById('4_2');
				t5_1  = document.getElementById('5_1');	t5_x  = document.getElementById('5_x');	t5_2  = document.getElementById('5_2');
				t6_1  = document.getElementById('6_1');	t6_x  = document.getElementById('6_x');	t6_2  = document.getElementById('6_2');
				t7_1  = document.getElementById('7_1');	t7_x  = document.getElementById('7_x');	t7_2  = document.getElementById('7_2');
				t8_1  = document.getElementById('8_1');	t8_x  = document.getElementById('8_x');	t8_2  = document.getElementById('8_2');
				t9_1  = document.getElementById('9_1');	t9_x  = document.getElementById('9_x');	t9_2  = document.getElementById('9_2');
				t10_1 = document.getElementById('10_1');	t10_x = document.getElementById('10_x');	t10_2 = document.getElementById('10_2');
				t11_1 = document.getElementById('11_1');	t11_x = document.getElementById('11_x');	t11_2 = document.getElementById('11_2');
				t12_1 = document.getElementById('12_1');	t12_x = document.getElementById('12_x');	t12_2 = document.getElementById('12_2');
				t13_1 = document.getElementById('13_1');	t13_x = document.getElementById('13_x');	t13_2 = document.getElementById('13_2');

				t1  = (isCorrect(t1_1)  +  isCorrect(t1_x)  + isCorrect(t1_2));
				t2  = (isCorrect(t2_1)  +  isCorrect(t2_x)  + isCorrect(t2_2));
				t3  = (isCorrect(t3_1)  +  isCorrect(t3_x)  + isCorrect(t3_2));
				t4  = (isCorrect(t4_1)  +  isCorrect(t4_x)  + isCorrect(t4_2));
				t5  = (isCorrect(t5_1)  +  isCorrect(t5_x)  + isCorrect(t5_2));
				t6  = (isCorrect(t6_1)  +  isCorrect(t6_x)  + isCorrect(t6_2));
				t7  = (isCorrect(t7_1)  +  isCorrect(t7_x)  + isCorrect(t7_2));
				t8  = (isCorrect(t8_1)  +  isCorrect(t8_x)  + isCorrect(t8_2));
				t9  = (isCorrect(t9_1)  +  isCorrect(t9_x)  + isCorrect(t9_2));
				t10 = (isCorrect(t10_1) + isCorrect(t10_x)  + isCorrect(t10_2));
				t11 = (isCorrect(t11_1) + isCorrect(t11_x)  + isCorrect(t11_2));
				t12 = (isCorrect(t12_1) + isCorrect(t12_x)  + isCorrect(t12_2));
				t13 = (isCorrect(t13_1) + isCorrect(t13_x)  + isCorrect(t13_2));
								
				tPoints = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11 + t12 + t13;

				return tPoints;
			}
			
			function getSignPostString()
			{
				tRows = calcStryketRows();
				tHel = 0;
				tHalv = 0;
				t1_1  = getPoints(document.getElementById('1_1'));	t1_x  = getPoints(document.getElementById('1_x'));	t1_2  = getPoints(document.getElementById('1_2'));  if(t1_1+t1_x+t1_2 == 2)    tHalv = tHalv +1; if(t1_1+t1_x+t1_2 == 3)    tHel = tHel +1;
				t2_1  = getPoints(document.getElementById('2_1'));	t2_x  = getPoints(document.getElementById('2_x'));	t2_2  = getPoints(document.getElementById('2_2'));  if(t2_1+t2_x+t2_2 == 2)    tHalv = tHalv +1; if(t2_1+t2_x+t2_2 == 3)    tHel = tHel +1;
				t3_1  = getPoints(document.getElementById('3_1'));	t3_x  = getPoints(document.getElementById('3_x'));	t3_2  = getPoints(document.getElementById('3_2'));  if(t3_1+t3_x+t3_2 == 2)    tHalv = tHalv +1; if(t3_1+t3_x+t3_2 == 3)    tHel = tHel +1;
				t4_1  = getPoints(document.getElementById('4_1'));	t4_x  = getPoints(document.getElementById('4_x'));	t4_2  = getPoints(document.getElementById('4_2'));  if(t4_1+t4_x+t4_2 == 2)    tHalv = tHalv +1; if(t4_1+t4_x+t4_2 == 3)    tHel = tHel +1;
				t5_1  = getPoints(document.getElementById('5_1'));	t5_x  = getPoints(document.getElementById('5_x'));	t5_2  = getPoints(document.getElementById('5_2'));  if(t5_1+t5_x+t5_2 == 2)    tHalv = tHalv +1; if(t5_1+t5_x+t5_2 == 3)    tHel = tHel +1;
				t6_1  = getPoints(document.getElementById('6_1'));	t6_x  = getPoints(document.getElementById('6_x'));	t6_2  = getPoints(document.getElementById('6_2'));  if(t6_1+t6_x+t6_2 == 2)    tHalv = tHalv +1; if(t6_1+t6_x+t6_2 == 3)    tHel = tHel +1;
				t7_1  = getPoints(document.getElementById('7_1'));	t7_x  = getPoints(document.getElementById('7_x'));	t7_2  = getPoints(document.getElementById('7_2'));  if(t7_1+t7_x+t7_2 == 2)    tHalv = tHalv +1; if(t7_1+t7_x+t7_2 == 3)    tHel = tHel +1;
				t8_1  = getPoints(document.getElementById('8_1'));	t8_x  = getPoints(document.getElementById('8_x'));	t8_2  = getPoints(document.getElementById('8_2'));  if(t8_1+t8_x+t8_2 == 2)    tHalv = tHalv +1; if(t8_1+t8_x+t8_2 == 3)    tHel = tHel +1;
				t9_1  = getPoints(document.getElementById('9_1'));	t9_x  = getPoints(document.getElementById('9_x'));	t9_2  = getPoints(document.getElementById('9_2'));  if(t9_1+t9_x+t9_2 == 2)    tHalv = tHalv +1; if(t9_1+t9_x+t9_2 == 3)    tHel = tHel +1;
				t10_1 = getPoints(document.getElementById('10_1'));	t10_x = getPoints(document.getElementById('10_x'));	t10_2 = getPoints(document.getElementById('10_2')); if(t10_1+t10_x+t10_2 == 2) tHalv = tHalv +1; if(t10_1+t10_x+t10_2 == 3) tHel = tHel +1;
				t11_1 = getPoints(document.getElementById('11_1'));	t11_x = getPoints(document.getElementById('11_x'));	t11_2 = getPoints(document.getElementById('11_2')); if(t11_1+t11_x+t11_2 == 2) tHalv = tHalv +1; if(t11_1+t11_x+t11_2 == 3) tHel = tHel +1;
				t12_1 = getPoints(document.getElementById('12_1'));	t12_x = getPoints(document.getElementById('12_x'));	t12_2 = getPoints(document.getElementById('12_2')); if(t12_1+t12_x+t12_2 == 2) tHalv = tHalv +1; if(t12_1+t12_x+t12_2 == 3) tHel = tHel +1;
				t13_1 = getPoints(document.getElementById('13_1'));	t13_x = getPoints(document.getElementById('13_x'));	t13_2 = getPoints(document.getElementById('13_2')); if(t13_1+t13_x+t13_2 == 2) tHalv = tHalv +1; if(t13_1+t13_x+t13_2 == 3) tHel = tHel +1;
				
		 		var tPostString = 
		 		"rows="+tRows+"&t1_1="+t1_1+"&t1_x="+t1_x+"&t1_2="+t1_2+
		 		"&t2_1="+t2_1+"&t2_x="+t2_x+"&t2_2="+t2_2+
		 		"&t3_1="+t3_1+"&t3_x="+t3_x+"&t3_2="+t3_2+
		 		"&t4_1="+t4_1+"&t4_x="+t4_x+"&t4_2="+t4_2+
		 		"&t5_1="+t5_1+"&t5_x="+t5_x+"&t5_2="+t5_2+
		 		"&t6_1="+t6_1+"&t6_x="+t6_x+"&t6_2="+t6_2+
		 		"&t7_1="+t7_1+"&t7_x="+t7_x+"&t7_2="+t7_2+
		 		"&t8_1="+t8_1+"&t8_x="+t8_x+"&t8_2="+t8_2+
		 		"&t9_1="+t9_1+"&t9_x="+t9_x+"&t9_2="+t9_2+
		 		"&t10_1="+t10_1+"&t10_x="+t10_x+"&t10_2="+t10_2+
		 		"&t11_1="+t11_1+"&t11_x="+t11_x+"&t11_2="+t11_2+
		 		"&t12_1="+t12_1+"&t12_x="+t12_x+"&t12_2="+t12_2+
		 		"&t13_1="+t13_1+"&t13_x="+t13_x+"&t13_2="+t13_2+
		 		"&hel="+tHel+"&halv="+tHalv;

				return tPostString;
			}			

			function x1159474155336(pImage, pUrl, pIsClicked, pSign, pUtfall) 
		 	{ 
		 		var t1 = null;var tx = null;var t2 = null;
		 		if(gImageScreens[pImage.id] != 'http://www.maharajah.racing/ext/graphics/box_black.gif' && gImageScreens[pImage.id] != 'http://www.maharajah.racing/ext/graphics/box_black_g.gif')
		 		{
			 		gImageScreens[pImage.id] = pImage.src; 
			 		if(pIsClicked)
			 		{
			 			if(pSign == pUtfall)
			 				pImage.src = 'https://www.maharajah.racing/ext/graphics/box_black_g.gif';
			 			else
				 			pImage.src = pUrl;
			 		}
			 		else
			 			pImage.src = pUrl;
		 		}
		 		else
		 		{
		 			gImageScreens[pImage.id] = null;
		 			if(pSign == pUtfall)
		 				pImage.src = 'https://www.maharajah.racing/ext/graphics/box_empty_g.gif';
		 			else
		 				pImage.src = 'https://www.maharajah.racing/ext/graphics/box_empty.gif';
		 		}
		 		if(pIsClicked) 
		 		{
		 			gInPickMode = true;
		 			document.getElementById('stryketRows').innerHTML = calcStryketRows();
		 			document.getElementById('correctRows').innerHTML = countCorrectRows();
		 			document.getElementById('rensa').style.display='inline';
		 			//pick(pSign, pImage, pId)
		 		}
		 		else
		 			gInPickMode = false;
		 	} 
		 	
		 	function x1159474155341(pImage, pSign, pUtfall) 
		 	{ 
		 		if(gInPickMode == false && gImageScreens[pImage.id] != null) 
		 		{ 
		 			pImage.src = gImageScreens[pImage.id]; 
		 			gImageScreens[pImage.id] = null; 
		 		} 
		 	} 
		 	function removeStryket(pSystemId, pType) 
		 	{
		 		var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=removeStryket&type='+pType;
		 		var tPostString = "id="+pSystemId;
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerRemoveStryket);
		 		xmlHttp_Post(xmlHttp, tURL, tPostString);
		 	}
		 	function stateChangeHandlerRemoveStryket()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 			var tStr = xmlHttp.responseText;
		 			//alert(tStr);
		 			document.location.href = tStr;
		 		}
		 	}
///////////////////////////
//Alex
////////////////////

/*		 	function getURowStryktipset(){
		 		var total = 0;
		 		var arr = new Object();
		 		var arrVal = [];
		 		var arrID = [];
		 		var arrRow = [];
				var i = 0; 
				var currentRow = 0;
				var string;
				var element_id = 0;
				$j('.tipsRow').each(function(index) {
					if(index % 3 === 0){
						element_id = $j(this).attr("meta:index");
						row = $j(this).attr("meta:row");
						//console.log(element_id);
		   	 			arrVal[currentRow] = [];
		   	 			arrID[currentRow] = [];
		   	 			arrRow[currentRow] = [];
		   	 		}
		   	 			
					if($j(this).is(':checked')){	//then we have 1
						if(i == 0)
							arrVal[currentRow][i] = '1';
						else if(i == 1)
							arrVal[currentRow][i] = 'x';
						else
							arrVal[currentRow][i] = '2';
					}	else	{
						arrVal[currentRow][i] = '';
					}
					
					arrID[currentRow][i] = element_id;
					arrRow[currentRow][i] = row;

					i = i + 1;
					if(i % 3 === 0){
						i = 0;
						currentRow = currentRow + 1;
					}
		  		});
		  		
		  		arr.ids = arrID;
		  		arr.val = arrVal;
		  		arr.row = arrRow;
		  		
		  		return uRow;
		 	}*/

		 	function getBettingData(){
		 		var total = 0;
		 		var arr = new Object();
		 		var arrVal = [];
		 		var arrID = [];
		 		var arrRow = [];
		 		var arrURow = [];
				var i = 0; 
				var currentRow = 0;
				var string;
				var element_id = 0;
				$j('.tipsRow').each(function(index) {
					if(index % 3 === 0){
						element_id = $j(this).attr("meta:index");
						row = $j(this).attr("meta:row");
						//console.log(element_id);
		   	 			arrVal[currentRow] = [];
		   	 			arrID[currentRow] = [];
		   	 			arrRow[currentRow] = [];
		   	 			arrURow[currentRow] = [];
		   	 		}
		   	 			
					if($j(this).is(':checked')){	//then we have 1
						if(i == 0)
							arrVal[currentRow][i] = '1';
						else if(i == 1)
							arrVal[currentRow][i] = 'x';
						else
							arrVal[currentRow][i] = '2';
					}	else	{
						arrVal[currentRow][i] = '';
					}
					
					arrID[currentRow][i] = element_id;
					arrRow[currentRow][i] = row;

					i = i + 1;
					if(i % 3 === 0){
						arrURow[currentRow] = $j("[name='row_value_u_["+(currentRow+1)+"]']:checked").attr("value");
						i = 0;
						currentRow = currentRow + 1;
					}
		  		});
		  		
		  		arr.ids = arrID;
		  		arr.val = arrVal;
		  		arr.row = arrRow;
		  		arr.urow = arrURow;
		  		
		  		return arr;
		 	}
			function setBettingFields(obj){
				
				var data = obj;
				var nrInObj = data.length;
				
				for(i = 0; i < nrInObj; i++){
					if(data[i].type == 1)
						$j("#utfall_"+data[i].value+"_"+data[i].row).attr("checked", "checked");
					else if(data[i].type == 2)
						$j("#utfall_u_"+data[i].value+"_"+data[i].row).attr("checked", "checked");
				}		
			}

		 	function emptyKupong(){
		 		
				$j('.tipsRow').each(function(index) {
					this.checked = false;
				});
				$j('.tipsRowU').each(function(index) {
					this.checked = false;
				});
		 		$j("#totalOdds").empty();
		 		$j("#totalSumma").empty();
		 		$j("#totalHel").empty();
		 		$j("#totalHalv").empty();
		 	}	
		 	function removeElitserien(pSystemId, pType) 
		 	{
		 		var tURL = 'ajax.php' + '?action=removeElitserien&type='+pType;
		 		$j.post(tURL, {data: pSystemId}, function(data) {
		 			emptyKupong();
		 			window.location.reload();
		 		});
		 	}
		 	
	/*	 	function updateElitserien(pKupongId, pType) 
		 	{
		 		tId = document.getElementById('proposalid').value;
		 		var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=updateStryket&kupong='+pKupongId+'&type='+pType+'&id='+tId;
		 		var tPostString = getSignPostString();
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerRemoveStryket);
		 		xmlHttp_Post(xmlHttp, tURL, tPostString);
		 	} */
		 	function loadElitserien(pSystemId, pType) 
		 	{
		 		var tURL = 'ajax.php' + '?action=loadElitserien&type='+pType;
		 		$j.post(tURL, {data: pSystemId}, function(data) {
					setBettingFields(data);
		 		}, "json");
		 	}
		 	function saveElitserien(pKupongId, pType){
		 		
		 		//type 1 = nÃ¥t
		 		//type 3 = elitserien
		 		
		 		var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=saveElitserien&kupong='+pKupongId+'&pType='+pType;
		 		
		 		var myArr = new Object();
		 		myData = getBettingData();
		 		myArr.jsonStr = myData;
		 		var jsonString = JSON.stringify(myArr);
		 		
		 		//console.log(jsonString);
		 		
		 		$j.post(tURL, {data: jsonString}, function(data) {
		 			window.location.reload();
		 		});
		 		
		 	}
		 	
		 	///////////////////////////////////////////////////////
		 	
		 	function saveStryket(pKupongId, pType)
		 	{
		 		var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=saveStryket&kupong='+pKupongId+'&type='+pType;
		 		var tPostString = getSignPostString();
		 		
		 		$j.ajax({
				   type: "POST",
				   dataType: "html",
				   url: tURL,
				   data: tPostString,
				   success: function(msg){
				   	document.location.href = msg;
				   }
			 	});
		 	} 
		 	
		 	function showSendToFriend()
		 	{
		 		tElement = document.getElementById('sendField').style.display='inline';
		 	}
		 	function sendStryket(pKupongId, pType, pReturn) 
		 	{
		 		tId = document.getElementById('proposalid').value;
		 		tFromMail = document.getElementById('fromMail').value;
		 		tToMail = document.getElementById('toMail').value;
		 		tFromName = document.getElementById('fromName').value;
		 		tToName = document.getElementById('toName').value;
		 		if(tFromMail == '' || tToMail == '')
		 		{
		 			alert("BÃ¥da e-postfÃ¤lten mÃ¥ste fyllas i!");
		 		}
		 		else
		 		{
		 			var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=sendStryket&kupong='+pKupongId+'&type='+pType+'&id='+tId+'&email='+tFromMail+'&tomail='+tToMail+'&returnPath='+pReturn+'&toname='+tToName+'&name='+tFromName;
		 			var tPostString = getSignPostString();
		 			xmlHttp = GetXmlHttpObject(stateChangeHandlerSendStryket);
		 			xmlHttp_Post(xmlHttp, tURL, tPostString);
		 		}
		 	}
		 	function stateChangeHandlerSendStryket()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 			var tStr = xmlHttp.responseText;
		 			//alert(tStr);
		 			document.location.href = tStr;
		 		}
		 	} 
		 	function updateStryket(pKupongId, pType) 
		 	{
		 		tId = document.getElementById('proposalid').value;
		 		var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=updateStryket&kupong='+pKupongId+'&type='+pType+'&id='+tId;
		 		var tPostString = getSignPostString();
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerRemoveStryket);
		 		xmlHttp_Post(xmlHttp, tURL, tPostString);
		 	} 
		 	function loadStryket(pSystemId, pType, pEmail) 
		 	{
		 		var tURL = 'ajax.php' + '?q=' + Math.random() + '&action=loadStryket&type='+pType+'&email='+pEmail;
		 		var tPostString = 'id='+pSystemId;
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerLoadStryket);
		 		xmlHttp_Post(xmlHttp, tURL, tPostString);
		 	}
		 	function setMark(pValue, pId)
		 	{
		 		tElement = document.getElementById(pId);
		 		if(pValue == 1)
		 		{
		 			if(tElement.src == "https://www.maharajah.racing/ext/graphics/box_empty_g.gif")
		 				tElement.src = "https://www.maharajah.racing/ext/graphics/box_black_g.gif";
		 			else if(tElement.src == "https://www.maharajah.racing/ext/graphics/box_black_g.gif")
		 				tElement.src = "https://www.maharajah.racing/ext/graphics/box_black_g.gif";
		 				else
		 					tElement.src = "https://www.maharajah.racing/ext/graphics/box_black.gif";
		 		}
		 		else
		 		{
		 			if(tElement.src == "https://www.maharajah.racing/ext/graphics/box_empty_g.gif")
		 				tElement.src = "https://www.maharajah.racing/ext/graphics/box_empty_g.gif"
		 			else
		 				tElement.src = "https://www.maharajah.racing/ext/graphics/box_empty.gif";
		 		}
		 	}
		 	function stateChangeHandlerLoadStryket()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 			var tXml = xmlHttp.responseXML;
					var proposal = tXml.getElementsByTagName("*");
					
					setMark(proposal[0].getAttribute('t1_1'), '1_1');  setMark(proposal[0].getAttribute('t1_x'), '1_x');  setMark(proposal[0].getAttribute('t1_2'), '1_2');
					setMark(proposal[0].getAttribute('t2_1'), '2_1');  setMark(proposal[0].getAttribute('t2_x'), '2_x');  setMark(proposal[0].getAttribute('t2_2'), '2_2');
					setMark(proposal[0].getAttribute('t3_1'), '3_1');  setMark(proposal[0].getAttribute('t3_x'), '3_x');  setMark(proposal[0].getAttribute('t3_2'), '3_2');
					setMark(proposal[0].getAttribute('t4_1'), '4_1');  setMark(proposal[0].getAttribute('t4_x'), '4_x');  setMark(proposal[0].getAttribute('t4_2'), '4_2');
					setMark(proposal[0].getAttribute('t5_1'), '5_1');  setMark(proposal[0].getAttribute('t5_x'), '5_x');  setMark(proposal[0].getAttribute('t5_2'), '5_2');
					setMark(proposal[0].getAttribute('t6_1'), '6_1');  setMark(proposal[0].getAttribute('t6_x'), '6_x');  setMark(proposal[0].getAttribute('t6_2'), '6_2');
					setMark(proposal[0].getAttribute('t7_1'), '7_1');  setMark(proposal[0].getAttribute('t7_x'), '7_x');  setMark(proposal[0].getAttribute('t7_2'), '7_2');
					setMark(proposal[0].getAttribute('t8_1'), '8_1');  setMark(proposal[0].getAttribute('t8_x'), '8_x');  setMark(proposal[0].getAttribute('t8_2'), '8_2');
					setMark(proposal[0].getAttribute('t9_1'), '9_1');  setMark(proposal[0].getAttribute('t9_x'), '9_x');  setMark(proposal[0].getAttribute('t9_2'), '9_2');
					setMark(proposal[0].getAttribute('t10_1'), '10_1');setMark(proposal[0].getAttribute('t10_x'), '10_x');setMark(proposal[0].getAttribute('t10_2'), '10_2');
					setMark(proposal[0].getAttribute('t11_1'), '11_1');setMark(proposal[0].getAttribute('t11_x'), '11_x');setMark(proposal[0].getAttribute('t11_2'), '11_2');
					setMark(proposal[0].getAttribute('t12_1'), '12_1');setMark(proposal[0].getAttribute('t12_x'), '12_x');setMark(proposal[0].getAttribute('t12_2'), '12_2');
					setMark(proposal[0].getAttribute('t13_1'), '13_1');setMark(proposal[0].getAttribute('t13_x'), '13_x');setMark(proposal[0].getAttribute('t13_2'), '13_2');
					document.getElementById('proposalid').value = proposal[0].getAttribute('id');
					document.getElementById('kupongid').value = proposal[0].getAttribute('kupongid');
					tKupongId = document.getElementById('kupongid').value = proposal[0].getAttribute('kupongid');
			 		document.getElementById('stryketRows').innerHTML = calcStryketRows();
			 		document.getElementById('correctRows').innerHTML = countCorrectRows();
			 		
			 		document.getElementById('rensa').style.display='inline';
			 		tHiddenUpdate = document.getElementById('hiddenUpdate');
			 		var a = document.getElementById('saveChanges');
			 		if(a == null)
			 			a = document.createElement('a');
			 		tType = getParameter('type');
			 		a.id = "saveChanges";
			 		a.href="#";
			 		a.onclick=Function("updateStryket("+tKupongId+","+tType+")")
			 		a.style.color="black";
			 		if("<br />Spara Ã¤ndringar" != a.innerHTML)
			 			a.innerHTML = "<br />Spara Ã¤ndringar";
			 		tHiddenUpdate.appendChild(a);
			 		tHiddenUpdate.style.display = 'true';
		 		}
		 	}

			function getParameter(theArgName)
			{
				sArgs = location.search.slice(1).split('&');
			    r = '';
			    for (var i = 0; i < sArgs.length; i++) 
			    {
			    	var tString = new String(sArgs[i]);
			    	var tIndex = tString.indexOf('=');
			        if (sArgs[i].slice(0,tIndex) == theArgName) {
			            r = sArgs[i].slice(sArgs[i].indexOf('=')+1);
			            break;
			        }
			    }
			    return (r.length > 0 ? unescape(r).split(',') : '');
			}
			
			function checkBoxValue(pValue)
			{
				if(pValue == 'on')
					return 1;
				else
					return 0;
			}

		 	var gOpenedFloat = ''; var gImageScreens = new Array(); var gSignsArray = new Array(); var xmlHttp; var gInPickMode = false; var gNotFirstTime = false;
		 	var coverGames = 'coverGames.php';var sneakyGames = 'sneakyGames.php';var pickGames = 'pickGames.php'; var requestURL = 'getNewResults.php'+location.search; var x1159474155332 = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0; var x1159474155333 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0; var x1159474155334 = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0; var x1159474155335 = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0; 
		 	
			window.onerror = null;
	 		var bName = navigator.appName;
	 		var bVer = parseInt(navigator.appVersion);
	 		var NS4 = (bName == "Netscape" && bVer >= 4);
	 		var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
	 		var blink_speed=700;
	 		var j=0;

	 		function blink(pName, pRedName, pTagName, pTable, pSelectById)
			{
				if(typeof pSelectById != "undefined" && pSelectById == true)
				{
					var tTable = document.getElementById(pTable);
				} else {
					if(typeof pTable == "undefined") pTable = 1;
					var tTables = document.getElementsByTagName("table");
					var tTable = tTables[pTable];
					var pSelectById = false;
				}
				var tTags = tTable.getElementsByTagName(pTagName);
				for(var i = 0; i < tTags.length; i++)
				{
					tTag = tTags.item(i);
					tTagAttributes = tTag.attributes;
					tAttribute = tTagAttributes.getNamedItem("NAME");
					if(tAttribute != null)
					{
						if((tAttribute.value == pName || tAttribute.value == pRedName) && (NS4 || IE4))
						{ 
							if(j%2==0)
							{
									tTag.style.color="#AAAAAA";
							}
							else
							{
								if(pRedName == tAttribute.value)
									tTag.style.color="#ff0000";
								else
									tTag.style.color="#555555";
							}
						}
					}
				}
	
				if(j < 1) j++;
				else j--;
			
				setTimeout("blink('"+pName+"','"+pRedName+"','"+pTagName+"', '"+pTable+"', "+pSelectById+")",blink_speed);
			}
			
	 		function blinkred(pName, pTagName)
			{
				var tTables = document.getElementsByTagName("table");
				var tTable = tTables[1];
				var tTags = tTable.getElementsByTagName(pTagName);
				for(var i = 0; i < tTags.length; i++)
				{
					tTag = tTags.item(i);
					tTagAttributes = tTag.attributes;
					tAttribute = tTagAttributes.getNamedItem("NAME");
					if(tAttribute != null)
					{
						if(tAttribute.value == pName && (NS4 || IE4))
						{ 
							if(j%2==0)
							{
								tTag.style.color="#d70000";
							}
							else
								tTag.style.color="#555555";
						}
					}
				}
	
				if(j < 1) j++;
				else j--;
			
				setTimeout("blinkred('"+pName+"','"+pTagName+"')",blink_speed);
			}
		 	
			function changeColor(id) 
			{
				document.getElementById("row"+id).style.backgroundColor="#ccffcc";
			}
			function changeColor2(id) 
			{
				if (id%2==0)
					document.getElementById("row"+id).style.backgroundColor="#EBEBEB";
				else
					document.getElementById("row"+id).style.backgroundColor="#DCDCDC";
			}

		 	function remember() 
		 	{
		 		tRememberMe = checkBoxValue(document.getElementById('rmbr').checked);
		 		var tURL = 'https://www.maharajah.racing/ajax.php' + '?q=' + Math.random() + '&rememberMe='+tRememberMe+'&action=remember';
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerRemember);
		 		xmlHttp_Get(xmlHttp, tURL);
		 	} 
		 	function stateChangeHandlerRemember()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 		}
		 	}
			
		 	function login(pId, pId2) 
		 	{
		 		tElement1 = document.getElementById(pId);
		 		tElement2 = document.getElementById(pId2);
		 		tRememberMe = checkBoxValue(document.getElementById('rmbr').value);
		 		
		 		var tURL = '/ajax.php' + '?q=' + Math.random() + '&e1='+tElement1.value+'&e2='+tElement2.value+'&rememberMe='+tRememberMe+'&action=login';
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerLogin);
		 		xmlHttp_Get(xmlHttp, tURL);
		 	} 
		 	function stateChangeHandlerLogin()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
					if(xmlHttp.responseText == 1)
		 				document.location.reload();
		 			else if(xmlHttp.responseText == 2)
		 				alert("Ditt konto hos Maharajah.racing \u00E4r inte aktiverat. Kolla i skr\u00E4pkorgen efter din aktiveringsl\u00E4nk.\n Your Account Has not been activated. Check your spam folder for activation link.");
		 			else if(xmlHttp.responseText == -1)
		 				alert("Detta konto \u00E4r avst\u00E4ngt!\n This account are suspended!\nContact: maharajah.racing@outlook.com");
		 			else
		 				alert("Fel anv\u00E4ndarnamn eller l\u00F6senord, f\u00F6rs\u00F6k igen!\nWrong username or password. Try again! \n Or contact: maharajah.racing@outlook.com");
		 		}
		 	}
		 	
		 	function logout(pId, pId2) 
		 	{
		 		tElement1 = document.getElementById(pId);
		 		tElement2 = document.getElementById(pId2);
		 		var tURL = '/ajax.php' + '?q=' + Math.random() + '&e1='+tElement1+'&e2='+tElement2+'&action=logout';
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerLogout);
		 		xmlHttp_Get(xmlHttp, tURL);
		 	} 
		 	function stateChangeHandlerLogout()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 			document.location.reload();
		 		}
		 	}
			
			function playSound()
			{
				return '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="0" height="0" id="yes" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="yes.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="yes.swf" quality="high" bgcolor="#ffffff" width="0" height="0" name="yes" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
			}
			
		 	function xmlHttp_Get(x1159474155349, x1159474155345) { x1159474155349.open('GET', x1159474155345, true); x1159474155349.send(null); } 
		 	function GetXmlHttpObject(x1159474155351) { var x1159474155352 = null; if (x1159474155332){ var x1159474155353 = (x1159474155333) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP'; try{ x1159474155352 = new ActiveXObject(x1159474155353); x1159474155352.onreadystatechange = x1159474155351; } catch(e){ alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled'); return; } } else if (x1159474155334){ alert('Opera detected. The page may not behave as expected.'); return; } else{ x1159474155352 = new XMLHttpRequest(); x1159474155352.onload = x1159474155351; x1159474155352.onerror = x1159474155351; } return x1159474155352; }
		 	
		 	function findPos(obj) 
		 	{
				var x = y = 0;
				if (obj.offsetParent) 
				{
					x = obj.offsetLeft
					y = obj.offsetTop
					while (obj = obj.offsetParent) 
					{
						x += obj.offsetLeft
						y += obj.offsetTop
					}
				}
				tArray = new Array();
				tArray['x'] = x;
				tArray['y'] = y;
				return tArray;
			}
		 	
		 	function hourMinute(pTime, pId)
		 	{
		 		if(pTime != 0)
		 		{
					var t = new Date(pTime * 1000);
					var Y = t.getFullYear();
					var M = t.getMonth(); // month-1
					var D = t.getDate();
					var d = t.getDay(); // 0..6 == sun..sat
					var day = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][d];
					var mon = ['Jan','Feb','Mar','Apr','May','Jun',
					          'Jul','Aug','Sep','Oct','Nov','Dec'][M];
					var h = t.getHours();
					var m = t.getMinutes();
					//alert(h);
					var s = t.getSeconds();
					tVar = document.getElementById(pId);
					tVar.innerHTML=zeropad(h)+':'+zeropad(m);
		 		}
		 	}
		 	
		 	function zeropad( n ){ return n>9 ? n : '0'+n; }
			function openFloatStryk(pGameNumber)
			{
			    tQ = '?q=';
			    if(gOpenedFloat != '')
			    {
			    	tFloat = document.getElementById(gOpenedFloat);
			    	if(tFloat != null)
			    		document.getElementById(gOpenedFloat).style.display = 'none';
			    }
			    gOpenedFloat = 'floatSpace'+pGameNumber;
		 		var tURL = 'genStryketFloat.php' + tQ + Math.random() + '&id=' + pGameNumber;
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerFloat);
		 		xmlHttp_Get(xmlHttp, tURL); 
			}
			function openNetFloat(pGameNumber)
			{
			    tQ = '?q=';
			    if(gOpenedFloat != '')
			    {
			    	tFloat = document.getElementById(gOpenedFloat);
			    	if(tFloat != null)
			    		document.getElementById(gOpenedFloat).style.display = 'none';
			    }
			    gOpenedFloat = 'floatSpace'+pGameNumber;
		 		var tURL = 'genNetFloat.php' + tQ + Math.random() + '&id=' + pGameNumber;
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerFloat);
		 		xmlHttp_Get(xmlHttp, tURL); 				
			}
			function openFloat(pGameNumber)
			{
			    tQ = '?q=';
			    if(gOpenedFloat != '')
			    {
			    	tFloat = document.getElementById(gOpenedFloat);
			    	if(tFloat != null)
			    		document.getElementById(gOpenedFloat).style.display = 'none';
			    }
			    gOpenedFloat = 'floatSpace'+pGameNumber;
		 		var tURL = 'genLangenFloat.php' + tQ + Math.random() + '&id=' + pGameNumber;
		 		xmlHttp = GetXmlHttpObject(stateChangeHandlerFloat);
		 		xmlHttp_Get(xmlHttp, tURL); 
			}
		 	function stateChangeHandlerFloat()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 			var tStr = xmlHttp.responseText;
		 			//alert(tStr);
		 			var tArr=tStr.split("|"); 
		 			tId = tArr[0];
		 			tFloat = tArr[1];
					document.getElementById('float'+tId).innerHTML=tFloat;
					//$j("#float"+tId).html(tFloat);
					tLocation = document.location.href;
					tLocationArgs = tLocation.split('#');
					tLocation = tLocationArgs[0];
					document.location.href = tLocation+'#floatAnchor'+tId;
		 		}
		 	}
		 	function stateChangeHandlerFloatTest()
		 	{
		 		if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
		 		{
		 			var tStr = xmlHttp.responseText;
		 			alert(tStr);
		 			var tArr=tStr.split("|"); 
		 			tId = tArr[0];
		 			tFloat = tArr[1];
					document.getElementById('float'+tId).innerHTML=tFloat;
					tLocation = document.location.href;
					tLocationArgs = tLocation.split('#');
					tLocation = tLocationArgs[0];
					document.location.href = tLocation+'#floatAnchor'+tId;
		 		}
		 	}		 	
		 	document.all?document.attachEvent('onclick',checkFloat):document.addEventListener('click',checkFloat,false);
		 	function checkFloat(e) 
			{
				e?evt=e:evt=event;
				CSE=evt.target?evt.target:evt.srcElement;
				if(gOpenedFloat != '')
				{
					if (getObj(gOpenedFloat))
					{
						if (!isChild(CSE,getObj(gOpenedFloat)))
							document.getElementById(gOpenedFloat).style.display = 'none';
					}
				}
			}
			function get_team()
			{
				var teams = new Array(
				"Brazil",
				"England",
				"Argentina",
				"Sweden"
				);
				return teams[Math.round(Math.random()*teams.length)];
			}
			
			function submit()
			{
				var qstring = document.getElementById("qsstring").value;
				if (qstring.length > 0) 
				{
					window.open("http://www.tip-ex.com/quick_search.php?qsstring=" + qstring + "&referrer=" + window.location, "_blank");
				}
			
			}
			
	function xmlHttp_Post(xmlHttp, url, parameters) 
	{ 
      xmlHttp.open('POST', url, true);
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlHttp.setRequestHeader("Content-length", parameters.length);
      xmlHttp.setRequestHeader("Connection", "close");
      xmlHttp.send(parameters);
   }			
/* --- BoxOver ---
/* --- v 2.1 17th June 2006
By Oliver Bryant with help of Matthew Tagg
http://boxover.swazz.org */

if (typeof document.attachEvent!='undefined') {
   window.attachEvent('onload',init);
   document.attachEvent('onmousemove',moveMouse);
   document.attachEvent('onclick',checkMove); }
else {
   window.addEventListener('load',init,false);
   document.addEventListener('mousemove',moveMouse,false);
   document.addEventListener('click',checkMove,false);
}

var oDv=document.createElement("div");
var dvHdr=document.createElement("div");
var dvBdy=document.createElement("div");
var windowlock,boxMove,fixposx,fixposy,lockX,lockY,fixx,fixy,ox,oy,boxLeft,boxRight,boxTop,boxBottom,evt,mouseX,mouseY,boxOpen,totalScrollTop,totalScrollLeft;
boxOpen=false;
ox=10;
oy=10;
lockX=0;
lockY=0;

function init() {
	oDv.appendChild(dvHdr);
	oDv.appendChild(dvBdy);
	oDv.style.position="absolute";
	oDv.style.visibility='hidden';
	document.body.appendChild(oDv);	
}

function defHdrStyle() 
{
	dvHdr.style.fontWeight='bold';
	dvHdr.style.width='300px';
	dvHdr.style.fontFamily='arial';
	dvHdr.style.border='1px solid #A5CFE9';
	dvHdr.style.padding='3';
	dvHdr.style.fontSize='10pt';
	dvHdr.style.color='#4B7A98';
	dvHdr.style.background='#D5EBF9';
	dvHdr.style.filter='alpha(opacity=95)'; // IE
	dvHdr.style.opacity='0.95'; // FF
}

function defBdyStyle() 
{
	dvBdy.style.borderBottom='1px solid #A5CFE9';
	dvBdy.style.borderLeft='1px solid #A5CFE9';
	dvBdy.style.borderRight='1px solid #A5CFE9';
	dvBdy.style.width='300px';
	dvBdy.style.fontFamily='arial';
	dvBdy.style.fontSize='8pt';
	dvBdy.style.padding='3';
	dvBdy.style.color='#1B4966';
	dvBdy.style.background='#FFFFFF';
	dvBdy.style.filter='alpha(opacity=95)'; // IE
	dvBdy.style.opacity='0.95'; // FF
}

function checkElemBO(txt) {
if (!txt || typeof(txt) != 'string') return false;
if ((txt.indexOf('header')>-1)&&(txt.indexOf('body')>-1)&&(txt.indexOf('[')>-1)&&(txt.indexOf('[')>-1)) 
   return true;
else
   return false;
}

/*function scanBO(curNode) {
	  if (checkElemBO(curNode.title)) {
         curNode.boHDR=getParam('header',curNode.title);
         curNode.boBDY=getParam('body',curNode.title);
			curNode.boCSSBDY=getParam('cssbody',curNode.title);			
			curNode.boCSSHDR=getParam('cssheader',curNode.title);
			curNode.IEbugfix=(getParam('hideselects',curNode.title)=='on')?true:false;
			curNode.fixX=parseInt(getParam('fixedrelx',curNode.title));
			curNode.fixY=parseInt(getParam('fixedrely',curNode.title));
			curNode.absX=parseInt(getParam('fixedabsx',curNode.title));
			curNode.absY=parseInt(getParam('fixedabsy',curNode.title));
			curNode.offY=(getParam('offsety',curNode.title)!='')?parseInt(getParam('offsety',curNode.title)):10;
			curNode.offX=(getParam('offsetx',curNode.title)!='')?parseInt(getParam('offsetx',curNode.title)):10;
			curNode.fade=(getParam('fade',curNode.title)=='on')?true:false;
			curNode.fadespeed=(getParam('fadespeed',curNode.title)!='')?getParam('fadespeed',curNode.title):0.04;
			curNode.delay=(getParam('delay',curNode.title)!='')?parseInt(getParam('delay',curNode.title)):0;
			if (getParam('requireclick',curNode.title)=='on') {
				curNode.requireclick=true;
				document.all?curNode.attachEvent('onclick',showHideBox):curNode.addEventListener('click',showHideBox,false);
				document.all?curNode.attachEvent('onmouseover',hideBox):curNode.addEventListener('mouseover',hideBox,false);
			}
			else {// Note : if requireclick is on the stop clicks are ignored   			
   			if (getParam('doubleclickstop',curNode.title)!='off') {
   				document.all?curNode.attachEvent('ondblclick',pauseBox):curNode.addEventListener('dblclick',pauseBox,false);
   			}	
   			if (getParam('singleclickstop',curNode.title)=='on') {
   				document.all?curNode.attachEvent('onclick',pauseBox):curNode.addEventListener('click',pauseBox,false);
   			}
   		}
			curNode.windowLock=getParam('windowlock',curNode.title).toLowerCase()=='off'?false:true;
			curNode.title='';
			curNode.hasbox=1;
	   }
	   else
	      curNode.hasbox=2;   
}
*/

function scanBO(curNode) 
{
  var btext = curNode.getAttribute('hoverbox');
  if (checkElemBO(btext)) {
    curNode.boHDR=getParam('header',btext);
    curNode.boBDY=getParam('body',btext);
    curNode.boCSSBDY=getParam('cssbody',btext);      
    curNode.boCSSHDR=getParam('cssheader',btext);
    curNode.IEbugfix=(getParam('hideselects',btext)=='on')?true:false;
    curNode.fixX=parseInt(getParam('fixedrelx',btext));
    curNode.fixY=parseInt(getParam('fixedrely',btext));
    curNode.absX=parseInt(getParam('fixedabsx',btext));
    curNode.absY=parseInt(getParam('fixedabsy',btext));
    curNode.offY=(getParam('offsety',btext)!='')?parseInt(getParam('offsety',btext)):10;
    curNode.offX=(getParam('offsetx',btext)!='')?parseInt(getParam('offsetx',btext)):10;
    curNode.fade=(getParam('fade',btext)=='on')?true:false;
    curNode.fadespeed=(getParam('fadespeed',btext)!='')?getParam('fadespeed',btext):0.04;
    curNode.delay=(getParam('delay',btext)!='')?parseInt(getParam('delay',btext)):0;
    if (getParam('requireclick',btext)=='on') {
      curNode.requireclick=true;
      document.all?curNode.attachEvent('onclick',showHideBox):curNode.addEventListener('click',showHideBox,false);
      document.all?curNode.attachEvent('onmouseover',hideBox):curNode.addEventListener('mouseover',hideBox,false);
    }
    else {// Note : if requireclick is on the stop clicks are ignored         
      if (getParam('doubleclickstop',btext)!='off') {
        document.all?curNode.attachEvent('ondblclick',pauseBox):curNode.addEventListener('dblclick',pauseBox,false);
      }  
      if (getParam('singleclickstop',btext)=='on') {
        document.all?curNode.attachEvent('onclick',pauseBox):curNode.addEventListener('click',pauseBox,false);
      }
    }
    curNode.windowLock=getParam('windowlock',btext).toLowerCase()=='off'?false:true;
    btext='';
    curNode.hasbox=1;
   }
   else
      curNode.hasbox=2;
}

function getParam(param,list) {
	var reg = new RegExp('([^a-zA-Z]' + param + '|^' + param + ')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]');
	var res = reg.exec(list);
	var returnvar;
	if(res)
		return res[2].replace('[[','[').replace(']]',']');
	else
		return '';
}

function Left(elem){	
	var x=0;
	if (elem.calcLeft)
		return elem.calcLeft;
	var oElem=elem;
	while(elem){
		 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderLeftWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderLeftWidth);
		 x+=elem.offsetLeft;
		 elem=elem.offsetParent;
	  } 
	oElem.calcLeft=x;
	return x;
	}

function Top(elem){
	 var x=0;
	 if (elem.calcTop)
	 	return elem.calcTop;
	 var oElem=elem;
	 while(elem){		
	 	 if ((elem.currentStyle)&& (!isNaN(parseInt(elem.currentStyle.borderTopWidth)))&&(x!=0))
		 	x+=parseInt(elem.currentStyle.borderTopWidth); 
		 x+=elem.offsetTop;
	         elem=elem.offsetParent;
 	 } 
 	 oElem.calcTop=x;
 	 return x;
 	 
}

var ah,ab;
function applyStyles() {
	if(ab)
		oDv.removeChild(dvBdy);
	if (ah)
		oDv.removeChild(dvHdr);
	dvHdr=document.createElement("div");
	dvBdy=document.createElement("div");
	CBE.boCSSBDY?dvBdy.className=CBE.boCSSBDY:defBdyStyle();
	CBE.boCSSHDR?dvHdr.className=CBE.boCSSHDR:defHdrStyle();
	dvHdr.innerHTML=CBE.boHDR;
	dvBdy.innerHTML=CBE.boBDY;
	ah=false;
	ab=false;
	if (CBE.boHDR!='') {		
		oDv.appendChild(dvHdr);
		ah=true;
	}	
	if (CBE.boBDY!=''){
		oDv.appendChild(dvBdy);
		ab=true;
	}	
}

var CSE,iterElem,LSE,CBE,LBE, totalScrollLeft, totalScrollTop, width, height ;
var ini=false;

// Customised function for inner window dimension
function SHW() {
   if (document.body && (document.body.clientWidth !=0)) {
      width=document.body.clientWidth;
      height=document.body.clientHeight;
   }
   if (document.documentElement && (document.documentElement.clientWidth!=0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) {
      width=document.documentElement.clientWidth;   
      height=document.documentElement.clientHeight;   
   }   
   return [width,height];
}


var ID=null;
function moveMouse(e) {
   //boxMove=true;
	e?evt=e:evt=event;
	
	CSE=evt.target?evt.target:evt.srcElement;
	
	if (!CSE.hasbox) {
	   // Note we need to scan up DOM here, some elements like TR don't get triggered as srcElement
	   iElem=CSE;
	   while ((iElem.parentNode) && (!iElem.hasbox)) {
	      scanBO(iElem);
	      iElem=iElem.parentNode;
	   }	   
	}
	
	if ((CSE!=LSE)&&(!isChild(CSE,dvHdr))&&(!isChild(CSE,dvBdy))){		
	   if (!CSE.boxItem) {
			iterElem=CSE;
			while ((iterElem.hasbox==2)&&(iterElem.parentNode))
					iterElem=iterElem.parentNode; 
			CSE.boxItem=iterElem;
			}
		iterElem=CSE.boxItem;
		if (CSE.boxItem&&(CSE.boxItem.hasbox==1))  {
			LBE=CBE;
			CBE=iterElem;
			if (CBE!=LBE) {
				applyStyles();
				if (!CBE.requireclick)
					if (CBE.fade) {
						if (ID!=null)
							clearTimeout(ID);
						ID=setTimeout("fadeIn("+CBE.fadespeed+")",CBE.delay);
					}
					else {
						if (ID!=null)
							clearTimeout(ID);
						COL=1;
						ID=setTimeout("oDv.style.visibility='visible';ID=null;",CBE.delay);						
					}
				if (CBE.IEbugfix) {hideSelects();} 
				fixposx=!isNaN(CBE.fixX)?Left(CBE)+CBE.fixX:CBE.absX;
				fixposy=!isNaN(CBE.fixY)?Top(CBE)+CBE.fixY:CBE.absY;			
				lockX=0;
				lockY=0;
				boxMove=true;
				ox=CBE.offX?CBE.offX:10;
				oy=CBE.offY?CBE.offY:10;
			}
		}
		else if (!isChild(CSE,dvHdr) && !isChild(CSE,dvBdy) && (boxMove))	{
			// The conditional here fixes flickering between tables cells.
			if ((!isChild(CBE,CSE)) || (CSE.tagName!='TABLE')) {   			
   			CBE=null;
   			if (ID!=null)
  					clearTimeout(ID);
   			fadeOut();
   			showSelects();
			}
		}
		LSE=CSE;
	}
	else if (((isChild(CSE,dvHdr) || isChild(CSE,dvBdy))&&(boxMove))) {
		totalScrollLeft=0;
		totalScrollTop=0;
		
		iterElem=CSE;
		while(iterElem) {
			if(!isNaN(parseInt(iterElem.scrollTop)))
				totalScrollTop+=parseInt(iterElem.scrollTop);
			if(!isNaN(parseInt(iterElem.scrollLeft)))
				totalScrollLeft+=parseInt(iterElem.scrollLeft);
			iterElem=iterElem.parentNode;			
		}
		if (CBE!=null) {
			boxLeft=Left(CBE)-totalScrollLeft;
			boxRight=parseInt(Left(CBE)+CBE.offsetWidth)-totalScrollLeft;
			boxTop=Top(CBE)-totalScrollTop;
			boxBottom=parseInt(Top(CBE)+CBE.offsetHeight)-totalScrollTop;
			doCheck();
		}
	}
	
	if (boxMove&&CBE) {
		// This added to alleviate bug in IE6 w.r.t DOCTYPE
		bodyScrollTop=document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
		bodyScrollLet=document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft;
		mouseX=evt.pageX?evt.pageX-bodyScrollLet:evt.clientX-document.body.clientLeft;
		mouseY=evt.pageY?evt.pageY-bodyScrollTop:evt.clientY-document.body.clientTop;
		if ((CBE)&&(CBE.windowLock)) {
			mouseY < -oy?lockY=-mouseY-oy:lockY=0;
			mouseX < -ox?lockX=-mouseX-ox:lockX=0;
			mouseY > (SHW()[1]-oDv.offsetHeight-oy)?lockY=-mouseY+SHW()[1]-oDv.offsetHeight-oy:lockY=lockY;
			mouseX > (SHW()[0]-dvBdy.offsetWidth-ox)?lockX=-mouseX-ox+SHW()[0]-dvBdy.offsetWidth:lockX=lockX;			
		}
		
		oDv.style.left=((fixposx)||(fixposx==0))?fixposx:bodyScrollLet+mouseX+10+"px";
		//oDv.style.left=((fixposx)||(fixposx==0))?fixposx:bodyScrollLet+mouseX+ox+lockX+"px";
		oDv.style.top=((fixposy)||(fixposy==0))?fixposy:bodyScrollTop+mouseY+10+"px";		
		//oDv.style.top=((fixposy)||(fixposy==0))?fixposy:bodyScrollTop+mouseY+oy+lockY+"px";		
		
	}
}

function doCheck() {	
	if (   (mouseX < boxLeft)    ||     (mouseX >boxRight)     || (mouseY < boxTop) || (mouseY > boxBottom)) {
		if (!CBE.requireclick)
			fadeOut();
		if (CBE.IEbugfix) {showSelects();}
		CBE=null;
	}
}

function pauseBox(e) {
   e?evt=e:evt=event;
	boxMove=false;
	evt.cancelBubble=true;
}

function showHideBox(e) {
	oDv.style.visibility=(oDv.style.visibility!='visible')?'visible':'hidden';
}

function hideBox(e) {
	oDv.style.visibility='hidden';
}

var COL=0;
var stopfade=false;
function fadeIn(fs) {
		ID=null;
		COL=0;
		oDv.style.visibility='visible';
		fadeIn2(fs);
}

function fadeIn2(fs) {
		COL=COL+fs;
		COL=(COL>1)?1:COL;
		oDv.style.filter='alpha(opacity='+parseInt(100*COL)+')';
		oDv.style.opacity=COL;
		if (COL<1)
		 setTimeout("fadeIn2("+fs+")",20);		
}


function fadeOut() {
	oDv.style.visibility='hidden';
	
}

function isChild(s,d) {
	while(s) {
		if (s==d) 
			return true;
		s=s.parentNode;
	}
	return false;
}

var cSrc;
function checkMove(e) {
	e?evt=e:evt=event;
	cSrc=evt.target?evt.target:evt.srcElement;
	if ((!boxMove)&&(!isChild(cSrc,oDv))) {
		fadeOut();
		if (CBE&&CBE.IEbugfix) {showSelects();}
		boxMove=true;
		CBE=null;
	}
}

function showSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
}

function hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
   elements[i].style.visibility='hidden';
   }
}
/* --- Swazz Javascript Calendar ---
/* --- v 1.0 3rd November 2006
By Oliver Bryant
http://calendar.swazz.org */

function getObj(objID)
{
    if (document.getElementById) {return document.getElementById(objID);}
    else if (document.all) {return document.all[objID];}
    else if (document.layers) {return document.layers[objID];}
}

function checkClick(e) 
{
	e?evt=e:evt=event;
	CSE=evt.target?evt.target:evt.srcElement;
	if (getObj('fc'))
		if (!isChild(CSE,getObj('fc')))
			getObj('fc').style.display='none';
}

function isChild(s,d) {
	while(s) {
		if (s==d) 
			return true;
		s=s.parentNode;
	}
	return false;
}

function Left(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function Top(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
/*document.write('<div id="fc" style="position:absolute;width:162px;height:180px;display:none;z-index:100">');
document.write('<iframe frameborder="0" style="position:absolute;width:162px;height:180px;"></iframe>');
document.write('<div style="position:relative;width:162px;height:180px;">');*/
	
document.write('<table id="fc" style="position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #ABABAB;display:none" cellpadding=2>');
document.write('<tr><td style="cursor:pointer" onclick="csubm()"><img src="arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="arrowrightmonth.gif"></td></tr>');
document.write('<tr><td align=center style="background:#ABABAB;font:12px Arial">S</td><td align=center style="background:#ABABAB;font:12px Arial">M</td><td align=center style="background:#ABABAB;font:12px Arial">T</td><td align=center style="background:#ABABAB;font:12px Arial">W</td><td align=center style="background:#ABABAB;font:12px Arial">T</td><td align=center style="background:#ABABAB;font:12px Arial">F</td><td align=center style="background:#ABABAB;font:12px Arial">S</td></tr>');

/*document.write('<table id="fc2" style="position:absolute;border-collapse:collapse;background:#FFFFFF;border:1px solid #ABABAB;z-index:100" cellpadding=2>');
document.write('<tr><td style="cursor:pointer" onclick="csubm()"><img src="arrowleftmonth.gif"></td><td colspan=5 id="mns" align="center" style="font:bold 13px Arial"></td><td align="right" style="cursor:pointer" onclick="caddm()"><img src="arrowrightmonth.gif"></td></tr>');
document.write('<tr><td align=center style="background:#ABABAB;font:12px Arial">S</td><td align=center style="background:#ABABAB;font:12px Arial">M</td><td align=center style="background:#ABABAB;font:12px Arial">T</td><td align=center style="background:#ABABAB;font:12px Arial">W</td><td align=center style="background:#ABABAB;font:12px Arial">T</td><td align=center style="background:#ABABAB;font:12px Arial">F</td><td align=center style="background:#ABABAB;font:12px Arial">S</td></tr>');*/

for(var kk=1;kk<=6;kk++) {
	document.write('<tr>');
	for(var tt=1;tt<=7;tt++) {
		num=7 * (kk-1) - (-tt);
		document.write('<td id="v' + num + '" style="width:18px;height:18px">&nbsp;</td>');
	}
	document.write('</tr>');
}
document.write('</table>');
/*document.write('</div></div>');*/

document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick,false);


// Calendar script
var now = new Date;
var sccm=now.getMonth();
var sccy=now.getFullYear();
var ccm=now.getMonth();
var ccy=now.getFullYear();

var updobj;
function lcs(ielem) 
{
	updobj=ielem;
	pos = findPos(ielem);
	getObj('fc').style.left = pos['x']+'px';
	getObj('fc').style.top = (pos['y']+20)+'px';
	tObj = getObj('fc');
	getObj('fc').style.display='';
	
	// First check date is valid
	curdt=ielem.value;
	curdtarr=curdt.split('-');
	isdt=true;
	for(var k=0;k<curdtarr.length;k++) 
	{
		if (isNaN(curdtarr[k]))
			isdt=false;
	}
	if (isdt&(curdtarr.length==3)) 
	{
		ccm=curdtarr[1]-1;
		ccy=curdtarr[0];
		prepcalendar(curdtarr[2],curdtarr[1]-1,curdtarr[0]);
	}
	
}

function evtTgt(e)
{
	var el;
	if(e.target)el=e.target;
	else if(e.srcElement)el=e.srcElement;
	if(el.nodeType==3)el=el.parentNode; // defeat Safari bug
	return el;
}
function EvtObj(e){if(!e)e=window.event;return e;}
function cs_over(e) {
	evtTgt(EvtObj(e)).style.background='#FFCC66';
}
function cs_out(e) {
	evtTgt(EvtObj(e)).style.background='#C4D3EA';
}
function cs_click(e) 
{
	tValue = calvalarr[evtTgt(EvtObj(e)).id.substring(1,evtTgt(EvtObj(e)).id.length)];
	updobj.value=tValue;
	getObj('fc').style.display='none';
	location.href='allList2.php?menu='+getParam('menu')+'&time='+tValue;
}

var mn=new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
var mnn=new Array('31','28','31','30','31','30','31','31','30','31','30','31');
var mnl=new Array('31','29','31','30','31','30','31','31','30','31','30','31');
var calvalarr=new Array(42);

function f_cps(obj) {
	obj.style.background='#C4D3EA';
	obj.style.font='10px Arial';
	obj.style.color='#333333';
	obj.style.textAlign='center';
	obj.style.textDecoration='none';
	obj.style.border='1px solid #6487AE';
	obj.style.cursor='pointer';
}

function f_cpps(obj) {
	obj.style.background='#C4D3EA';
	obj.style.font='10px Arial';
	obj.style.color='#ABABAB';
	obj.style.textAlign='center';
	obj.style.textDecoration='line-through';
	obj.style.border='1px solid #6487AE';
	obj.style.cursor='default';
}

function f_hds(obj) {
	obj.style.background='#FFF799';
	obj.style.font='bold 10px Arial';
	obj.style.color='#333333';
	obj.style.textAlign='center';
	obj.style.border='1px solid #6487AE';
	obj.style.cursor='pointer';
}

// day selected
function prepcalendar(hd,cm,cy) 
{
	now=new Date();
	sd=now.getDate();
	td=new Date();
	td.setDate(1);
	td.setFullYear(cy);
	td.setMonth(cm);
	cd=td.getDay();
	getObj('mns').innerHTML=mn[cm]+ ' ' + cy;
	marr=((cy%4)==0)?mnl:mnn;
	for(var d=1;d<=42;d++) 
	{
		f_cps(getObj('v'+parseInt(d)));
		if ((d >= (cd -(-1))) && (d<=cd-(-marr[cm]))) {
			//dip=((d-cd < sd)&&(cm==sccm)&&(cy==sccy));
			dip = false;
			htd=((hd!='')&&(d-cd==hd));
			if (dip)
				f_cpps(getObj('v'+parseInt(d)));
			else if (htd)
				f_hds(getObj('v'+parseInt(d)));
			else
				f_cps(getObj('v'+parseInt(d)));

			getObj('v'+parseInt(d)).onmouseover=(dip)?null:cs_over;
			getObj('v'+parseInt(d)).onmouseout=(dip)?null:cs_out;
			getObj('v'+parseInt(d)).onclick=(dip)?null:cs_click;
			
			getObj('v'+parseInt(d)).innerHTML=d-cd;	
			//calvalarr[d]=''+(d-cd)+'/'+(cm-(-1))+'/'+cy;
			tMonth = (cm-(-1));
			tDay = (d-cd);
			if(tMonth < 10)
				tMonth = '0'+tMonth;
			if(tDay < 10)
				tDay = '0'+tDay;

			calvalarr[d]=''+cy+'-'+tMonth+'-'+tDay;
		}
		else {
			getObj('v'+d).innerHTML='&nbsp;';
			getObj('v'+parseInt(d)).onmouseover=null;
			getObj('v'+parseInt(d)).onmouseout=null;
			getObj('v'+parseInt(d)).style.cursor='default';
			}
	}
}

prepcalendar('',ccm,ccy);
//getObj('fc'+cc).style.visibility='hidden';

function caddm() {
	marr=((ccy%4)==0)?mnl:mnn;
	
	ccm+=1;
	if (ccm>=12) {
		ccm=0;
		ccy++;
	}
	cdayf();
	prepcalendar('',ccm,ccy);
}

function csubm() {
	marr=((ccy%4)==0)?mnl:mnn;
	ccm-=1;
	if (ccm<0) 
	{
		ccm=11;
		ccy--;
	}
	cdayf();
	prepcalendar('',ccm,ccy);
}

function cdayf() 
{
	if ((ccy>sccy)|((ccy==sccy)&&(ccm>=sccm)))
	{
		return;
	}
	else 
	{
		ccy=sccy;
		//ccm=sccm;
		sccm=ccm;
		//cfd=scfd;
	}
}
