function bookmarkSite(){
    if (window.sidebar) // firefox
      window.sidebar.addPanel(document.title, document.location.href, "");
       else if(window.opera && window.print){ // opera
       var elem = document.createElement('a');
       elem.setAttribute('href',document.location.href);
       elem.setAttribute('title',document.title);
       elem.setAttribute('rel','sidebar');
       elem.click();
    }
      else if(document.all){// ie
      window.external.AddFavorite(window.location.href.replace(/(.*)\?.*/, "$1"), document.title);
    }
  }


function Set_Cookie( name, value, expires, path, domain, secure )
{
  // set time, it's in milliseconds
  var today = new Date();
  today.setTime( today.getTime() );

  /*
  if the expires variable is set, make the correct
  expires time, the current script below will set
  it for x number of days, to make it for hours,
  delete * 24, for minutes, delete * 60 * 24
  */
  if ( expires )
  {
  expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );

  document.cookie = name + "=" +escape( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  ( ( path ) ? ";path=" + path : "" ) +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
  // first we'll split this cookie up into name/value pairs
  // note: document.cookie only returns name=value, not the other components
  var a_all_cookies = document.cookie.split( ';' );
  var a_temp_cookie = '';
  var cookie_name = '';
  var cookie_value = '';
  var b_cookie_found = false; // set boolean t/f default f

  for ( i = 0; i < a_all_cookies.length; i++ )
  {
    // now we'll split apart each name=value pair
    a_temp_cookie = a_all_cookies[i].split( '=' );


    // and trim left/right whitespace while we're at it
    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

    // if the extracted name matches passed check_name
    if ( cookie_name == check_name )
    {
      b_cookie_found = true;
      // we need to handle case where cookie has no value but exists (no = sign, that is):
      if ( a_temp_cookie.length > 1 )
      {
        cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
      }
      // note that in cases where cookie is initialized but no value, null is returned
      return cookie_value;
      break;
    }
    a_temp_cookie = null;
    cookie_name = '';
  }
  if ( !b_cookie_found )
  {
    return null;
  }
}


// Show the drop down menu
function openMenu(id)
{
  if (document.getElementById(id).style.display != 'block'){
    document.getElementById(id).style.display = "block";
  }
}

// hide the drop down menu
function closeMenu(id)
{
  if (document.getElementById(id).style.display != 'none'){
    document.getElementById(id).style.display = "none";
  }
}

// highlight the drop down menu choice when mouse over
function highlightChoice(id, background_color, anchor_color)
{
  if (background_color == "") {
    background_color = "#999999";
  }
  if (anchor_color == "") {
    anchor_color = "#FFFFFF";
  }
  document.getElementById(id).style.backgroundColor = background_color;
  var anchor = document.getElementById(id).getElementsByTagName('a');
  anchor[0].style.color = anchor_color;
}

// drop down menu choice back to normal style when mouse out
function deselectChoice(id, background_color, anchor_color)
{
  if (background_color == "") {
    background_color = "#CCCCCC";
  }
  if (anchor_color == "") {
    anchor_color = "#000000";
  }
  document.getElementById(id).style.backgroundColor = background_color;
  var anchor = document.getElementById(id).getElementsByTagName('a');
  anchor[0].style.color = anchor_color;
}

function selectSearch()
{
  if (document.getElementById('google1').checked || document.getElementById('google2').checked) {
    document.getElementById('google_search_box').style.display = 'block';
    document.getElementById('local_search_box').style.display = 'none';
    document.getElementById('local2').checked = false;
    document.getElementById('google2').checked = false;
    document.getElementById('google1').checked = true;
  }
  else {
    document.getElementById('google_search_box').style.display = 'none';
    document.getElementById('local_search_box').style.display = 'block';
    document.getElementById('google1').checked = false;
    document.getElementById('local1').checked = false;
    document.getElementById('local2').checked = true;
  }
}

function swapSearch(layer_id){
  if(layer_id == 'local_search_box'){
    document.getElementById('google_search_box').style.display = 'none';
    document.getElementById('local_search_box').style.display = 'block';
  }else{
    document.getElementById('google_search_box').style.display = 'block';
    document.getElementById('local_search_box').style.display = 'none';
  }
}

function cursorToPointer(obj, color, underline) {
  obj.style.cursor = 'pointer';
  var anchor = obj.getElementsByTagName('a')
  anchor[0].style.color = color;
  if (underline == true) {
    anchor[0].style.textDecoration = 'underline';
  }
  else {
    anchor[0].style.textDecoration = 'none';
  }
}

function redirect(url) {
  window.location = url;
}

//Change the href to the tracking page with its target url, or change the link back after tracking
function changeLink(obj, url) {
  obj.href = url;
}

//request a page on background
function requestPage(url) {
  var xhr=false;
  try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
  catch (e)
  {
    try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
    catch (e2)
    {
      try {  xhr = new XMLHttpRequest();     }
      catch (e3) {  xhr = false;   }
    }
  }

  xhr.open('GET', url,  false);
  xhr.send(null);
}

//popup window and go to the input url
function popupWindowToUrl(url, _width, _height) {
  if (_width == '') { _width = 600; }
  if (_height == '') { _height = 500; }
  window.open(url,"Window1","menubar=no,width="+_width+",height="+_height+",toolbar=no");
}

//show or hide the drop down arrow image when mouseover
function displayHideArrow(obj, imgUrl, showBG) {
  var div = obj.getElementsByTagName('div');
  if (showBG) {
    div[0].style.background = "transparent url("+imgUrl+") no-repeat right top";
  }
  else {
    div[0].style.background = "transparent none";
  }
}

// Change Background Image
function changeBackground(obj, backgroundColor, imgUrl, repeatX, repeatY, leftRight, topBottom) {
  var repeat = "";
  if (repeatX && repeatY) {
    repeat = "repeat";
  }
  else if (repeatX) {
    repeat = "repeat-x";
  }
  else if (repeatY) {
    repeat = "repeat-y";
  }
  else {
    repeat = "no-repeat";
  }

  obj.style.background = ""+backgroundColor+" url("+imgUrl+") "+repeat+" "+leftRight+" "+topBottom+"";
}

function regenerateCaptcha()
{
  document.getElementById('captcha_image').src='/captcha.php?r='+Math.floor(Math.random()*100000000);
  return false;
}

function changeCursor(obj, cursor_style) {
  obj.style.cursor = cursor_style;
}

function changeAction(formId, formAction) {
  document.getElementById(formId).action = formAction;
}

function clearTxtboxText(txtboxId, txtToClear, clearAnyway, wordColor) {
  txtBox = document.getElementById(txtboxId);

  if (txtToClear == '') {
    txtToClear == 'Google Search';
  }

  if (txtBox.value == txtToClear && !clearAnyway) {
    txtBox.value = '';
    txtBox.focus();
  }
  else if(clearAnyway) {
    txtBox.value = '';
    txtBox.focus();
  }
  if(wordColor != '') {
    txtBox.style.color = wordColor;    
  }
}
function addText(theField)
{
if (theField.value == '')
theField.value = theField .defaultValue;
}
function changeImgBorderStyle(ImgId, borderColor, borderPx) {
  imgElement = document.getElementById(ImgId);
  imgElement.style.border = borderPx + "px solid " + borderColor;
  //imgElement.style.border = "2px solid red";
}

function emailValidation(email_id)
{
  var email = document.getElementById(email_id);
  var err = '';
  var filter  = /^([a-zA-Z0-9_\.\-!#$%&'\*+\/=?^`{}\|\~])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,})$/;
  if(email.value == '' ||email.value == null ){
    err = err+'Please fill in your email.\r\n';
    alert(err);
    email.focus;
    return false;
  }else if(!(filter.test(email.value))){
    err = err+'Please input a valid email address.\r\n';
    alert(err);
    email.focus;
    return false;
  }
}
