function Trim(s)
{
	var tempStr1, s1 ,tmpStr2 ;
	s1 = s;
	tempStr1 = lTrim(s1);
	tempStr2 = rTrim(tempStr1);
	return tempStr2 ;
}	

function rTrim(s)
{
	var temp="";
	tempStr="";
	temp=s;
	var len=s.length;
	
	if(len>0)
	{
		for(i=len;i > 0;i--)
		{
			if(temp.charAt(i-1)!=" ")
				break;
		}
		
		k=0;
		for(j=0;j<i;j++)
		{
			tempStr=tempStr+temp.charAt(j);
			k=k+1;
		}
		return tempStr;
	}
	else
		return tempStr;
}

function lTrim(s)
{
	var temp="";
	tempStr="";
	temp=s;
	var len=s.length;
	
	if(len>0)
	{
		for(i=0;i<len;i++)
		{
			if(temp.charAt(i)!=" ")
				break;
		}
		
		k=0;
		for(j=i;j<len;j++)
		{
			tempStr=tempStr+temp.charAt(j);
			k=k+1;
		}
		return tempStr;
	}
	else
		return tempStr;
}


function isEmail(email) {
  var flag =false ;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) > -1)
	  {
		 flag =true ;
		}
      
	else
	  {
		flag = false;
		break;
	  }
  }
if(flag)
{
	var theStr=email;
		var atIndex = theStr.indexOf('@');
		var dotIndex = theStr.indexOf('.', atIndex);
		var flag = true;
		theSub = theStr.substring(0, dotIndex+1)

		if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length))
		{
			//alert("Invalid E-mail ID");
			flag = false;
		}
		else
		{ 
			flag = true;
		}

}
  return flag;
}

/*#################################################################*/
//XMLhttp variable will hold the XMLHttpRequest object
var xmlhttp = false;
	if(window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	} else if(window.ActiveXObject) {

		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}


function DivOpenClose(DivIdOpen,DivIdClose,FieldName,FieldValue)
{
		document.getElementById(DivIdClose).style.display='none';
		document.getElementById(DivIdOpen).style.display='block';
		document.getElementById(FieldName).value=FieldValue;

}

function hideMe()
{
document.getElementById('msg').style.display="none";
}


function QuickInvite()
{
	if(document.getElementById('Invite').style.display=='block')
	{
		document.getElementById("Invitation").value="1";
		document.getElementById("NotInvite").style.display="block";
		document.getElementById("Invite").style.display="none";
	}
	else
	{
		document.getElementById("Invitation").value="0";
		document.getElementById("NotInvite").style.display="none";
		document.getElementById("Invite").style.display="block";
	}
}

//quick add i have got more info
function quickmoreinfo(siteurl,formnames)
{
	var  objFrm=formnames;

	var fName=eval("document." + objFrm +".txtfname.value");
	var fName1=Trim(fName);
	
	var lName=eval("document." + objFrm +".txtlname.value");
	var lName1=Trim(lName);
	
	var email=eval("document." + objFrm +".txtemail.value");
	var email1=Trim(email);

	var Invitation=eval("document." + objFrm +".Invitation.value");
	var Invite=Trim(Invitation);
		
	if(fName1=='' || fName1=='First Name')
	{
		alert('First Name Should not be blank!');
		return false;
	}
	
	if(lName1=='' || lName1=='Last Name')
	{
		alert('Last Name Should not be blank!');
		return false;
	}

	if(email1=='')
	{
		alert('Email Should not be blank!');
		return false;
	}
	else
	{
		if (!isEmail(email1))
		{
		alert("E-mail is not correct");
		return false;
		}
	}
	
	quickvalidate(fName1,lName1,email1,siteurl,Invite);
}

