function getElemVal(elemName)

{

	if (elemName!='' && document.getElementById(elemName).value!='')

		return document.getElementById(elemName).value;

	else return '';

}



function createRequestObject()

{

	var request_o;

	var browser = navigator.appName;

	if(browser == "Microsoft Internet Explorer")

	{

		request_o = new ActiveXObject("Microsoft.XMLHTTP");

	}

	else

	{

		request_o = new XMLHttpRequest();

	}

	return request_o;

}

var http = createRequestObject();

var imgurlnext='';

var webmaildropdown='';

function handleFetchedContactResponse()

{

	if(http.readyState == 4)

    {

        tmp = http.responseText;

		if(tmp!='')

		{

//			alert(tmp.indexOf('err:::'));

			if (tmp.indexOf('err:::')==0 || tmp.indexOf('err:::')==1 || tmp.indexOf('err:::')==2 || tmp.indexOf('err:::')==4)

			{

				document.getElementById('contactlist').innerHTML = '';

	    		document.getElementById('contactlist').style.display = "none";



				tmp=tmp.replace(/err:::/g,'');

				if (tmp.indexOf('Your email provider is')==0 || tmp.indexOf('Your')==2)

				{

	    			toggleDiv('regular',imgurlnext);

//	    			document.getElementById('fetch').innerHTML = '<img src="'+imgurlnext+'submit.png" onClick="javascript: processFetch();" onKeyPress="javascript: processFetch();" tabindex="4">';

				}

				else

				{

	    			//document.getElementById('fetch').innerHTML = "<input type='button' value='Fetch' onClick='javascript: processFetch();'  tabindex='4' />";

	    			document.getElementById('fetch').innerHTML = '<img src="'+imgurlnext+'submit.png" onClick="javascript: processFetch();" onKeyPress="javascript: processFetch();" tabindex="4">';

				}

				document.getElementById('errmsg').innerHTML = tmp;

    			document.getElementById('errmsg').style.display = "block";

			}

			else

			{

				document.getElementById('email').readonly=false;

				document.getElementById('password').readonly=true;



				document.getElementById('fetchcontact').style.display = 'none';



				document.getElementById('contactlist').innerHTML = tmp;

	    		document.getElementById('contactlist').style.display = "block";



	    		/*document.getElementById('eblock').style.display = 'none';

	    		document.getElementById('cblock').style.display = 'none';

	    		document.getElementById('rblock').style.display = 'none';*/

			}

		}

    }

}

function fetchContacts(fetchurl,imgurl)

{

	http.open('get',fetchurl);

    http.onreadystatechange = handleFetchedContactResponse;

    http.send(null);

}



function handleSaveResponse()

{

	if(http.readyState == 4)

    {

        tmp = http.responseText;

		if(tmp!='')

		{

			if (tmp.indexOf('err:::')==0 || tmp.indexOf('err:::')==1 || tmp.indexOf('err:::')==2)

			{

				tmp=tmp.replace(/err:::/g,'');

				document.getElementById('errmsg').innerHTML = tmp;

	    		document.getElementById('errmsg').style.display = "block";

			}

			else

			{

//				YtTools.start();

				document.getElementById('contactlist').innerHTML = '';

	    		document.getElementById('contactlist').style.display = "none";



	    		document.getElementById('successmsg').innerHTML = tmp;

	    		document.getElementById('successmsg').style.display = "block";



	    		document.getElementById('footer').style.display = "none";

			}

		}

    }

}



function reloadCaptcha(httpurl)

{

	img = document.getElementById('imgCaptcha');

	img.src = decode64(httpurl)+'inc/php/create_image.php?' + Math.random();

}



function saveContacts(saveurl,params,ajaximgurl,imgurl,httpurl,InvType,successmsg_mode,recaptchadisp)

