//Function to open pop up window
function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}
//=============iView===========================================
//Function to add smiley
function AddSmileyIcon(imagePath){	
	window.opener.frames.iView.focus();								
	window.opener.frames.iView.document.execCommand('InsertImage', false, imagePath);
	window.close();
}

function doBackCol(bCol) {
    if(bCol != '')
      	window.opener.frames.iView.document.execCommand('backcolor', false, bCol);
//	  ColorBar.style.display = 'none';
//	   viewColor = 1;
		window.close();
  }
  
 function doForeCol(fCol) {
      if(fCol != '')
      window.opener.frames.iView.document.execCommand('forecolor', false, fCol);
//	  ColorBar2.style.display = 'none';
//	   viewColor2 = 1;
	   window.close();
  }
  //===========================================================
  
  //Function to clear form
function ResetForm(){

	if (window.confirm('Are you sure you want to reset the form?')){
		frames.iView.focus();
	 	frames.iView.document.body.innerHTML = ''; 
	 	return true;
	 } 
	 return false;		
}
  
  //Function to open preview post window
function OpenPreviewWindow(targetPage, formName){
	
	//now = new Date  
	var htmlCode = iView.document.body.innerHTML; 
    document.ans_frm.answer.value = htmlCode; 
	//Open the window first 	
   	openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=625,height=400')
   		
   	//Now submit form to the new window
   	formName.action = targetPage //+ "?answer=" + htmlCode//now.getTime();	

	formName.target = "preview";
	formName.submit();
}

//=========================================
function pickuser(symbol) {
  if (window.opener && !window.opener.closed) {
   //window.opener.document.main.document.execCommand('insertimage', false, symbol);
	//window.opener.document.ans_frm.file_name.value = symbol;
	window.opener.document.form1.g_avatar.value = symbol;
	window.opener.document.avatar.src = symbol;
	//window.opener.document.ans_frm.uname.focus();
  	window.close();
	}
}

function doForeCol1(fCol) {
	if(fCol != '')
      	iView.document.execCommand('forecolor', false, fCol);
	YAHOO.example.container.panel2.hide();
}

function doBackCol1(bCol) {
	if(bCol != '')
      iView.document.execCommand('backcolor', false, bCol);
	YAHOO.example.container.panel1.hide();
}
function AddSmileyIcon1(imagePath){	
	window.opener.frames.iView.focus();								
	window.opener.frames.iView.document.execCommand('InsertImage', false, imagePath);
	window.close();
}
