function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images ) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		menu01over = newImage("images/menu_01o.gif");
		menu02over = newImage("images/menu_02o.gif");
		menu03over = newImage("images/menu_03o.gif");
		menu04over = newImage("images/menu_04o.gif");
		menu05over = newImage("images/menu_05o.gif");
		menu06over = newImage("images/menu_06o.gif");
		menu07over = newImage("images/menu_07o.gif");
		preloadFlag = true;
	}
}

function genRand(){
	var i = Math.round(100000000*Math.random());
	return i;
}

function GetXmlHttpObject()
{
	var xmlHttp=null;try
		{
		// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
	catch (e)
	{
	// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function postContactData(){
	document.getElementById('sendbutton').disabled = true;
	var err = false;
	if( !document.getElementById('nameID').value ){ err = true; focusError(document.getElementById('nameID')); }
	if( !document.getElementById('surnameID').value ){ err = true; focusError(document.getElementById('surnameID')); }
	//if( !document.getElementById('companyID').value ){ err = true; focusError(document.getElementById('companyID')); }
	//if( !document.getElementById('titleID').value ){ err = true; focusError(document.getElementById('titleID')); }
	//if( !document.getElementById('phoneID').value ){ err = true; focusError(document.getElementById('phoneID')); }
	if( !echeck(document.getElementById('emailID').value) ){ err = true; focusError(document.getElementById('emailID')); }
	//if( !document.getElementById('noteID').value ){ err = true; focusError(document.getElementById('noteID')); }
	if( err ){
		document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">fill in the required fields</font></td></tr></table>';
		setTimeout(function(){document.getElementById('dataresult').innerHTML = ''; document.getElementById('sendbutton').disabled = false;},2000);
		return false;
	}
	
	document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Form sending...</font></td></tr></table>';
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null ){
		//alert ("Browser does not support HTTP Request");
		document.getElementById('sendbutton').disabled = false;
		return;
	} else {
		var url="engine/sendPostData.php";
		url=url+"?q1="+document.getElementById('nameID').value;
		url=url+"&q2="+document.getElementById('surnameID').value;
		url=url+"&q3="+document.getElementById('companyID').value;
		url=url+"&q4="+document.getElementById('titleID').value;
		url=url+"&q5="+document.getElementById('phoneID').value;
		url=url+"&q6="+document.getElementById('emailID').value;
		url=url+"&q7="+document.getElementById('noteID').value;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function () {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				//alert(xmlHttp.responseText);
				if (xmlHttp.responseText == "true"){
					document.getElementById('nameID').value = '';
					document.getElementById('surnameID').value = '';
					document.getElementById('companyID').value = '';
					document.getElementById('titleID').value = '';
					document.getElementById('phoneID').value = '';
					document.getElementById('emailID').value = '';
					document.getElementById('noteID').value = '';
					document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Form has been sent!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('dataresult').innerHTML = ''; document.getElementById('sendbutton').disabled = false;},2000);
				} else {
					document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">Error!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('dataresult').innerHTML = ''; document.getElementById('sendbutton').disabled = false;},2000);
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function postMaillistData(){
	document.getElementById('ml_sendbutton').disabled = true;
	var err = false;
	if( !document.getElementById('ml_nameID').value ){ err = true; focusError(document.getElementById('ml_nameID')); }
	if( !echeck(document.getElementById('ml_emailID').value) ){ err = true; focusError(document.getElementById('ml_emailID')); }
	if( err ){
		document.getElementById('ml_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">fill in the required fields</font></td></tr></table>';
		setTimeout(function(){document.getElementById('ml_dataresult').innerHTML = ''; document.getElementById('ml_sendbutton').disabled = false;},2000);
		return false;
	}
	
	document.getElementById('ml_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Form sending...</font></td></tr></table>';
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null ){
		alert ("Browser does not support HTTP Request");
		document.getElementById('ml_sendbutton').disabled = false;
		return;
	} else {
		var url="engine/sendMaillistData.php";
		url=url+"?q1="+document.getElementById('ml_nameID').value;
		url=url+"&q2="+document.getElementById('ml_emailID').value;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function () {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				//alert(xmlHttp.responseText);
				if (xmlHttp.responseText == "true"){
					document.getElementById('ml_nameID').value = '';
					document.getElementById('ml_emailID').value = '';
					document.getElementById('ml_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">You have been added!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('ml_dataresult').innerHTML = ''; document.getElementById('ml_sendbutton').disabled = false;},2000);
				} else if (xmlHttp.responseText == "already"){
					document.getElementById('ml_nameID').value = '';
					document.getElementById('ml_emailID').value = '';
					document.getElementById('ml_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">You are already at list!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('ml_dataresult').innerHTML = ''; document.getElementById('ml_sendbutton').disabled = false;},2000);
				} else {
					document.getElementById('ml_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">Error!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('ml_dataresult').innerHTML = ''; document.getElementById('ml_sendbutton').disabled = false;},2000);
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function postClientLoginData(){
	document.getElementById('sendbutton').disabled = true;
	var err = false;
	if( !document.getElementById('usernameID').value ){ err = true; focusError(document.getElementById('usernameID')); }
	if( !document.getElementById('passwordID').value ){ err = true; focusError(document.getElementById('passwordID')); }
	if( err ){
		document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">Wrong username or password!</font></td></tr></table>';
		setTimeout(function(){document.getElementById('dataresult').innerHTML = ''; document.getElementById('sendbutton').disabled = false;},2000);
		return false;
	}
	document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Processing...</font></td></tr></table>';
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null ){
		alert ("Browser does not support HTTP Request");
		document.getElementById('sendbutton').disabled = false;
		return;
	} else {
		var url="engine/sendClientLoginData.php";
		url=url+"?q1="+document.getElementById('usernameID').value;
		url=url+"&q2="+document.getElementById('passwordID').value;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function () {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				//alert(xmlHttp.responseText);
				if (xmlHttp.responseText != "false"){
					document.getElementById('usernameID').value = '';
					document.getElementById('passwordID').value = '';
					document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Login Success! Please Wait...</font></td></tr></table>';
					setTimeout(function(){document.getElementById('dataresult').innerHTML = ''; document.getElementById('sendbutton').disabled = false; document.location.href=xmlHttp.responseText;},2000);
				} else {
					document.getElementById('dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">Wrong username or password!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('dataresult').innerHTML = ''; document.getElementById('sendbutton').disabled = false;},2000);
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function postRecommendedPeopleData(job){
	document.getElementById('r_sendbutton').disabled = true;
	var err = false;
	if( !document.getElementById('r_nameID').value ){ err = true; focusError(document.getElementById('r_nameID')); }
	if( !echeck(document.getElementById('r_emailID').value) ){ err = true; focusError(document.getElementById('r_emailID')); }
	if( !document.getElementById('r_frnameID').value ){ err = true; focusError(document.getElementById('r_frnameID')); }
	if( !echeck(document.getElementById('r_fremailID').value) ){ err = true; focusError(document.getElementById('r_fremailID')); }
	if( err ){
		document.getElementById('r_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">fill in the required fields</font></td></tr></table>';
		setTimeout(function(){document.getElementById('r_dataresult').innerHTML = ''; document.getElementById('r_sendbutton').disabled = false;},2000);
		return false;
	}
	document.getElementById('r_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Processing...</font></td></tr></table>';
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null ){
		alert ("Browser does not support HTTP Request");
		document.getElementById('r_sendbutton').disabled = false;
		return;
	} else {
		var url="engine/sendRecommendedPeopleData.php";
		url=url+"?q1="+document.getElementById('r_nameID').value;
		url=url+"&q2="+document.getElementById('r_emailID').value;
		url=url+"&q3="+document.getElementById('r_frnameID').value;
		url=url+"&q4="+document.getElementById('r_fremailID').value;
		url=url+"&q5="+job;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function () {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				//alert(xmlHttp.responseText);
				if (xmlHttp.responseText != "error"){
					document.getElementById('r_nameID').value = '';
					document.getElementById('r_emailID').value = '';
					document.getElementById('r_frnameID').value = '';
					document.getElementById('r_fremailID').value = '';
					document.getElementById('r_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Successfully completed !...</font></td></tr></table>';
					setTimeout(function(){document.getElementById('r_dataresult').innerHTML = ''; document.getElementById('r_sendbutton').disabled = false;},3000);
				} else {
					document.getElementById('r_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">Error!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('r_dataresult').innerHTML = ''; document.getElementById('r_sendbutton').disabled = false;},2000);
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function postUserPortfolioData(job){
	document.getElementById('p_sendbutton').disabled = true;
	var err = false;
	if( !document.getElementById('p_nameID').value ){ err = true; focusError(document.getElementById('p_nameID')); }
	if( !document.getElementById('p_urlID').value ){ err = true; focusError(document.getElementById('p_urlID')); }
	if( err ){
		document.getElementById('p_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">fill in the required fields</font></td></tr></table>';
		setTimeout(function(){document.getElementById('p_dataresult').innerHTML = ''; document.getElementById('p_sendbutton').disabled = false;},2000);
		return false;
	}
	document.getElementById('p_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Processing...</font></td></tr></table>';
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null ){
		alert ("Browser does not support HTTP Request");
		document.getElementById('p_sendbutton').disabled = false;
		return;
	} else {
		var url="engine/sendUserPortfolioData.php";
		url=url+"?q1="+document.getElementById('p_nameID').value;
		url=url+"&q2="+document.getElementById('p_urlID').value;
		url=url+"&q3="+job;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function () {
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
				//alert(xmlHttp.responseText);
				if (xmlHttp.responseText == "true"){
					document.getElementById('p_nameID').value = '';
					document.getElementById('p_urlID').value = '';
					document.getElementById('p_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#2c2c2c;"><tr><td align="center"><font color="#ffffff">Successfully completed !...</font></td></tr></table>';
					setTimeout(function(){document.getElementById('p_dataresult').innerHTML = ''; document.getElementById('p_sendbutton').disabled = false;},4000);
				} else {
					document.getElementById('p_dataresult').innerHTML = '<table border="0" cellpadding="2" cellspacing="0" style="width:100%; background-color:#440000;"><tr><td align="center"><font color="#ffffff">Error!</font></td></tr></table>';
					setTimeout(function(){document.getElementById('p_dataresult').innerHTML = ''; document.getElementById('p_sendbutton').disabled = false;},2000);
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1){ return false; }
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false; }
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false; }
	if (str.indexOf(at,(lat+1))!=-1){ return false; }
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; }
	if (str.indexOf(dot,(lat+2))==-1){ return false; }
	if (str.indexOf(" ")!=-1){ return false; }
	return true;			
}

function focusError(item){
	item.focus();
	if ( item.style.backgroundImage && item.style.backgroundImage != "none" ){
		item.style.background='#110000';
		setTimeout("focusErrorDoForBg(document.getElementById('" + item.id + "'))", 2000);
	} else {
		item.style.background='#110000';
		setTimeout("focusErrorDo(document.getElementById('" + item.id + "'))", 2000);
	}
}
function focusErrorDo(item){
	item.style.background='#0c0c0c';
}
function focusErrorDoForBg(item){
	item.style.backgroundImage='url(images/inp_txt_back_01.gif)';
}

function iphone_bottom(){
	var i = genRand();
	var a = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="142" height="163" id="bottom_iphone" align="middle">';
	a += '<param name="allowScriptAccess" value="sameDomain" />';
	a += '<param name="wmode" value="transparent" />';
	a += '<param name="movie" value="bottom_iphone.swf?r='+i+'" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#000000" /><embed src="bottom_iphone.swf?r='+i+'" quality="high" bgcolor="#000000" width="142" height="163" name="bottom_iphone" wmode="transparent" align="middle" allowScriptAccess="sameDomain" menu="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	a += '</object>';
	document.write(a);
}

function genRand(){
	var i = Math.round(100000000*Math.random());
	return i;
}