function setBG() {
	sh = ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight );
	sw = ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth );
	if (sw < 600) {
		$("#bgbox").hide();
	} else {
		$("#bgbox").show();
		size = (sw / sh);
		$("#bgbox").css("height", sh + "px");
		$("#screen").css({'height': sh, 'width': sw});
		if (size > 1.61904) {
			wnum = (sw / 1700);
			newh = (1050 * wnum);
			$("#bg").css("width", (sw + .1) + "px");
			$("#bg").css("height", newh + "px");
		} else {
			hnum = (sh / 1050);
			neww = (1700 * hnum);
			$("#bg").css("width", neww + "px");
			$("#bg").css("height", sh + "px");
			$("#bg").css("left", "-" + ((neww - sw) / 2) + "px");
		}
	}
}
function getSize() {
	sh = ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight );
	sw = ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth );
	boxh = $("#bgbox").css("height");
	boxw = $("#bgbox").css("width");
	bgh = $("#bg").css("height");
	bgw = $("#bg").css("width");
	alert('Screen\n\nwidth: ' + sw + '\nheight: '+ sh + '\n\nbgbox\n\nwidth: ' + boxw + '\nheight: '+ boxh + '\n\nbg\n\nwidth: ' + bgw + '\nheight: '+ bgh);
}
function getContacts(type,name) {
	$('#searching').fadeIn('fast');
	var currentHref = window.location.href;
	window.location.href = currentHref.substr(0, currentHref.lastIndexOf("#")) + "#" + type + "=" + escape(name);
	$.get('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type + '&checkNum=1', function(data) {
		checkNum = data;
		if ($("#contactlist").is(":visible")) {
			$("#contactlist").slideUp("fast");
		}
		if (type != "submarket" && checkNum > 3) {
			$('#choices').slideUp('fast', function() {
				$('#choices').load('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type, function() {
					$('#choices').slideDown('fast', function() {
						if (type != "submarket") {
							$('#criteria').load('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type + '&criteria=1');
						}
						$('#searching').fadeOut('fast');
					});
				});
			});
		} else {
			$('#contactlist').load('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type + '&list=1', function() {
				$('#contactlist').slideDown('fast', function() {
					if (type != "submarket") {
						$('#criteria').load('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type + '&criteria=1');
					}
					$('#searching').fadeOut('fast');
				});
			});
		}
	});
}
function resetContacts(type,name) {
	$('#searching').fadeIn('fast');
	if ($("#contactlist").is(":visible")) {
		$("#contactlist").slideUp("fast");
	}
	if (type == "world") {
		resets = "#continenttxt, #countrytxt, #statetxt, #markettxt, #submarkettxt";
		// var currentHref = window.location.href;
		// window.location.href = currentHref.substr(0, currentHref.lastIndexOf("#"));
	} else if (type == "continent") {
		resets = "#countrytxt, #statetxt, #markettxt, #submarkettxt";
	} else if (type == "country") {
		resets = "#statetxt, #markettxt, #submarkettxt";
	} else if (type == "state") {
		resets = "#markettxt, #submarkettxt";
	} else if (type == "market") {
		resets = "#submarkettxt";
	}
	$('#choices').slideUp('fast', function() {
		$('#choices').load('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type, function() {
			$('#choices').slideDown('fast', function() {
				$('#criteria').load('/includes/handle_get_contacts.php?selection=' + escape(name) + '&type=' + type + '&criteria=1');
				$(resets).html('&nbsp;');
				$('#searching').fadeOut('fast');
			});
		});
	});
}
function loadContacts() {
	if(window.location.hash) {
		hash = window.location.hash;
		myhash = hash.split("=");
		getContacts(myhash[0].substr(1),myhash[1]);
	} else {
		return;
	}
}
function showProfile(id) {
	$("#d" + id).toggle("fast", function() {
		if ($("#a" + id).html() == "Click to hide profile") {
			$("#a" + id).html("Click to view profile");
		} else {
			$("#a" + id).html("Click to hide profile");
		}
	});
}
/*********************************************************************
 * @Author Hamid Alipour Codehead @ webmaster-forums.code-head.com		
**/
function get_object(id) {
	var object = null;
	if( document.layers )	{			
		object = document.layers[id];
	} else if( document.all ) {
		object = document.all[id];
	} else if( document.getElementById ) {
		object = document.getElementById(id);
	}
	return object;
}
function is_child_of(parent, child) {
	if( child != null ) {			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}
function fixOnMouseOut(element, event, JavaScript_code) {
	var current_mouse_target = null;
	if( event.toElement ) {				
		current_mouse_target 			 = event.toElement;
	} else if( event.relatedTarget ) {				
		current_mouse_target 			 = event.relatedTarget;
	}
	if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
		eval(JavaScript_code);
	}
}
/*********************************************************************/
function changeText(id,text) {
	document.getElementById(id).innerHTML = text;
}
function valCaptcha(myform) {
	ValidateForm(myform);
	if (checkForm == 0) {
		res = $.ajax({
			type: "GET",
			url: "/cms/live/handle_recaptcha_validate.php?challenge=" + document.forms[myform].elements['recaptcha_challenge_field'].value + "&response=" + document.forms[myform].elements['recaptcha_response_field'].value,
			async: false
		}).responseText;
		if (res == 0) {
			alert("The varification characters you typed were incorrect. Please try again.");
			Recaptcha.reload();
			document.forms[myform].elements['recaptcha_response_field'].focus();
		} else {
			document.forms[myform].submit();
		}
	} else {
		checkForm = 0;
	}
}
// --------------------- SHOW LANGUAGES ---------------- //
function showLang() {
	$("#langlist").show('fast');
}