{

//	alert(InvType);

	http.open("POST", saveurl, true);



	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

	http.setRequestHeader("Content-length", params.length);

	http.setRequestHeader("Connection", "close");



	http.onreadystatechange = function() {//Call a function when the state changes.

		if(http.readyState == 4 && http.status == 200) {

			var tmp='';

			tmp = http.responseText;

			if (tmp.indexOf('err:::')==0 || tmp.indexOf('err:::')==1 || tmp.indexOf('err:::')==2)

			{

				tmp=tmp.replace(/err:::/g,'');

				document.getElementById('errmsg').innerHTML = tmp;

	    		document.getElementById('errmsg').style.display = "block";

				/*reloadCaptcha(encode64(httpurl));

				document.getElementById('send').innerHTML = '<input type="button" value="Send" onClick="javascript: processSendInvitation(\'Regular\');"  />';*/

				if (InvType=='Regular')

				{

					if (recaptchadisp=='YES')

					{

						reloadCaptcha(encode64(httpurl));

					}

//					document.getElementById('send').innerHTML = '<input type="button" value="Send" onClick="javascript: processSendInvitation(\'Regular\');"  />';

					document.getElementById('send').innerHTML = '<img src="'+imgurl+'send.png" onClick="javascript: processSendInvitation(\'Regular\');" onKeyPress="javascript: processSendInvitation(\'Regular\');"  />';

				}

				else

				{

					/*document.getElementById('send-contactmessage').innerHTML = '<input type="button" value="Send" onClick="javascript: processSendInvitation('+'\''+InvType+'\''+');"  />';

					document.getElementById('send-contactlist').innerHTML = '<input type="button" value="Send" onClick="javascript: processSendInvitation('+'\''+InvType+'\''+');"  />';*/

					document.getElementById('send-contactmessage').innerHTML = '<img src="'+imgurl+'send.png" onClick="javascript: processSendInvitation('+'\''+InvType+'\''+');" onKeyPress="javascript: processSendInvitation('+'\''+InvType+'\''+');"  />';

					document.getElementById('send-contactlist').innerHTML = '<img src="'+imgurl+'send.png" onClick="javascript: processSendInvitation('+'\''+InvType+'\''+');" onKeyPress="javascript: processSendInvitation('+'\''+InvType+'\''+');"  />';

				}

			}

			else

			{

				if (successmsg_mode=='D')

				{

	//				YtTools.start();

					document.getElementById('contactlist').innerHTML = '';

		    		document.getElementById('contactlist').style.display = "none";

		    		document.getElementById('successmsg').innerHTML = tmp;

		    		document.getElementById('successmsg').style.display = "block";



		    		document.getElementById('description').style.display = "none";

		    		document.getElementById('footer').style.display = "none";

		    		document.getElementById('importcsv').style.display = 'none';

		    		document.getElementById('regular').style.display = 'none';

		    		document.getElementById('fetchcontact').style.display = 'none';

		    		/*document.getElementById('eblock').style.display = 'none';

		    		document.getElementById('cblock').style.display = 'none';

		    		document.getElementById('rblock').style.display = 'none';*/

				}

				else if (successmsg_mode=='R')

				{

					if (navigator.appName=='Netscape')

					{

						tmp = tmp.replace(/\n/g,'');

						tmp = tmp.replace(/\s/g,'').replace(/  ,/g,'');

					}

					window.location = tmp;

				}

			}

		}

	}

	http.send(params);

}



/*added by jairo*/

function SendSocialContacts(sendurl,params)