//quick contacr check quick_contactcheck.php
function quickvalidate(Fname,Lname,strmailuser,siteurl,Invite) 
{
		//alert(strmailuser)
//		var  objFrm=formname;
		
		var usertype='';
		var url = siteurl+'/phpfiles/quick_contactcheck.php?qmail=' + strmailuser + '&fname=' + Fname + '&lname=' + Lname;
			xmlhttp.open('GET', url, true);
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
				{
					
					var result=new Array();
					result=eval(xmlhttp.responseText);
					//alert(xmlhttp.responseText);
					if(result[0][0]=='87')
					{
						var GreyBoxUrl = siteurl+'/user/?action=homescreen&do=addcontactinfoscreen&newcon=quick&contemail='+result[0][3]+ '&fname=' + Fname + '&lname=' + Lname + '&Invite=' + Invite + '&usertype=' + usertype;
						
						GB_show('Add New Contact',GreyBoxUrl,660,800);
						//document.frmquickadd.action='quickadd.php';
						//document.frmquickadd.submit();
					}
					else
					{
				    var url = siteurl+'/user/?action=homescreen&contemail='+result[0][3]+'&msg=' + result[0][2];
					window.location.href=url;
					}		
						
				}
			};
			xmlhttp.send(null);
		
			
}

//Function for Select ALL 

function select_all(theClickBox,CheckBoxName) {
var theArray=document.getElementsByName('CHKDEL[]');
	if ( document.getElementById(theClickBox).checked ) {
		for (i = 0; i < theArray.length; i++) {
			theArray[i].checked = true ;
		}
		if ( typeof theArray[0] != 'object' ) {
			theArray.checked = true;
		}

	} else 
		{
			for (i = 0; i < theArray.length; i++) {
				theArray[i].checked = false ;
			}
			if ( typeof theArray[0] != 'object' ) {
				theArray.checked = false;
			}
	}
return true;	
}

function selectAll(theClickBox,CheckBoxName) {

var theArray=document.getElementsByName(CheckBoxName+'[]');
	if ( document.getElementById(theClickBox).checked ) {
		for (i = 0; i < theArray.length; i++) {
			theArray[i].checked = true ;
		}
		if ( typeof theArray[0] != 'object' ) {
			theArray.checked = true;
		}

	} else 
		{
			for (i = 0; i < theArray.length; i++) {
				theArray[i].checked = false ;
			}
			if ( typeof theArray[0] != 'object' ) {
				theArray.checked = false;
			}
	}
return true;	
}
function ShowDivs(Divid)
{
if(document.getElementById(Divid).style.display=='none')
document.getElementById(Divid).style.display="block";
else
document.getElementById(Divid).style.display="none";
}

function AddContact(siteurl)
{
document.frmUser.action= siteurl+'/user/?action=homescreen&do=addcontactinfo';
document.frmUser.submit();
}


function AddInNewConnection(siteurl,fName1,lName1,email1,usertype)
{
	if(usertype === undefined)
	usertype='';

//	quickvalidate(fName1,lName1,email1,siteurl,1);
var GreyBoxUrl = siteurl+'/user/?action=homescreen&do=addcontactinfoscreen&newcon=addcontact&contemail='+email1+ '&fname=' + fName1 + '&lname=' + lName1 + '&usertype=' + usertype + '&Invite=1';
GB_show('Add New Contact',GreyBoxUrl,660,800);

}

function AddInNewConnectionHomescreen(siteurl,fName1,lName1,email1,usertype)
{
	if(usertype === undefined)
	usertype='';

//	quickvalidate(fName1,lName1,email1,siteurl,1);
var GreyBoxUrl = siteurl+'/user/?action=homescreen&do=addcontactinfoscreen&newcon=newcon&contemail='+email1+ '&fname=' + fName1 + '&lname=' + lName1 + '&usertype=' + usertype + '&Invite=1';
GB_show('Add New Contact',GreyBoxUrl,660,800);

}

function popup(url,w,h,id)
{
	x = 125;
	y = 100;

window.open(url,id,'width='+w+',height='+h+',resizable=no,scrollbars=yes,left='+x+',top='+y+',screenX='+x+',screenY='+y+',status=yes');
}



var db   = new Array();
 db[0] = new Array();//This is actual data which will be shown
 db[1] = new Array(); //Search parameters
 db[2] = new Array();//Display String
 db[3] = new Array();//Click function
 db[4] = new Array();//Searched Click function
