// bookmarksite

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}










// top navigation menu

function show_sub_menu(element){
	document.getElementById(element).style.visibility = 'visible';
	if(element=='menu_share'){
	document.getElementById(element).style.width = '300px';
	document.getElementById(element).style.backgroundPosition='85px 0px';
	}
	if(element=='menu_learn'){
	document.getElementById(element).style.width = '600px';
	document.getElementById(element).style.backgroundPosition='395px 0px';
	}
	if(element=='menu_benefit'){
	document.getElementById(element).style.width = '410px';
	document.getElementById(element).style.backgroundPosition='325px 0px';
	}
}
function hide_sub_menu(element){
	document.getElementById(element).style.visibility = 'hidden';
}

function toggleLayer2(showlayerID,hidelayerID1,hidelayerID2){
	document.getElementById(hidelayerID1).style.display ='none';
	document.getElementById(hidelayerID2).style.display ='none';
	document.getElementById(showlayerID).style.display ='block';
}
function changetabcolor(currenttab,othertab1,othertab2,othertab3,othertab4,othertab5){
	document.getElementById(currenttab).className ='current';
	document.getElementById(othertab1).className ='none';
	document.getElementById(othertab2).className ='none';
	document.getElementById(othertab3).className ='none';
	document.getElementById(othertab4).className ='none';
	document.getElementById(othertab5).className ='none';
}

function toggleLayer3(layerID){
	if(document.getElementById(layerID)){
	var elements = new Array();
	elements = document.getElementById('tab_div').getElementsByTagName('div');
	//alert(elements.length);
	for (var i=0;i<(elements.length);i++) {
		document.getElementById(elements[i].id).style.display ='none';
	}
	document.getElementById(layerID).style.display ='block';
}
else{
	alert("No Match Found....!");
}
}



// tool tips for form elements

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

//document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
//document.write('<img id="dhtmlpointer" src="../images/arrow2.gif">') //write out pointer image

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 ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

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-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

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 hide_content(obj, val, def_val)
{
	if(val==def_val)
		obj.value = "";
	
}
function hide_search_content(obj, val)
{
	if(val.search(/search/i)!='-1'){
		obj.value = "";
	}
}
function show_content(obj, val, def_val)
{
	if(val=="")
		obj.value = def_val;
	
}


// function for triming a string

 function Trim(TRIM_VALUE){

	if(TRIM_VALUE.length < 1){

		return "";

	}

	TRIM_VALUE = RTrim(TRIM_VALUE);

	TRIM_VALUE = LTrim(TRIM_VALUE);

	if(TRIM_VALUE==""){

		return "";

	}

	else{

		return TRIM_VALUE;

	}

} 

function RTrim(VALUE){

	var w_space = String.fromCharCode(32);

	var v_length = VALUE.length;

	var strTemp = "";

	if(v_length < 0){

		return"";

	}

	var iTemp = v_length -1;



	while(iTemp > -1){

		if(VALUE.charAt(iTemp) == w_space){

		}

		else{

			strTemp = VALUE.substring(0,iTemp +1);

			break;

		}

		iTemp = iTemp-1;



	} //End While

	return strTemp;



} //End Function



function LTrim(VALUE){

	var w_space = String.fromCharCode(32);

	if(v_length < 1){

		return"";

	}

	var v_length = VALUE.length;

	var strTemp = "";



	var iTemp = 0;



	while(iTemp < v_length){

		if(VALUE.charAt(iTemp) == w_space){

		}

		else{

			strTemp = VALUE.substring(iTemp,v_length);

			break;

		}

		iTemp = iTemp + 1;

	} //End While

	return strTemp;

} //End Function




function select_all(CheckValue, form_name, val){
	var objCheckBoxes = document.forms[form_name].elements[val];
	if(!objCheckBoxes)
	return;

	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}




//animated collapse login
function showlayer(layer){
/* alert(document.getElementById(layer)); */
	var myLayer=document.getElementById(layer);
	if(myLayer.style.display=="none" || myLayer.style.display==""){
		myLayer.style.display="block";
	} else { 
		myLayer.style.display="none";
		}
}






function charRemaining(tField, nField, maxAllowed) {
	if (tField.value.length > maxAllowed) {
			tField.value = tField.value.substring(0, maxAllowed);
	}
	document.getElementById(nField).innerHTML = maxAllowed - tField.value.length;
}