{

//	alert(sendurl+'?'+params);

//	http.open("POST", sendurl, true);

	http.open("GET", sendurl+'?'+params, true);

	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

	http.setRequestHeader("Content-length", params.length);

	http.setRequestHeader("Connection", "close");



	http.onreadystatechange = function() {//Call a function when the state changes.

		if(http.readyState == 4 && http.status == 200) {

			//	alert(http.responseText.length);

				if(http.responseText.length != 0 ){window.location = http.responseText;}

				document.getElementById('contactlist').innerHTML = '';

		    		document.getElementById('contactlist').style.display = "none";

		    		document.getElementById('successmsg').innerHTML = "Successfully send ";

		    		document.getElementById('successmsg').style.display = "block";

		    		document.getElementById('description').style.display = "none";

		    		document.getElementById('footer').style.display = "none";

		    		document.getElementById('importcsv').style.display = 'none';

		    		document.getElementById('regular').style.display = 'none';

		    		document.getElementById('fetchcontact').style.display = 'none';

		    		/*document.getElementById('eblock').style.display = 'none';

		    		document.getElementById('cblock').style.display = 'none';

		    		document.getElementById('rblock').style.display = 'none';*/



			/*addde by jairo*/				

		}

	}

	//http.send(params);

	http.send(null);

	

}



/*added by jairo*/









function replace_html(id, content) {

	document.getElementById(id).innerHTML = content;

	document.getElementById(id).style.display = "block";

}



function show_progressbar(id,imgurl) {

	replace_html(id, '<img src='+imgurl+' border="0" alt="Loading, please wait..." />');

}



function toggleDiv(displayDiv,imgurl,webmail_dropdown)

{

	document.getElementById('errmsg').innerHTML = '';

	document.getElementById('errmsg').style.display = "none";



	document.getElementById('contactlist').innerHTML = '';

	document.getElementById('contactlist').style.display = 'none';

//	document.getElementById('fetch').innerHTML = "<input type='button' value='Fetch' onClick='javascript: processFetch();'  tabindex='4' />";



	if (displayDiv=='regular')

	{

		document.getElementById(displayDiv).style.display = 'block';

		document.getElementById('importcsv').style.display = 'none';

		document.getElementById('fetchcontact').style.display = 'none';

		document.getElementById('importbox').style.display = 'none';



		if (getElemVal('importername')!='')

		{

			document.getElementById('fromname').value = getElemVal('importername');

		}

		if (getElemVal('email')!='')

		{

			if (webmail_dropdown=='YES')

				document.getElementById('fromemail').value = getElemVal('email')+'@'+getElemVal('provider');

			else

				document.getElementById('fromemail').value = getElemVal('email');

		}



		/*document.getElementById('eblock').style.display = 'none';

		document.getElementById('cblock').style.display = 'none';

		document.getElementById('rblock').style.display = 'block';*/

	}

	else if (displayDiv=='importcsv')

	{

		document.getElementById(displayDiv).style.display = 'block';

		document.getElementById('fetchcontact').style.display = 'none';

		document.getElementById('regular').style.display = 'none';

		document.getElementById('importbox').style.display = 'block';



		/*document.getElementById('eblock').style.display = 'none';

		document.getElementById('rblock').style.display = 'none';

		document.getElementById('cblock').style.display = 'block';*/

	}

	else if (displayDiv=='fetchcontact')

	{

		document.getElementById(displayDiv).style.display = 'block';

		document.getElementById('regular').style.display = 'none';

		document.getElementById('importcsv').style.display = 'none';

		document.getElementById('importbox').style.display = 'none';

		document.getElementById('fetch').innerHTML = '<img src="'+imgurl+'submit.png" onClick="javascript: processFetch();" onKeyPress="javascript: processFetch();" tabindex="4">';



		if (webmail_dropdown=='YES')

		{

			if (getElemVal('fromemail')!='')

			{

				var ieml = getElemVal('fromemail');

				tarr = ieml.split('@');

				document.getElementById('email').value = tarr[0];

				for(i=0;i<document.getElementById('provider').options.length;i++)

				{

					//alert(document.getElementById('provider').options[i].value +'=='+ tarr[1]);

					if (document.getElementById('provider').options[i].value == tarr[1])

					{

						document.getElementById('provider').selectedIndex = i;

						break;

					}

					else continue;

				}

			}



		}

		else

		{

			if (getElemVal('fromname')!='')

			{

				document.getElementById('importername').value = getElemVal('fromname');

			}

			if (getElemVal('fromemail')!='')

			{

				document.getElementById('email').value = getElemVal('fromemail');

			}

		}

		/*document.getElementById('rblock').style.display = 'none';

		document.getElementById('cblock').style.display = 'none';

		document.getElementById('eblock').style.display = 'block';*/

	}

}