var selected=0;

function SendTo(e){

var t1=document.getElementById('txtsearch').value;

if(Trim(t1)=='')
{ 
	document.getElementById('search').style.display='none';
	//document.getElementById('search').innerHTML="Enter Value For Search";
	//alert('Please enter value for search!');
	return false;
}
else
{
if(!e){var e = window.event};
code = e.keyCode;
var objDiv = document.getElementById("search");

if(code != 38 && code != 40 && code != 13){
	document.getElementById('search').style.display='block';
	document.getElementById('search').innerHTML="Loading...";

	var url = 'http://www.nexodex.com/phpfiles/searchresult.php?t1=' + t1;
	var xmlhttp = false;
	if (window.XMLHttpRequest) 
	{
	 xmlhttp = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
	 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	//confirm('Loding Data');
	xmlhttp.open('GET', url, false);
	setTimeout(function() 
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
			
			if(xmlhttp.responseText != "")
			{
				 var cnt=xmlhttp.responseText.split("-/-");
				 db[0]=cnt[0].split("*/");
			     db[3]=cnt[1].split("-/*");
				 
if(db[0]!='')
				 objDiv.style.display='block';
else
					 objDiv.style.display='none';

				 objDiv.scrollTop = 0;
        
				  objDiv.innerHTML = '';
				  for(var i= 1 ; i < db[0].length;i++)
				  {
					   var objChDiv = document.createElement('div');
					   objChDiv.setAttribute('id' , "ch_"+i);
					   objDiv.appendChild(objChDiv);
					   objChDiv.innerHTML=db[0][i];
					   objChDiv.className = 'cDiv';
					   
					   if(i == 1)
					   {
							//objChDiv.className = 'cDivSel';
							//var selected=0;
							
					   }
					   
					   objChDiv.onmouseover = function(){mouseMoveSelection(objDiv , this)};
					   //objChDiv.onclick = function(){clickTk(objDiv)};
				  }
			}
			else{
				alert(xmlhttp.responseText);
			document.getElementById('search').style.display='none';
			}
		}
	},500);
	
	xmlhttp.send(null);
}

	if(code == 38)
     {
          moveByKeyPress('up' , objDiv);
     }
     else if(code == 40)
     {
          moveByKeyPress('down' , objDiv);
     }
     else if(code == 13)
     {
		  moveByKeyPress('enter' , objDiv);
		  
     }

 }

}

function moveByKeyPress(type , objDiv)
  {
     
	 
     
     var obj;
     if(type == 'up')
     {
          if(i != 0)
          {
			 // alert(selected)
              selected = selected - 1;
              temp = "ch_"+selected;
             
              obj = document.getElementById(temp);
              mouseMoveSelection(objDiv , obj);
              objDiv.scrollTop = 30;
          }
     }
     else if(type == 'down')
     {
          if(selected != db[0].length)
          {
               selected = selected+1;
              temp = "ch_"+selected;
              obj = document.getElementById(temp);
              if(obj)
              {
                    mouseMoveSelection(objDiv , obj);
                    objDiv.scrollTop = objDiv.scrollHeight - objDiv.clientHeight;
              }
              
              
          }    
               
     }
     else if(type == 'enter')
     {
         
     if(selected!=0){
        eval(db[3][selected]);
	 }else{
	document.frmmesearch.action='/user/?action=homescreen&do=SearchList';
	document.frmmesearch.submit();
	 }    
     }
     
     
     
  }
 
  
  function tt()
  {
	var txtsearch=document.getElementById("txtsearch").value;
	if(txtsearch!=''){
	var act='/user/?action=homescreen&do=SearchList&txtsearch='+txtsearch;
	window.location.href=act;
	}else
		alert('Search Field Should not be blank!');
	return false;
  }

  function mouseMoveSelection(objDiv , obj)
  {
    
     var chNd = objDiv.childNodes;
     
     for(var i=0 ; i<chNd.length;i++)
     {
          chNd[i].className = "cDiv";
          
     }
     
     obj.className = 'cDivSel';
     
  }

  function mousedown()
{
	if (document.getElementById("search"))
	{
		document.getElementById("search").style.display="none";
	}
}
 function formSub(act)
  {
window.location.href=act;
  }
 
 function invite(id)
{
document.getElementById("Invitation_"+id).value="1";
document.getElementById("NotInvite"+id).style.display="block";
document.getElementById("Invite"+id).style.display="none";
}

