

function setColor(tr, clr){
if(document.getElementById||(document.all && !(document.getElementById))){
  tr.style.backgroundColor=clr;
  }
}

function WarnDeleteLineItem(blah, the_url) {
  if (confirm("Are you sure to delete " + ((blah)? "' " + blah + " '" : "") + "?")) {
    top.location.href=the_url;
  }
}

// begin:: infamous Ajax Page loader.
function loadPanel(panel_id, content_url) {

  var page_request = false;
  if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest();
  else if (window.ActiveXObject){ // if IE
    try {
      page_request = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
      try {
        page_request = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e){}
    }
  }
  else
    return false;
  page_request.onreadystatechange=function(){
    loadpage(page_request, panel_id)
  }
  page_request.open('GET', content_url, true)
  page_request.send(null)
}



function loadpage(page_request, panel_id){
  if(page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(panel_id).innerHTML=page_request.responseText
}
// end:: infamous Ajax Page loader.


// this toogles the lyr display and changes the content of lyrToggle
//
function toggleLayer(lyr, lyrToggle, state) {

  oLyr = document.getElementById(lyr);
  oLyrToggle = document.getElementById(lyrToggle);

  the_html = "<a class=\"link4\" href=\"javascript:toggleLayer('" + lyr + "', '" + lyrToggle + "',";

  oLyr.style.display = state;
  if(state == 'none') {
    the_html +=  "'inline');\"><img src=\"images/show.gif\" border=\"0\"> Show</a>";
  } else {
    the_html +=  "'none');\"><img src=\"images/hide.gif\" border=\"0\"> Hide</a>";
  }

  oLyrToggle.innerHTML = the_html;

}


/***** This function is written to add a object
        Function defined on 27-02-2006 : PK *****/

function getObj(n,d) {

  var p,i,x;

  if(!d)

      d=document;


  if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);

  }



  if(!(x=d[n])&&d.all)

      x=d.all[n];



  for(i=0;!x&&i<d.forms.length;i++)

      x=d.forms[i][n];



  for(i=0;!x&&d.layers&&i<d.layers.length;i++)

      x=getObj(n,d.layers[i].document);



  if(!x && d.getElementById)

      x=d.getElementById(n);



  return x;

}


function MailPage(sURL) {
  sMail = "mailto:?subject=A page that might interest you.&body=Hi, Please check this page " + escape(sURL);
  document.location.href = sMail;
}


function slideLogin() {

  o = document.getElementById('loginLyr');
  s = o.style.display;
  o.style.display = (s == 'none') ? 'inline' : 'none';

}

function isEmail(email) {
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/; // valid

  return (!reg1.test(email) && reg2.test(email))
}

function ValidateLogin(frm){
  if(frm.name.value=='' || frm.keyCode.value=='') {
    alert('Please enter your Keyword and Keycode');
    return false;
  } else {
    if(!isEmail(frm.emailid.value)) {
      alert('Invalid Email Id');
      return false;
    } else {
      return true;
    }
  }
}



// jcarousel start
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(3);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(3);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