function toggleAll(cb)

{

    var val = cb.checked;

	var frm = document.frmmain;

	var len = frm.elements.length;

	var i=0;

	for( i=0 ; i<len ; i++) {

		if (frm.elements[i].name=='emails[]') {

			frm.elements[i].checked=val;

		}

	}

}



function isEmail(who)

{

    var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;

	return(email.test(who));

}



function showDomainList(showhide)

{

	if (showhide==true)

	{

		document.getElementById('domainlist').style.display="block";

	}

	else if (showhide==false)

	{

		document.getElementById('domainlist').style.display="none";

	}

}



var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";



function encode64(input) {

   var output = "";

   var chr1, chr2, chr3;

   var enc1, enc2, enc3, enc4;

   var i = 0;



   do {

      chr1 = input.charCodeAt(i++);

      chr2 = input.charCodeAt(i++);

      chr3 = input.charCodeAt(i++);



      enc1 = chr1 >> 2;

      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);

      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);

      enc4 = chr3 & 63;



      if (isNaN(chr2)) {

         enc3 = enc4 = 64;

      } else if (isNaN(chr3)) {

         enc4 = 64;

      }



      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +

         keyStr.charAt(enc3) + keyStr.charAt(enc4);

   } while (i < input.length);



   return output;

}



function decode64(input) {

   var output = "";

   var chr1, chr2, chr3;

   var enc1, enc2, enc3, enc4;

   var i = 0;



   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =

   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");



   do {

      enc1 = keyStr.indexOf(input.charAt(i++));

      enc2 = keyStr.indexOf(input.charAt(i++));

      enc3 = keyStr.indexOf(input.charAt(i++));

      enc4 = keyStr.indexOf(input.charAt(i++));



      chr1 = (enc1 << 2) | (enc2 >> 4);

      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);

      chr3 = ((enc3 & 3) << 6) | enc4;



      output = output + String.fromCharCode(chr1);



      if (enc3 != 64) {

         output = output + String.fromCharCode(chr2);

      }

      if (enc4 != 64) {

         output = output + String.fromCharCode(chr3);

      }

   } while (i < input.length);



   return output;

}



var arrContacts = new Array();



function AddContact()

{

	var cname = getElemVal('cname');

	var cemail = getElemVal('cemail');



	if ((cemail==null)||(cemail=="")){

		alert(enter_friends_email);

		document.getElementById('cemail').focus();

		return false;

	}

	else

	{

		if (!isEmail(cemail))

		{

			alert(enter_friends_valid_email);

			document.getElementById('cemail').select();

			document.getElementById('cemail').focus();

			return false;

		}

	}

	document.getElementById('cname').value='';

	document.getElementById('cemail').value='';

	document.getElementById('cname').focus();

	var cnm = cname;

	cnm = cnm.replace("&","@amp@");

	cnm = cnm.replace("&amp;","@amp@");

	arrContacts.splice(arrContacts.length,0,cemail+":::"+cnm);

	deleteAllRows('addcontacts');

	RowToTable();

}



function DeleteContact(elementno)

{

	arrContacts.splice(elementno,1);

	deleteAllRows('addcontacts');

	RowToTable();

}



function RowToTable(Act)