function Notinvite(id)
{
document.getElementById("Invitation_"+id).value="";
document.getElementById("NotInvite"+id).style.display="none";
document.getElementById("Invite"+id).style.display="block";
}

function select_all_Invite(theClickBox,formnames){
	var theArray1=document.getElementById("chechboxcounter").value;
	var  objfrm=formnames;
	if ( theClickBox.checked ) 
	{
		for (i = 0; i < theArray1; i++) {
		Notinvite(i);
		}
	}
	else
	{
		for (i = 0; i < theArray1; i++) {
		invite(i);
		}

	}
}

function select_all_Inport123(theClickBox,formnames) {
		var theArray=document.getElementsByName('email_array[]');
		Selval= new Array();
		var Selval12= new Array();
		var  objfrm=formnames;
	
			if ( theClickBox.checked ) {
				
				for (i = 0; i < theArray.length; i++) {
					theArray[i].checked = true ;
					//theArray[i].disabled = true;
				}
				if ( typeof theArray[0] != 'object' ) {
					theArray.checked = true;
				}
				document.getElementById('all1').checked = true;
				Selval=(document.getElementById("clickedValuesALL").value).split(',');
				submitCheckValues();
				//addOptgroup123(objfrm.tagname, '','');
				addremoveTags123(objfrm);
			
			} else 
				{
					if(Selval=="")
						Selval='';

					submitCheckValues();
					addOptgroup123(objfrm.tagname, '','');
				

					for (i = 0; i < theArray.length; i++) {
						theArray[i].checked = false ;
						//theArray[i].disabled = false;
					}
					if ( typeof theArray[0] != 'object' ) {
						theArray.checked = false;
					}
					document.getElementById('all1').checked = false;
			}
	return true;	
}

