function initRotation() {
	t = setTimeout(function(){ 
		rotate = startRotation(1);
	}, 7000);
}
function startRotation(num) {
	if (num != 3) {
		$('#slide' + num).fadeOut('fast', function() {
			num = num + 1;
			$('#slide' + num).fadeIn('fast');
			t = setTimeout(function(){ 
				startRotation(num);
			}, 7000);
		});
	} else {
		$('#slide' + num).fadeOut('fast', function() {
			num = 1;
			$('#slide' + num).fadeIn('fast');
			t = setTimeout(function(){ 
				startRotation(num);
			}, 7000);
		});
	}
}
function showBucket(id) {
	$("#show" + id).slideDown("fast");
}
function hideBucket(id) {
	$("#show" + id).slideUp("fast");
}
/*********************************************************************
 * @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 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");
		}
	});
}
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;
	}
}

