{

	var tbl = document.getElementById('addcontacts');

	var lastRow = tbl.rows.length;

	var iteration = lastRow;

	var row = tbl.insertRow(lastRow);

	if (arrContacts.length>0)

	{

		for(i=0;i<arrContacts.length;i++)

		{

			SplitArrContacts = arrContacts[i].split(':::');

			var cellNameText = row.insertCell(0);

			var cnm = SplitArrContacts[1];

			cnm = cnm.replace("@amp@", "&");

			var textNameNode = document.createTextNode(cnm);

			cellNameText.appendChild(textNameNode);



			var cellEmailText = row.insertCell(1);

			var textEmailNode = document.createTextNode(SplitArrContacts[0]);

			cellEmailText.appendChild(textEmailNode);



			var cellAct = row.insertCell(2);

			cellAct.align="center";

			var elAct = document.createElement('a');

			elAct.href="javascript:DeleteContact("+i+");";

			var LinkTN = document.createTextNode('Delete');

			elAct.appendChild(LinkTN);

			cellAct.appendChild(elAct);



			row = tbl.insertRow(lastRow+1);

		}

	}

}



function deleteAllRows(tblId)

{

  var tbl = document.getElementById(tblId);

  for (var i=tbl.tBodies[0].rows.length-1; i>=2; i--) {

    tbl.tBodies[0].deleteRow(i);

  }

}



function removeRowFromTable()

{

  var tbl = document.getElementById('addcontacts');

  var lastRow = tbl.rows.length;

  if (lastRow > 2) tbl.deleteRow(lastRow - 1);

}



function fetch(urlhttp,urlimg,webmail_dropdown)

{

	imgurlnext = urlimg;

	webmaildropdown = webmail_dropdown;

	var frm = document.frmmain;

	var emailID = frm.email;

	var passwordId = frm.password;

	var importerName = frm.importername;

	//added by jairo

	var doms=frm.Domain;

	//added by jairo



	if ((importerName.value==null)||(importerName.value=="")){

		alert(enter_your_name);

		importerName.focus();

		return false;

	}

//added by jairo noel

	if ((doms.value==null)||(doms.value=="")){

		alert("please select a service");

		doms.focus();

		return false;

	}

//added by jairo noel



if ((emailID.value==null)||(emailID.value=="")){

		alert(enter_your_email);

		emailID.focus();

		return false;

	}

	else

	{

		var tempEmail = '';

		if (webmail_dropdown == 'YES')

		{

			var provider = getElemVal('provider');

			if (provider=='linkedin')

			{

				if (!isEmail(emailID.value)){

					alert(enter_your_valid_email);

					emailID.select();

					emailID.focus();

					return false;

				}

				tempEmail = emailID.value+'.'+provider;

			}

			else

			{

				tempEmail = emailID.value+'@'+provider;

				if (!isEmail(tempEmail)){

					alert(enter_your_valid_email);

					emailID.select();

					emailID.focus();

					return false;

				}

			}

		}

		else

		{

			tempEmail = emailID.value;

			tempEmail = tempEmail.replace(/.linkedin/g,'');

			if (!isEmail(tempEmail)){

				/*

				alert(enter_your_valid_email);

				emailID.select();

				emailID.focus();

				return false;

				*/

			}

		}

	}

	if((passwordId.value==null) || (passwordId.value==""))

	{



		alert(enter_password);

		passwordId.focus();

		return false;

	}



	/*emailID.value=tempEmail;

	alert(emailID.value);*/



	document.getElementById('errmsg').innerHTML = '';

	document.getElementById('errmsg').style.display = "none";



	document.getElementById('contactlist').innerHTML = '';

	document.getElementById('contactlist').style.display = "none";



//	var fetchurl=  urlhttp+"importer.php?req=fc&n="+encode64(importerName.value)+"&e="+encode64(emailID.value)+"&p="+encode64(passwordId.value)+"&cc=&cr=";

//	var fetchurl=  urlhttp+"importer.php?req=fc&n="+encode64(importerName.value)+"&e="+encode64(tempEmail)+"&p="+encode64(passwordId.value)+"&cc=&cr=";

//modified by jairo start

	var fetchurl=  urlhttp+"importer.php?req=fc&n="+encode64(importerName.value)+"&e="+encode64(tempEmail)+"&p="+

							encode64(passwordId.value)+"&cc=&cr=&doms="+encode64(doms.value);

//	alert(fetchurl);						

//modified by jairo	end

	var imgurl= urlimg+"ajax-loader1.gif";

//modified by jairo start

	//document.getElementById('password').value = "";

//modified by jairo end



	document.getElementById('fetch').innerHTML = "<img src='"+imgurl+"'>";

	fetchContacts(fetchurl,imgurl);

}