function AddtagsPlaxo123(formnames)
{

var checkTrue=false;
var i, objfrm=eval(formnames);
//var checkboxlgth=document.getElementById('chechboxcounter').value;
var clickvalues1=document.getElementById("clickedValues").value;
var clickvalues=clickvalues1.split(',');

//alert(clickvalues);
//alert(clickvalues.length);

if(clickvalues != "")
{
 var selectedvalue=formnames.tagname.value;

 
 if(selectedvalue != "")
 {
 var ind = formnames.tagname.selectedIndex;
 var selectedText=formnames.tagname.options[ind].text;
 
 var splitvalue=selectedvalue.split("/-");

 if(splitvalue[0]=='Add')
 {
 
 	
 	for(i=0; i < clickvalues.length; i++)
 	{
 		
 		//alert(clickvalues[i]);
 			if(clickvalues[i] !="")
 			{
 			var ckvalues=clickvalues[i];
 		
 			var vv=ckvalues;
			//	alert(vv);
 			Divvalue='';
 			Tagsvalue='';
 			if(document.getElementById("Tags_"+vv).value == "")
 			{
 			Divvalue='';
 			Tagsvalue='0';
 			}
 			else
 			{
 			var dd=document.getElementById("TagsDivs_"+vv).innerHTML.split(", ");
 			
 			if(dd.length>0)
 			{
 			for(k=0;k<dd.length;k++)
 			{
 			if(dd[k] != selectedText)
 			Divvalue=Divvalue+dd[k]+", ";
 			}
 			}
 			
 			var ddvalue=document.getElementById("Tags_"+vv).value.split(",");
						
			if(ddvalue.length>0)
			{
			for(k=0;k<ddvalue.length;k++)
			{

			if(ddvalue[k] != splitvalue[1] && ddvalue[k] !="" && ddvalue[k] !="0")
			{
			//alert(splitvalue[1]);
			//alert(ddvalue[k]);
			Tagsvalue=Tagsvalue+ddvalue[k]+",";
			}
			}
			Tagsvalue=(Tagsvalue.substring(0,Tagsvalue.length-1));
 			}
 			//alert(Tagsvalue);
 			}
 			
 			document.getElementById("Tags_"+vv).value=Tagsvalue+","+splitvalue[1];
 			document.getElementById("TagsDivs_"+vv).innerHTML=Divvalue+selectedText;;
 			}
 			
 			
 		
 		
 	}
 
   }	
   else
   {
   
   var i, objfrm=eval(formnames);
   	
   	
   	for(i=0; i < clickvalues.length; i++)
   	{
   		
   			if(clickvalues[i] !="")
   			{
   			var ckvalues=clickvalues[i];
   			
   			var vv=ckvalues;
   			Divvalue='';
   			Tagsvalue='';
   			if(document.getElementById("Tags_"+vv).value == "")
   			{
   			Divvalue='';
   			Tagsvalue='';
   			}
   			else
   			{
   			var dd=document.getElementById("TagsDivs_"+vv).innerHTML.split(", ");
   			
   			if(dd.length>0)
   			{
   			for(k=0;k<dd.length;k++)
   			{
   			
   			if(dd[k] != selectedText)
   			Divvalue=Divvalue+dd[k]+", ";
   			}
   			Divvalue=(Divvalue.substring(0,Divvalue.length-2));
   			}
   			
   			var ddvalue=document.getElementById("Tags_"+vv).value.split(",");
   			
 			if(ddvalue.length>0)
 			{
 			for(k=0;k<ddvalue.length;k++)
 			{
 
 			if(ddvalue[k] != splitvalue[1] && ddvalue[k] !="" && ddvalue[k] !="0")
 			Tagsvalue=Tagsvalue+ddvalue[k]+",";
 			}
 			Tagsvalue=(Tagsvalue.substring(0,Tagsvalue.length-1));
 			}
   			}
   			document.getElementById("Tags_"+vv).value=Tagsvalue;
   			document.getElementById("TagsDivs_"+vv).innerHTML=Divvalue;
   			}
   			
   			
   		
   		
 	}
   
   
   
   }
 }
 addremoveTags123(formnames);
 }
 else
 {
 alert("Please Select atleast one contact from a list");
 addOptgroup123(objfrm.tagname, '','');
 }
}

function addremoveTags123(formnames)
{
var ckvalues=new Array();
var i, objfrm=formnames;
var j=0,checkTrue=false;
//var checkboxlgth=document.getElementById('chechboxcounter').value;
var clickvalues1=document.getElementById("clickedValues").value;
var clickvalues=clickvalues1.split(',');

//alert(clickvalues1);
for(i=0; i < clickvalues.length; i++)
{
	var ckvalues1=0;
	
		if(clickvalues[i] !="")
   		{
   		var ckvalues1=clickvalues[i];
		
		if(document.getElementById("Tags_"+ckvalues1).value != "")
		ckvalues[j]=document.getElementById("Tags_"+ckvalues1).value;
		j++;
		}
	
}

//alert(ckvalues)
if(clickvalues != "" )
{
	
	if(ckvalues !="")
	{
		var theQuery=ckvalues;
	
	
		var url = appPath+'/phpfiles/getTagsNameByAjax.php?q=' + theQuery;
		//alert(url);


		var xmlhttp = false;
		if (window.XMLHttpRequest) 
		{
		 xmlhttp = new XMLHttpRequest();
		} 
		else if (window.ActiveXObject) 
		{
		 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	
		xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = function() 
	{
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		//var =objfrm.tagname.length;
		var OptionCount=xmlhttp.responseText.split("/*-");
		var Optionvalues=OptionCount[0].split(",");
		var Tagsvalues=OptionCount[1].split(",");
		addOptgroup123(objfrm.tagname, Tagsvalues,Optionvalues);
		
	 }
	};
		xmlhttp.send(null);
}
else
 {
 addOptgroup123(objfrm.tagname, '','');
 }

}
else
 {
// alert("Please Select atleast one contact from a list");
 addOptgroup123(objfrm.tagname, '','');
 }
}


