//helper function to create the form
function getNewSubmitForm(url, target){
 var submitForm = document.createElement("FORM");
// document.body.appendChild(submitForm);
 submitForm.method = "POST";
 submitForm.action= url;
 submitForm.target= target;
 return submitForm;
}

//helper function to add elements to the form
function createNewFormElement(inputForm, elementName, elementValue){
 var newElement = document.createElement("<input name='"+elementName+"' type='hidden'>");
 inputForm.appendChild(newElement);
 newElement.value = elementValue;
 return newElement;
}

//function that creates the form, adds some elements
//and then submits it
function createFormAndSubmit(url, target){
 var submitForm = getNewSubmitForm(url, target);
// createNewFormElement(submitForm, "field1", "somevalue");
// createNewFormElement(submitForm, "field2", "somevalue");
//alert ('url = '+ submitForm.action);
 submitForm.submit();
}
/*
//alert ('before submit');
createFormAndSubmit ( 'http://www.manogat.com/node/14710', 'cframe' );
//alert ('after submit');
*/
//document.getElementById ('cframe').src = 'http://www.manogat.com/node/14710';
//document.frames['cframe'].location.href = 'http://www.manogat.com/node/14710';

var manoDiv = null;
var commentDiv = null;
var commentUrl = '';
function isJsEnabled() {
  if (typeof document.jsEnabled == 'undefined') {
    // Note: ! casts to boolean implicitly.
    document.jsEnabled = !(
     !document.getElementsByTagName ||
     !document.createElement        ||
     !document.createTextNode       ||
     !document.documentElement      ||
     !document.getElementById);
  }
  return document.jsEnabled;
}

function addLoadEvent(func) {
  var oldOnload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  }
  else {
    window.onload = function() {
      oldOnload();
      func();
    }
  }
}

if (isJsEnabled()) {
  addLoadEvent(manoProcOnLoad);
}

function manoProcOnLoad ()
{

  var script=document.getElementById('script_urchin');

  if (script)
  {
    script.parentNode.removeChild(script);
  }
  script=document.createElement('SCRIPT');
  script.id='script_urchin';
//  script.src='/fetch_cw.php/?cwid='+cwid+'&rand='+Math.random();
  script.src='http://www.google-analytics.com/urchin.js';
//  script.src='http://www.manogat.com/dev/urchin.js';
//alert ( 'url = '+script.src);
  var head=document.getElementsByTagName('HEAD')[0];
  head.appendChild(script);


//var lnk = '<a href="http://www.manogat.com/node/12034">आपल्या प्रतिक्रिया, टिप्पणी, प्रतिसाद येथे स्वागतार्ह आहेत.</a><br/>(प्रतिसाद लिहिण्यासाठी सदस्यत्वाची आवश्यकता नाही.)';
var lnk = '(प्रतिसाद लिहिण्यासाठी सदस्यत्वाची आवश्यकता नाही.)';

manoDiv = document.getElementById('manoDiv');
if ( manoDiv )
{
   manoDiv.parentNode.removeChild(manoDiv);
}

manoDiv = document.createElement('DIV');
manoDiv.id = 'manoDiv';
manoDiv.innerHTML = lnk;
var nodeDiv = null;
//var body = document.getElementsByTagName('BODY')[0];
var divs = document.getElementsByTagName('DIV');
for ( var i=0; i<divs.length; i++ )
{
   if (/node/.test(divs[i].className))
   {
      nodeDiv = divs[i];
      break;
   }
}

if ( nodeDiv )
{
//nodeDiv.innerHTML = nodeDiv.innerHTML.replace(/ऱ्/g, 'र्‍');
nodeDiv.parentNode.appendChild(manoDiv);

commentDiv = document.createElement('DIV');
commentDiv.id = 'commentDiv';
nodeDiv.parentNode.appendChild(commentDiv);
var l ="http://www.manogat.com/cmtfy/node";
l += '?rand='+Math.random();
l += '&title='+encodeURIComponent(document.title);
//alert('l = ' + l );
/*
var e=document.createElement("iframe"),h={name:"cframe",src:l,frameBorder:0,width:1000,height:10000,marginWidth:"0",marginHeight:"0",hspace:"0",vspace:"0",allowTransparency:"true",scrolling:"no"};for(var n in h){e.setAttribute(n,h[n])}
commentDiv.appendChild(e);
*/
var iftxt = '<iframe id="cframe" src="'+l+'" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%"></iframe>';
commentDiv.innerHTML = iftxt;
//commUrl = 'http://www.manogat.com/node/12048';
//commUrl = document.URL.replace ( 'node', 'comment');
//commUrl += '?rand='+Math.random();
//HTTPGet(commUrl, renderComm, null);

}

_uacct = "UA-2905887-1";
setTimeout('invokeUrchin()',2000);
//urchinTracker();

//  var script=document.getElementById('script_cookie');

//  if (script)
//  {
//    script.parentNode.removeChild(script);
//  }
//  script=document.createElement('SCRIPT');
//  script.id='script_cookie';
//  script.src='http://www.manogat.com/misc/cookie.js';
//alert ( 'url = '+script.src);
//  var head=document.getElementsByTagName('HEAD')[0];
//  head.appendChild(script);


//setTimeout('txtImg()',2000);

}

function renderComm (text, callbackParam)
{
//alert ( document.URL);
text = text.replace ( '_COMMENTS_HERE_', '<h3>वाचकांचे प्रतिसाद</h3>');
var lnk = '<p><a href="http://www.manogat.com/node/12034">आपल्या प्रतिक्रिया, टिप्पणी, प्रतिसाद येथे स्वागतार्ह आहेत.</a><br/>(प्रतिसाद लिहिण्यासाठी सदस्यत्वाची आवश्यकता नाही.)</p>';
commentDiv.innerHTML = text+lnk;
}

function invokeUrchin()
{
urchinTracker();
}



function dev_digit ( inStr )
{
inStr = inStr.replace(eval("/1/g"), "१");
inStr = inStr.replace(eval("/2/g"), "२");
inStr = inStr.replace(eval("/3/g"), "३");
inStr = inStr.replace(eval("/4/g"), "४");
inStr = inStr.replace(eval("/5/g"), "५");
inStr = inStr.replace(eval("/6/g"), "६");
inStr = inStr.replace(eval("/7/g"), "७");
inStr = inStr.replace(eval("/8/g"), "८");
inStr = inStr.replace(eval("/9/g"), "९");
inStr = inStr.replace(eval("/0/g"), "०");
return inStr;
}


