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($.trim(frm.emailid.value)=='' || $.trim(frm.pass.value)=='') {
		alert('Please enter your Email Id and Password');
		return false;
	} else {
		if(!isEmail($.trim(frm.emailid.value))) {
			alert('Invalid Email Id');
			return false;
		} else {
			return true;
		}
	}
}

function NewsForm() {
	var isError = false;
  var errorMessage = "";
  var frm = document.news;
  
 	
  if($.trim(frm.email.value) == ""){
  	isError = true;
  	errorMessage +='\n  Email!';
  	
  } else {
  	
  	if(!isEmail($.trim(frm.email.value))){
  	isError = true;
  	errorMessage +='\n Invalid Email!';
  	}
  }
  
  if(!isError) {
    var dns_process_url = 'index.php?stub=Home&action=AjaxDnsCheck';
    var data =  { email: frm.email.value } 
    jQuery.post(dns_process_url, data, function(response) {
      
      if(response != 'true') {
        alert(response);
      } else {
        document.news.submit();
      }
    });
    
    
  } else {
    
     alert('Missing required fields:\n' + errorMessage);
     
   }
   
  
}

var qf_seen = false;
// var qf_timer = setTimeout( "qf_tickle()", 15000);

function qf_tickle() {
  if( qf_seen == true ) {
    clearTimeout( qf_timer);
  } else {
    toggle_quote_form();
  }
}


// Slides the Instant Price Quote form back and forth.
// refer http://docs.jquery.com/Effects/animate#paramsdurationeasingcallback
function toggle_quote_form() {
  
  o = $('#quote_form_holder');
  t = $('#toggle_zone');
  duration = 'medium';
  
  if( o.css('left') == '-502px' ) { 
    // show the form

    qf_seen = true; // set this true so that we don't tickle the user...
    
    // this is the html when expanded
    t_htm  = '<a href="javascript:void(0);" onclick="javascript:toggle_quote_form();" ';
    t_htm += 'title="Push the form back">';
    t_htm += '<img class="getQuote-close" src="images/spacer.gif" border="0" /></a>';   
    
    
    o.animate( 
      {left: '0px'}, 
      duration, 
      'linear',
      t.html( t_htm )
    );
    
  } else {
    
    // hide the form
    
    // the open form html when collapsed ..  this is the default state.
    t_htm = '<a href="javascript:void(0);" onclick="javascript:toggle_quote_form();" ';
    t_htm += 'title="">';
    t_htm += '<img class="getQuote" src="images/spacer.gif" border="0" /></a>';
    
    o.animate( 
      {left: '-502px'}, 
      duration, 
      'linear',
      t.html( t_htm )
    ); 

  } // end if( o.css('left') == '-500px' )

} // end function toggle_quote_form()


/*
// This enables the quote form to sail along the scrolling .. didn't look too good - need to do some easing stuff.
// commenting out for now 10/11/2009 3:14:54 PM
$(window).scroll( function() {
  o = $('#quote_form_holder');
  t = $(window).scrollTop();
  o.css('top', 100 + t);  
});
*/

function toggle_display(div_id) {
  $('#'+div_id).toggle("slow");
}


//function toggle_display(div_id){
//  
//  if(div_id == 'date_internet') {
//    
//    $('#'+div_id).show("slow");
//    
//     if(div_id == 'internet_service') $('#'+div_id).show("slow");
//     else $('#internet_service').hide("slow");
//     
//             
//  } else {
//    
//    $('#date_internet').hide("slow");
//  }
//    
//       
//      
//  
//  if(div_id == 'voice') $('#'+div_id).show("slow");
//  else $('#voice').hide("slow");
//  
//  
//  if(div_id == 'both_voice_internet') $('#'+div_id).show("slow");
//  else $('#both_voice_internet').hide("slow");
//    
//  
//}



