// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
		
var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""
  function searchvalid()
  {    
    //if(document.getElementById('searchKeywords').value=="")
    if (Trim(document.getElementById('searchKeywords').value) == "")
    {
    alert("Please enter search text.");
    document.getElementById('searchKeywords').focus();
    return false;
    }
  }
  
  function LTrim( value ) 
{
    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");
}
// Removes ending whitespaces
function RTrim( value ) 
{
    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function Trim( value ) 
{
  return LTrim(RTrim(value));
}


function ddrivetip(thetext, thewidth, thecolor){
	if (ns6||ie){
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
	tipobj.innerHTML=thetext
	enabletip=true
	return false
	}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-10
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-10

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
	if (ns6||ie){
	enabletip=false
	tipobj.style.visibility="hidden"
	pointerobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
	}
}

document.onmousemove=positiontip

function follow_feedback_display(e)
{
	var dId = document.getElementById('feedback_popup');
	Effect.toggle('feedback_popup');
	var errId = document.getElementById('feedback_err');
	errId.innerHTML = '';
	dId.style.top = ( e.clientY + document.documentElement.scrollTop - 700 ) + "px" ;
	//// dId.style.left = ( e.clientX + document.documentElement.scrollLeft - 100 ) + "px";
	dId.style.left = "120px";
}

function set_email_user_id_subject(val)
{
  //alert('here '+val);
	var dId = document.getElementById('feedback_id');
	dId.value = val ;
  
  var dId1 = document.getElementById('subject1');
  var stringVal = String(val);
  sbj = "[AMZDPS:"+stringVal+"]";
	dId1.value =  sbj;
}

function set_sender(val1)
{
	var dId = document.getElementById('feedback_by');
	dId.value = val1 ;
}

function email_user_display(e)
{
	var dId = document.getElementById('lb_email_user_popup');
	/* dId.style.display = ""; */
	Effect.toggle('lb_email_user_popup');
	var errId = document.getElementById('feedback_err');
	errId.innerHTML = '';
	dId.style.top = ( e.clientY + document.documentElement.scrollTop - 200 ) + "px" ;
	//// dId.style.left = ( e.clientX + document.documentElement.scrollLeft - 100 ) + "px";
	dId.style.left = "200px";
}