function importFromCSV()

{

	var frm = document.frmmain;

	if (frm.importfile.value=='')

	{

		alert(select_csv_format);

		return false;

	}

	else

	{

		fullName = frm.importfile.value;

		shortName = fullName.match(/[^\/\\]+$/);



		if (fullName==shortName)

		{

			alert(select_valid_file_path);

			return false;

		}

		splitName = fullName.split(".");

		if (splitName.length<=1)

		{

			alert(select_valid_file);

			return false;

		}

		fileType = splitName[1];

		fileType = fileType.toLowerCase();



		if (fileType == 'csv' || fileType == 'ldif')

		{

			document.frmmain.hdnaction.value='Import';

			document.frmmain.submit();

		}

		else

		{

			alert(select_csv_format);

			return false;

		}

	}

}



function sendInvitation(InvType,httpurl,imgurl,custsub,custmsg,custafflink,recaptchadisp,targeturl,contactid,gd,webmail_dropdown,successmsg_mode,allow_to_name_modify,allow_notification)

{

	var frm = document.frmmain;

	document.getElementById('fetchcontact').style.display = "none";

//	document.getElementById('importcsv').style.display = "none";



	if (InvType=='Import')

	{

		document.getElementById('importcsv').style.display = "block";

		var importerName = frm.sname;

		if ((importerName.value==null)||(importerName.value=="")){

			alert(enter_sender_name);

			importerName.focus();

			return false;

		}

		var emailID=frm.semail;

		if ((emailID.value==null)||(emailID.value=="")){

			alert(enter_your_email);

			emailID.focus();

			return false;

		}

		else

		{

			if (!isEmail(emailID.value)){

				alert(enter_your_valid_email);

				emailID.select();

				emailID.focus();

				return false;

			}

		}

	}

	document.getElementById('errmsg').innerHTML = '';

	document.getElementById('errmsg').style.display = "none";



	var arrEmails = new Array();

	var strEmails = '';

	/*added by jairo*/

	var strUid= '';

	/*added by jairo*/

	if (InvType=='Contact' || InvType=='Import')

	{

		if (frm.elements['emails[]'].length==undefined)

		{

			if(frm.elements['emails[]'].checked==true && frm.elements['emails[]'].value!='')

			{

				if (allow_to_name_modify=='Y')

				{

					strEmails = frm.elements['emails[]'].value+':::'+frm.elements['names[]'].value;

				}

				else

				{

					strEmails = frm.elements['emails[]'].value;

					//added by jairo

					if(!isEmail(strEmails)){

							strUid += frm.elements['emails[]'].value+",";

					}else{

						strUid+="";

					}

					//added by jairo

					

				}

			}

			else

			{

				alert(select_atleast_one);

				return false;

			}

		}

		else

		{

			for (i=0;i<frm.elements['emails[]'].length;i++)

			{

				if (frm.elements['emails[]'][i].checked==true && frm.elements['emails[]'][i].value!='')

				{

					temailarr=frm.elements['emails[]'][i].value.split(':::');

					if (isEmail(temailarr[0]))

					{

						if (allow_to_name_modify=='Y')

						{

							strEmails += frm.elements['emails[]'][i].value+':::'+frm.elements['names[]'][i].value+",";

						}

						else

						{

							strEmails += frm.elements['emails[]'][i].value+",";

						}

					}

					//modified my Jairo

					//else{ continue;};

					else{ strUid+=frm.elements['emails[]'][i].value+","; /*alert("ssss"+temailarr[0]); continue;*/};

					//modified my Jairo

				}

			}

		}

//modified by jairo		

//if (strEmails=='')

		if (strEmails=='' || strUid!='' )

//modified by jairo		

		{

			if(strUid.length==0){

				alert(select_atleast_one);

				return false;

			}

			/*addde by jairo*/

			document.getElementById('send-contactmessage').innerHTML = "<img src='"+imgurl+"ajax-loader1.gif"+"'>";

			document.getElementById('send-contactlist').innerHTML = "<img src='"+imgurl+"ajax-loader1.gif"+"'>";

			strUid=strUid.substring(0,(strUid.length-1));

			var $user = frm.elements['email'].value;

			var $pass = frm.elements['password'].value;

			var $doms = frm.elements['doms'].value;

			var saveurl= httpurl+"importer.php";

			var strParams = "req="+'ssc'+"&c="+encode64(strUid)+'&p='+encode64($pass)+'&u='+encode64($user)+'&d='+encode64($doms);

			//alert(strParams);

			SendSocialContacts(saveurl,strParams);

			//added by jairo

			return false;

		}

		else

		{

			strEmails=strEmails.substring(0,(strEmails.length-1));

		}

	}

	else if (InvType=='Regular')

	{

		var importerName = frm.fromname;

		if ((importerName.value==null)||(importerName.value=="")){

			alert(enter_your_name);

			importerName.focus();

			return false;

		}

		var emailID=frm.fromemail;

		if ((emailID.value==null)||(emailID.value=="")){

			alert(enter_your_email);

			emailID.focus();

			return false;

		}

		else

		{

			if(!isEmail(emailID.value)) {

				alert(enter_your_valid_email);

				emailID.select();

				emailID.focus();

				return false;

			}

		}

		if (arrContacts.length<=0)

		{

			alert(no_contact_email_specified);

			document.getElementById('cemail').focus();

			return false;

		}

		else

		{

			strEmails=arrContacts.join(',');

//			strEmails=strEmails.substring(0,(strEmails.length-1));

		}

	}

	var saveurl= httpurl+"importer.php";

	//added by jairo

	try{

			var $doms = frm.elements['doms'].value;

	}catch(e){

			var $doms = "YahooImporter";

	}

	//added by jairo

	

	//modified by jairo noel

	var strParams = "req="+encode64('sc')+"&c="+encode64(strEmails)+"&doms="+$doms;

	//modified by jairo noel





	if (custsub=='YES')

	{

		if (InvType=='Regular')

		{

			var sub = getElemVal('subject1');

			sub = sub.replace("&","@amp@");

			sub = sub.replace("&amp;","@amp@");

			strParams += "&s="+sub;

		}

		else

		{

			var sub = getElemVal('subject');

			sub = sub.replace("&","@amp@");

			sub = sub.replace("&amp;","@amp@");

			strParams += "&s="+sub;

		}

	}

	if (custmsg=='YES')

	{

		var strMsg = '';

		if (InvType=='Regular')

		{

			var msg = getElemVal('message1');

			msg = msg.replace("&","@amp@");

			msg = msg.replace("&amp;","@amp@");

			var arrMsg = msg.split("\n");

		}

		else

		{

			var msg = getElemVal('message');

			msg = msg.replace("&","@amp@");

			msg = msg.replace("&amp;","@amp@");

			var arrMsg = msg.split("\n");

		}

		for (i=0;i<arrMsg.length;i++)

		{

			if ((i-1)==arrMsg.length)

				strMsg += arrMsg[i];

			else

				strMsg += arrMsg[i].substring(0,(arrMsg[i].length))+"@_@";

		}

		strParams += "&m="+strMsg;

	}



	/*if (custafflink=='YES')

	{*/

//		strParams += "&al="+frm.afflink.value;

		if (InvType=='Regular')

		{

			var afl = document.getElementById('afflink1').value;

			afl = afl.replace("&","@amp@");

			afl = afl.replace("&amp;","@amp@");

			if (afl!='') strParams += "&al="+encode64(afl);

		}

		else

		{

			var afl = document.getElementById('afflink').value;

			afl = afl.replace("&","@amp@");

			afl = afl.replace("&amp;","@amp@");

			if (afl!='') strParams += "&al="+encode64(afl);

		}

	/*}*/



	/*if (recaptchadisp=='YES')

	{

//		strParams += "&cc="+frm.ccaptcha.value;

		strParams += "&rc="+frm.captchaval.value;

	}*/

	if (InvType=='Import')

	{

		document.getElementById('fetchcontact').innerHTML = '';

		strParams += "&t="+encode64('C');



		var fnm = frm.sname.value;

		fnm = fnm.replace("&","@amp@");

		fnm = fnm.replace("&amp;","@amp@");

		strParams += "&n="+encode64(fnm);

		strParams += "&e="+encode64(frm.semail.value);

	}

	else

	{

		if (InvType=='Contact')

		{

			var fnm = frm.importername.value;

			fnm = fnm.replace("&","@amp@");

			fnm = fnm.replace("&amp;","@amp@");

			strParams += "&n="+encode64(fnm);

			if (webmail_dropdown=='YES')

			{

				strParams += "&e="+encode64(frm.email.value+'@'+getElemVal('provider'));

			}

			else

			{

				strParams += "&e="+encode64(frm.email.value);

			}

			strParams += "&t="+encode64('E');

		}

		else if (InvType=='Regular')

		{

			var fnm = frm.fromname.value;

			fnm = fnm.replace("&","@amp@");

			fnm = fnm.replace("&amp;","@amp@");

			strParams += "&n="+encode64(fnm);

			strParams += "&e="+encode64(frm.fromemail.value);

			strParams += "&t="+encode64('R');

			if (gd!='' && recaptchadisp=='YES')

			{

				strParams += "&rc="+encode64(frm.captchaval.value);

			}

		}

	}



	strParams += "&su="+encode64(targeturl);

	strParams += "&cid="+encode64(contactid);

	if (InvType=='Regular')

	{

		if (allow_notification == 1 && document.getElementById('notification1').checked==true)

			strParams += "&notify="+1;

		else

			strParams += "&notify="+0;

	}

	else

	{

		if (allow_notification == 1 &&  document.getElementById('notification').checked==true)

			strParams += "&notify="+1;

		else

			strParams += "&notify="+0;

	}

	var ajaximgurl= imgurl+"ajax-loader1.gif";

	if (InvType=='Contact')

	{

		document.getElementById('send-contactmessage').innerHTML = "<img src='"+ajaximgurl+"'>";

		document.getElementById('send-contactlist').innerHTML = "<img src='"+ajaximgurl+"'>";

	}

	else if (InvType=='Regular')

	{

		document.getElementById('send').innerHTML = "<img src='"+ajaximgurl+"'>";

	}

	saveContacts(saveurl,strParams,ajaximgurl,imgurl,httpurl,InvType,successmsg_mode,recaptchadisp);

}



function setProviderText(nexturl)

{

	var provider = getElemVal('provider');

	var splitProvider = provider.split('.');

	var strImg = '';

	strImg = 'Telling my <img src="'+nexturl+splitProvider[0]+'.png"> contacts';

	document.getElementById('selectedprovider').innerHTML= strImg ;

}



function loadStats(encurl)

{

	http.open("GET",decode64(encurl)+'monitor.php?req=stats');

	http.onreadystatechange=getStatResponse;

	http.send(null);

}



function getStatResponse()

{

	if (http.readyState==4 || http.readyState=="complete")

	{

		document.getElementById("stats").innerHTML=http.responseText;

		document.getElementById("stats").style.display='inline';

	}

}