function addOptgroup123(oSelect, oData,Optionvalues)
{
var browserName=navigator.appName; 
var browserVer=parseInt(navigator.appVersion); 


var optgroups = 
document.getElementsByTagName("optgroup");
// oSelect.style.width ="100%";
// loop through the optgroup array
 for(var i = 0; i < optgroups.length; i++)
  {
    // take 1 optgroup at a time
    var optgroup = optgroups[i];
    
    // extract the label
    var label = optgroup.label;
	 if((label == "Remove Tags"))
	  {
   //removeContents(optgroup);
   /// oSelect.removeChild(optgroup);
   if(browserName=="Microsoft Internet Explorer" && browserVer >4)
   optgroup.removeNode(true);
	  else
oSelect.removeChild(optgroup);
	}
  }
	

  
  var returnValue = null;
  var i = 0;

//alert(oData);
    
  if(oSelect && Optionvalues.length > '0' && oData.length > 0)
  {
//  alert(Optionvalues.length);
   oOptgroup ="<select id='tagname' class='inputbox' name='tagname' style='width:200px;' onchange='AddtagsPlaxo123(this.form)'><option value=''>--------Select Tags--------</option><OPTGROUP label='Apply Tags'>";
 //  alert(oOptgroup);
     for(kl = 0; kl < Optionvalues.length; kl=kl+2)
        {
         if(Optionvalues[kl] !="")
          oOptgroup += "<OPTION value='"+Optionvalues[kl]+"'>"+Optionvalues[kl+1]+"</OPTION>";
        }
//alert(oOptgroup);

    oOptgroup += "</OPTGROUP><OPTGROUP label='Remove Tags'>";
  
  
    for(l = 0; l < oData.length; l=l+2)
    {
     if(oData[l] !="")
      oOptgroup += "<OPTION value='"+oData[l]+"'>"+oData[l+1]+"</OPTION>";
    }
    
  oOptgroup+= '</OPTGROUP></select>';   
 // alert(oOptgroup);

  document.getElementById("TagDisp").innerHTML= oOptgroup;
   
  }
//return returnValue;

}
var Selval=new Array();	
function chkv()
{
Selval=(document.getElementById("clickedValues").value).split(',');
}

function selValue(id,formnames)
{
	var  objfrm=formnames;
	if(Selval==''){ Selval=new Array();	}	
	if(document.getElementById("email_array"+id).checked ==true)
	{
	Selval.push(id);
	}
	else
	{
		var cval=","+Selval.join(",")+",";
		var nval=cval.replace(","+id+",",",")
		Selval=	nval.split(",");
		Selval.pop();
		Selval.shift();
	}
	submitCheckValues();
	addremoveTags123(objfrm);
	return true;
}

function selValue123(id,formnames)
{
	var  objfrm=formnames;
	if(Selval==''){ Selval=new Array();	}	
	if(document.getElementById("email_array"+id).checked ==true)
	{
	Selval.push(id);
	}
	else
	{
		var cval=","+Selval.join(",")+",";
		var nval=cval.replace(","+id+",",",")
		Selval=	nval.split(",");
		Selval.pop();
		Selval.shift();
	}
	submitCheckValues();
	addremoveTags123(objfrm);
	return true;
}
function submitCheckValues()
{
document.getElementById("clickedValues").value=Selval;
}


