var border = null;
var id_user = null;
function getNavigatorSize()
{	
	
	 var viewportwidth;
	 var viewportheight;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined')
	 {
	      viewportwidth = window.innerWidth,
	      viewportheight = window.innerHeight
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	 else if (typeof document.documentElement != 'undefined'
	     && typeof document.documentElement.clientWidth != 'undefined' 
	    	 && document.documentElement.clientWidth != 0)
	 {
	       viewportwidth = document.documentElement.clientWidth,
	       viewportheight = document.documentElement.clientHeight
	 }
	 
	 // older versions of IE
	 
	 else
	 {
	       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
	       viewportheight = document.getElementsByTagName('body')[0].clientHeight
	 }
	 var a = Array();
	 a['width']=viewportwidth; 
	 a['height']=viewportheight
	 return a;

}
function replace()
{
	var border=document.getElementById('border_friend');
	if(border!=null){
	var user_screen=getNavigatorSize();
		border.style.left = (user_screen['width'] - 990) / 2 +127+ "px";	
		border.style.bottom = (user_screen['height'] - 200) / 2 + "px";
	}
		
}
function addBlock(ident, text, parent)
{
	var newBlock = document.createElement('div');
	if(ident!= "")newBlock.setAttribute('id', ident);
	if(text != "")newBlock.innerHTML = text;
	
	parent.appendChild(newBlock);
	return newBlock;

	
}

function addTextArea(ident, rows, cols, text, parent)
{
	var newTA = document.createElement('textarea');
	if(ident != "")newTA.setAttribute('id', ident);
	if(rows != "")newTA.setAttribute('rows', rows);
	if(cols != "")newTA.setAttribute('cols', cols);
	if(text != "")newTA.innerHTML = text;
	
	parent.appendChild(newTA);
	
	return newTA;
}

function addParagraphe(ident, text, parent)
{
	var newParagraphe= document.createElement('p');
	if(ident != "")newParagraphe.setAttribuute('id', ident);
	newParagraphe.innerHTML = text;
	
	parent.appendChild(newParagraphe);
	
	return newParagraphe;
}

function addInput(ident, type, value, onclick, parent)
{
	var newInput = document.createElement('input');
	if(ident != "")newInput.setAttribute('id', ident);
	newInput.setAttribute('type', type);
	newInput.setAttribute('value', value);
	if(onclick != "")newInput.onclick = onclick;
	
	parent.appendChild(newInput);
	
	return newInput;
}

function draw2()
{
	
	var body = document.getElementsByTagName('body')[0];	
	  border = addBlock("border_friend", "", body);
			   addBlock("header_friend", "", border);//Creation du header
		
	var content = addBlock("content_friend", "", border);//Creation du contenu de la box	
	var ins = addBlock("ins", "", content);	
			  addParagraphe("", "Ajouter un commentaire", ins);//Creation du text descriptif
			  addTextArea("comment", "15", "60", "", ins);//Creation du textarea permetant de recevoir le commentaire
	var posInput = addParagraphe("", "", ins);
				   addInput("submit", "button", "Valider", makeRequest2, posInput);
				   addInput("reset", "button", "Annuler", myc_add_comment_close, posInput);
				   addBlock("footer_friend", "", border);//Creation du footer
		
		// positionnement du block ....
		user_screen=getNavigatorSize();
		border.style.left = (user_screen['width'] - 990) / 2 +127+ "px";	
		border.style.bottom = (user_screen['height'] - 200) / 2 + "px";

}

function myc_open2(link)
{
	id_user = link;

	document.getElementById('commentLink').style.visibility='hidden';
	draw2();
	
}
function myc_add_comment_close(e)
{
	try{ window.location.reload();}
	catch(e)
	{};
	try{	window.refresh();}
	catch(e)
	{};
	
	while (border.firstChild) {
  		border.removeChild(border.firstChild);
	}
	
	var body = document.getElementsByTagName('body')[0];
	
	body.removeChild(border);
	document.getElementById('commentLink').style.visibility='visible';
	

}
 

function makeRequest2(){
	
	var postData = "comment=" + document.getElementById('comment').value;
	YAHOO.util.Connect.asyncRequest('POST', id_user, {success:myc_add_comment_close}, postData);
}

function myc_show_hide_comments()
{
	var elt = document.getElementById('blank');
	if(elt.style.display=='none')
		elt.style.display='block';
	else 
		elt.style.display = 'none';
}



