/* Function to display the contents in expanded/mini profile */

// To get the HTTP object to call a method..
function getHTTPObject()
{
	var xmlhttp;
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlhttp = new XMLHttpRequest();
			}
			catch (e)
			{
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
} // EO function getHTTPObject()

function get_mini_profile_contents(profile_id, show, track_info)
{
	lnk = "link_change_id_"+profile_id;

	lnkhtml = document.getElementById(lnk).innerHTML;
	static_lnk= strpos(lnkhtml, 'blue-arrow', 5);  
	
	var from_folder = '';

	if(typeof(FROM_FOLDER) !== 'undefined')
		from_folder = '&from_folder=matrimony';
 
	var http_mini_p_content = new getHTTPObject();
	if(static_lnk != false)
	{
		var myurl = "/ssi/p-action/profile.php?staticflg=1&profileid="+profile_id+from_folder;
	}else{
		var myurl = "/ssi/p-action/profile.php?staticflg=0&profileid="+profile_id+from_folder;
	}

	if(track_info){myurl += track_info;}
 
	var img = "<div style=\"width:250px;\"><br><center><img src=\""+ IMG_PATH + "/imgs/profiles/loading-ajax.gif\"></center><br></div>";
	
	var large_photo		= profile_id+"large_photo";
	var prepage			= profile_id+"prepage_ext";
	var first_div		= profile_id+"first_div";
	var second_div		= profile_id+"second_div";
	var expand_div		= profile_id+"expand_ext";
	var restore_div		= profile_id+"restore_ext";
	var container_div	= profile_id+"container_div";
	var aboutme_div		= profile_id+"about_me";
	var temp_trans_delay = transition_delay;

	var status = AjaxRequest.get(
	{
		'url':myurl,
		'onLoading':function(req)
			{
				ppg_loading =1;
			},
		'onSuccess':function(req)
			{
				var responsetext = req.responseXML;
				
				var root = responsetext.getElementsByTagName('root')[0];
				if(root != null && responsetext.getElementsByTagName('error')[0] == null)
				{
					var mini_str = "<div class=\"sr_ssecbg\">";
					mini_str += "<div id=\""+large_photo+"\" class=\"sr_lr_pt\">"+responsetext.getElementsByTagName('photo')[0].childNodes[0].nodeValue+"</div>";
					mini_str += "<div id=\""+profile_id+"\" class=\"sr_pid\">";
					mini_str += "<div class=\"sc-ex\" onclick=\"restore_transition('"+prepage+"','"+first_div+"','"+second_div+"','"+container_div+"','"+expand_div+"','"+restore_div+"');\">"+responsetext.getElementsByTagName('intro')[0].childNodes[0].nodeValue+"</div>";
					mini_str += "<div width=100% class=\"smallbluelinkverdana\" style=\"float:center; background-color:#ffffff; color:#0066CC;\">";
					mini_str += "<table width=\"100%\" border=0 class=\"sr_fav_tbl\">";
					mini_str += "<tr>";
					mini_str += "<td width=\"35%\" style=\"vertical-align:bottom;\">"+responsetext.getElementsByTagName('favlink')[0].childNodes[0].nodeValue+"</td>";
					mini_str += "<td rowspan=\"3\" align=\"center\" width=\"65%\" height=\"78px\"><span id=\"link_change_id1_"+profile_id+"\">"+responsetext.getElementsByTagName('expresstext')[0].childNodes[0].nodeValue+"&nbsp;&nbsp;</span></td>";
					mini_str += "</tr>";
					mini_str += "<tr>";
					mini_str += "<td width=\"35%\">"+responsetext.getElementsByTagName('photolink')[0].childNodes[0].nodeValue+"</td></tr><tr><td valign=\"top\" width=\"35%\"><a href=\""+responsetext.getElementsByTagName('viewproflink')[0].childNodes[0].nodeValue+"\" "+responsetext.getElementsByTagName('logincheck')[0].childNodes[0].nodeValue+" class=\"smallbluelink\" title=\"View full profile details of "+profile_id+".\"><img src=\""+IMG_PATH+"/imgs/icons/icon-full-profile.gif\" border=\"none\" width=\"16px\" height=\"17px\" hspace=\"2\" class=\"sr_vfp\">View Full Profile</a></td>";
					mini_str += "</tr>";
					mini_str += "</table>";
					mini_str += "</div>";
					mini_str += "</div>";
					mini_str += "<br clear=\"all\">";
					mini_str += "<div class=\"sr_mini_ref_mdl\"></div>";
					mini_str += "<div id=\""+aboutme_div+"\" class=\"sr_abt_div\" onclick=\"restore_transition('"+prepage+"','"+first_div+"','"+second_div+"','"+container_div+"','"+expand_div+"','"+restore_div+"');\">";
					mini_str += "<span class=\"sr_abt_spn\">"+responsetext.getElementsByTagName('about')[0].childNodes[0].nodeValue+"</span>";
					mini_str += "</div>";
					mini_str += "</div>";
				}
				else if(responsetext.getElementsByTagName('error')[0] != null)
				{
					mini_str =responsetext.getElementsByTagName('error')[0].childNodes[0].nodeValue;
				}

				var second_div_obj = document.getElementById(second_div);
				second_div_obj.innerHTML = mini_str;
				
				ppg_loading =0;				
				expand_transition_part2(prepage,first_div,second_div,container_div,expand_div,restore_div);
			},
		'timeout':30000,
		'onTimeout':function(req){ alert('A problem occurred while communicating with the server.\nPlease make sure you are connected to the Internet and try again in sometime.'); return false;}
		,'onError':function(req){ alert('Error!\nStatusText='+responsetext+'\nContents='+responsetext);}
	}
	);
} // EO get_mini_profile_contents

function strpos( haystack, needle, offset){   
     var i = (haystack+'').indexOf( needle, offset );    
    return i===-1 ? false : i;   
}  