function subAmt(){
var val=document.getElementById('subname').value;
	if(val != ''){
			var url = appPath+'/phpfiles/getsubamt.php?q=' + val;
			var xmlhttp = false;
			if (window.XMLHttpRequest) 
			{
			 xmlhttp = new XMLHttpRequest();
			} 
			else if (window.ActiveXObject) 
			{
			 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.open('GET', url, true);
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					document.getElementById('SubDivs').style.display='block';
					//alert(xmlhttp.responseText);
					document.getElementById('SubDivs').innerHTML = xmlhttp.responseText;
					
				} 
			};
			xmlhttp.send(null);
}
else{
//document.getElementById('SubDivs').style.display='none';
document.getElementById('SubDivs').innerHTML="<br><div class='fl' style='width:23px'>&nbsp</div><div class='w10 fl' style='font-size:10px;'>Size:</div><div class='w25 fl'><select name='subtype' id='subtype' style='width:200px;' onchange='openSubDiv1()' disabled><option value=''>--Select Size---</option></select></div></br>";
}
}
function openSubDiv(id){
document.getElementById('showS').style.display='none';
document.getElementById('showM').style.display='none';
document.getElementById('showL').style.display='none';
document.getElementById('show'+id).style.display='block';
}


function openSubDiv1(){
var subtype= document.getElementById('subtype').value
	document.getElementById('payper').style.display='none';
document.getElementById('Small').style.display='none';
document.getElementById('Medium').style.display='none';
document.getElementById('Large').style.display='none';
if(subtype!=''){
document.getElementById('payper').style.display='block';
document.getElementById(subtype).style.display='block';
}
}



function showToolTip(e,text,ishide){
	if(document.all)e = event;
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX - 100;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';	
	if(ishide==1)
	{
		var IfrRef = document.getElementById('DivShim');
		IfrRef.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
		IfrRef.style.left = leftPos + 'px';
		obj.style.zIndex = 1000;
		IfrRef.style.zIndex = obj.style.zIndex - 1;
		// alert( obj.offsetWidth+" "+obj.offsetHeight);
		IfrRef.style.width = '140px';
		objHeight =obj.offsetHeight-27 ;
		//alert(objHeight);
		IfrRef.style.height = objHeight+"px";
		IfrRef.style.display = "block";
	}
}	

function hideToolTip()
{
	document.getElementById('bubble_tooltip').style.display = 'none';
	document.getElementById('DivShim').style.display = 'none';
	
}

function CloseAddContact()
{
window.parent.parent.location.href='/user/?action=toolscontrolscreen&do=payments';
}

function Details(id)
{
if(document.getElementById('Nexodexdivs_'+id).style.display=='none'){
document.getElementById('Nexodexdivs_'+id).style.display="block";
document.getElementById('NexodexdivsLink_'+id).innerHTML="[-]";
}else{
document.getElementById('Nexodexdivs_'+id).style.display="none";
document.getElementById('NexodexdivsLink_'+id).innerHTML="[+]";
}
}

function optionopen(id)
{

var divlist=document.getElementsByTagName("div");
for (var i=0; i<divlist.length; i++){
divid = divlist[i].getAttribute("id");
if(divid != null){
		var atIndex = divid.indexOf(id);
		if(atIndex > -1){
			if(document.getElementById(divid).style.display=='none'){
				document.getElementById(divid).style.display="block";
				}else{
				document.getElementById(divid).style.display="none";
				}

		}
	}
}

}

function savedivhide(id)
{
var divlist=document.getElementsByTagName("input");
for (var i=0; i<divlist.length; i++){
divid = divlist[i].getAttribute("id");
if(divid != null){
		var atIndex = divid.indexOf(id);
		if(atIndex > -1){
			if(document.getElementById(divid).style.display=='none'){
				document.getElementById(divid).style.display="block";
				}else{
				document.getElementById(divid).style.display="none";
				document.getElementById(divid).style.innerHTML="";
				}

		}
	}
}

}

function popupall(id)
{

var popupall=	document.getElementById("popupall").value;

var divlist=document.getElementsByTagName("div");
for (var i=0; i<divlist.length; i++){
divid = divlist[i].getAttribute("id");
if(divid != null){
		var atIndex = divid.indexOf(id);
		if(atIndex > -1){
			var ic=divid.split('Nexodexdivs_');
			if(popupall==0){
				document.getElementById(divid).style.display="block";
				document.getElementById('NexodexdivsLink_'+ic[1]).innerHTML="[-]";
				document.getElementById("popupall").value=1;
				}else{
				document.getElementById(divid).style.display="none";
				document.getElementById('NexodexdivsLink_'+ic[1]).innerHTML="[+]";
				document.getElementById("popupall").value=0;
				}

		}
	}
}

}

