
jQuery.preloadImages = function() {
	for (var i = 0; i < arguments.length; i++)
		{
			jQuery("<img>").attr("src", arguments[i]);
		}
}

$.preloadImages('/images/master.png', '/images/bg_bleu.png', '/images/bg_cyan.png', '/images/bg_vert.png', '/images/bg_bleu2.png', '/images/news_tab_1.gif', '/images/news_tab_2.gif', '/images/news_tab_3.gif', '/images/news_tab_4.gif');

function doLog()
{
	$("body").append('<img src="/dolog.php?scrh='+screen.height+'&amp;scrw='+screen.width+'&amp;scrd='+screen.colorDepth+'">');
	//$.post("/dolog.php", {scrh:screen.height,scrw:screen.width,scrd:screen.colorDepth});
}


var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
  if (document.getElementById)
  {     // DOM level 1 browsers: IE 5+, NN 6+
    this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {     // IE 4
    this.obj = document.all[name];
    this.style = document.all[name].style;
  }
  else if (document.layers)  {                  // NN 4
    this.obj = document.layers[name];
    this.style = document.layers[name];
  }
}
function toggle(chunk) {
  var item = new getObj(chunk);

  if(item.style.display == '')
  {
    item.style.display = 'none';
  } else {
    item.style.display = '';
  }

}

function PopQuestionnaire()
{
  window.open("http://www.soreltracyregion.net/questionnaire.html" ,"questionnairepopup","width=800,height=600,toolbar=no,location=no,menubar=no,directories=no,scrollbars=yes,resizeable=no,status=no,left=50,top=50");
}

function popup_previsu_carte()
{
  window.open("http://www.soreltracyregion.net/extranet/carte.php?mode=previsu" ,"precartepopup","width=600,height=460,toolbar=no,location=no,menubar=no,directories=no,scrollbars=yes,resizeable=no,status=no,left=50,top=50");
}

function SoumettreComm()
{
  window.open("/soumission/index.php" ,"souscommpopup","width=720,height=400,toolbar=no,location=no,menubar=no,directories=no,scrollbars=no,resizeable=no,status=no,left=50,top=50");
}
function WebCam()
{
  window.open("http://www.soreltracyregion.net/webcam/index.php" ,"webcamstrpopup","width=700,height=500,toolbar=no,location=no,menubar=no,directories=no,scrollbars=no,resizeable=no,status=no,left=50,top=50");
}

function WebCamCurling()
{
  window.open("http://www.soreltracyregion.net/webcam/curling.php" ,"webcamcurlingpopup","width=940,height=750,toolbar=no,location=no,menubar=no,directories=no,scrollbars=no,resizeable=no,status=no");
}

function WebCamCurlingGrosPlan()
{
  window.open("http://www.soreltracyregion.net/webcam/curling_grosplan.php" ,"webcamcurlinggppopup","width=720,height=740,toolbar=no,location=no,menubar=no,directories=no,scrollbars=no,resizeable=no,status=no");
}

function FestiCamPopup(nom)
{
	window.open("http://www.soreltracyregion.net/webcam/festicam/index.php/"+nom ,"festicampopup","width=1000,height=700,toolbar=no,location=no,menubar=no,directories=no,scrollbars=no,resizeable=no,status=no,left=50,top=50");
}

function CJSODirect() {
  window.open('http://www.cjso.qc.ca/realdirect/radio.html','CJSODirect','top=50,left=50,screenx=50,screeny=50,scrollbars=no,width=256,height=230');
}


function insereTag(id, Tag, fTag)
{  
	ajtBBCode(Tag, fTag, id);
}
function insereTxt(id, txt)
{
	ajtTexte(txt, id);
}  

function ajtTexte(txt,id)
{
	var obj = document.getElementById(id), sel;
	obj.focus();
	if (document.selection && document.selection.createRange)
	{
		sel = document.selection.createRange();
		if (sel.parentElement()==obj) //si sel est dans obj
			sel.text = sel.text+txt;
	}
	else if(String(typeof obj.selectionStart)!="undefined")
	{

		var ss = obj.scrollTop;
		sel1 = obj.value.substr(0, obj.selectionStart);
		sel2 = obj.value.substr(obj.selectionEnd);

		obj.value = sel1 + txt + sel2;

		selPos = txt.length + sel1.length;
		obj.setSelectionRange(sel1.length, selPos);
		obj.scrollTop = ss;
	
	}
	else obj.value += txt;
	obj.focus();
}

function ajtBBCode(Tag, fTag, id)
{
	var obj = document.getElementById(id), sel;
	obj.focus();
	if (document.selection && document.selection.createRange)
	{
		sel = document.selection.createRange();
		if (sel.parentElement()==obj)//si sel est dans obj
			sel.text = Tag+sel.text+fTag;
	}
	else if(String(typeof obj.selectionStart)!="undefined")
	{
		var ss = obj.scrollTop;
		sel1 = obj.value.substr(0, obj.selectionStart);
		sel2 = obj.value.substr(obj.selectionEnd);
		sel = obj.value.substr(obj.selectionStart, obj.selectionEnd - obj.selectionStart);
		obj.value = sel1 + Tag + sel + fTag + sel2;

		selPos = Tag.length + sel1.length + sel.length + fTag.length;
		obj.setSelectionRange(sel1.length, selPos);
		obj.scrollTop = ss;
	
	}
	else obj.value+=Tag+fTag;
	obj.focus();
}

