var _xmlHttp;
function getXmlHttpObject(){
	_xmlHttp=null;
	try{
		_xmlHttp=new XMLHttpRequest();
	}catch (e){
		try{
			_xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			_xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return _xmlHttp;
}
function run(f, phpUrl, pString){
	if(pString === undefined){
		pString = "";
	}
	_xmlHttp=getXmlHttpObject();
	if (_xmlHttp===null){
	 alert ("Browser does not support HTTP Request");
	 return;
	}
	var url='/amap/pajax/'+phpUrl+'.php';
	url=url+"?randVal="+Math.random()+"&";
	_xmlHttp.open("POST",url,true);
	_xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	_xmlHttp.setRequestHeader("Content-length", pString.length);
	_xmlHttp.setRequestHeader("Connection", "close");
	if(f){
		_xmlHttp.onreadystatechange = function() {
			if(_xmlHttp.readyState == 4 && _xmlHttp.status == 200){
				f(_xmlHttp.responseText);
			}
		};
	}
	_xmlHttp.send(pString);
}
function closeBox(){
	document.getElementById('fill_box').style.display = 'none';
}
function openBox(){
	document.getElementById('fill_box').style.display = '';
}
function changePortfolio(str){
	var arr = str.split('[&]');
	var spl;
	var portfolio = [];
	for(i=0;i<arr.length;i++){
		spl = arr[i].split('[=]');	
		portfolio[spl[0]] = spl[1];
	}
	document.getElementById('port_client_name').innerHTML = portfolio['client_name'];	
	document.getElementById('port_box_client_name').innerHTML = portfolio['client_name'];	
	document.getElementById('port_details').innerHTML = portfolio['details'];	
	document.getElementById('port_box_details').innerHTML = portfolio['details'];	
	document.getElementById('port_website').innerHTML = '<a href="http://'+portfolio['website'].split("https://").join("").split("http://").join("")+'">'+portfolio['website']+'</a>';
	document.getElementById('port_box_website').innerHTML = '<a href="http://'+portfolio['website'].split("https://").join("").split("http://").join("")+'">'+portfolio['website']+'</a>';
	portfolio['description_short'] = portfolio['description'];
	if(portfolio['description'].length > 80){
	   portfolio['description_short'] = portfolio['description'].substr(0,80) + '... <a href="javascript:openBox();">Read More &gt;&gt;</a>';
	}
	document.getElementById('port_description').innerHTML = '<span class="description">'+portfolio['description_short']+'</span>';
	document.getElementById('port_box_description').innerHTML = '<span class="description">'+portfolio['description']+'</span>';
	document.getElementById('portfolioLeft').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="526" height="286"><param name="movie" value="/amap/swf.php?swf='+portfolio['swf']+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="/amap/swf.php?swf='+portfolio['swf']+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="526" height="286" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
	var fill_box = document.getElementById('fill_box');
	fill_box.style.display = 'none';
}