function automateyesornot()
{
	
	if(document.getElementById('automateyesornot').value==1)
	var option=0;
	else
	var option=1;
		
	 var url = appPath+'/phpfiles/automate.php?option=' + option;
	//alert(url)
	var xmlhttp = false;
	if (window.XMLHttpRequest) 
	{
	 xmlhttp = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
	 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		if(document.getElementById('automateyesornot').value==1){
		document.getElementById('automate').innerHTML="Automate?";
		document.getElementById('automateyesornot').value=0;
		}else{
		document.getElementById('automate').innerHTML="Don't Automate?";
		document.getElementById('automateyesornot').value=1;
		}
			window.location.href='/user/?action=homescreen&msg=MjA5';
		} 
	};
	xmlhttp.send(null);


}
// Google suggest function added on 10/23/2008

/*
	This is the JavaScript file for the AJAX Suggest Tutorial

	You may use this code in your own projects as long as this 
	copyright is left	in place.  All code is provided AS-IS.
	This code is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
	
	For the rest of the code visit http://www.DynamicAJAX.com
	
	Copyright 2006 Ryan Smith / 345 Technical / 345 Group.	

*/
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("Your Browser Sucks!\nIt's about time to upgrade don't you think?");
	}
}

//Our XmlHttpRequest object to get the auto suggest
var searchReq = getXmlHttpRequestObject();

//Called from keyup on the search textbox.
//Starts the AJAX request.
function searchSuggest(e) {
if(!e){var e = window.event};
code = e.keyCode;
var objDiv = document.getElementById("search");
	if(code != 38 && code != 40 && code != 13){
	document.getElementById('search').style.display='block';
	document.getElementById('search').innerHTML="Loading...";
	if (searchReq.readyState == 4 || searchReq.readyState == 0) {
		var str = escape(document.getElementById('txtsearch').value);
		searchReq.open("GET", 'http://www.nexodex.com/phpfiles/searchresult.php?t1=d' + str, true);
		searchReq.onreadystatechange = handleSearchSuggest; 
		searchReq.send(null);
	}
	}
}

//Called when the AJAX response is returned.
function handleSearchSuggest() {
//var e = window.event;
//code = e.keyCode;
var objDiv = document.getElementById("search");
	if (searchReq.readyState == 4) {

		if(searchReq.responseText != "")
			{
				 var cnt=searchReq.responseText.split("-/-");
				 db[0]=cnt[0].split("*/");
			     db[3]=cnt[1].split("-/*");
				 
if(db[0]!='')
				 objDiv.style.display='block';
else
					 objDiv.style.display='none';

				 objDiv.scrollTop = 0;
        
				  objDiv.innerHTML = '';
				  for(var i= 1 ; i < db[0].length;i++)
				  {
					   var objChDiv = document.createElement('div');
					   objChDiv.setAttribute('id' , "ch_"+i);
					   objDiv.appendChild(objChDiv);
					   objChDiv.innerHTML=db[0][i];
					   objChDiv.className = 'cDiv';
					   
					   if(i == 1)
					   {
							//objChDiv.className = 'cDivSel';
							//var selected=0;
							
					   }
					   
					   objChDiv.onmouseover = function(){mouseMoveSelection(objDiv , this)};
					   //objChDiv.onclick = function(){clickTk(objDiv)};
				  }
			}
			else{
				alert(searchReq.responseText);
			document.getElementById('search').style.display='none';
			}
		
	}
}

//Mouse over function
function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
}
//Mouse out function
function suggestOut(div_value) {
	div_value.className = 'suggest_link';
}
//Click function
function setSearch(value) {
	document.getElementById('txtsearch').value = value;
	document.getElementById('search_suggest').innerHTML = '';
}
