function profiledisplay(field, val) {
	var target_id;
	
	switch (field) {
		case 'fn': target_id = 'profile_pdfn_eg'; break;
		case 'sn': target_id = 'profile_pdsn_eg'; break;
		case 'c': target_id = 'profile_pdc_eg'; break;
		case 'jt': target_id = 'profile_pdjt_eg'; break;
		default: return false;
	}
	
	document.getElementById(target_id).innerHTML = val;
}

function numbersOnly(id) {
	document.getElementById(id).value = document.getElementById(id).value.replace(/[^0-9,.]/g, '');
}
function showhide(id1, id2) {
	var currentStyle = document.getElementById(id1).className;
	if (currentStyle == "show") {
		document.getElementById(id1).className = "hide";
		document.getElementById(id2).className = "show";
	} else {
		document.getElementById(id1).className = "show";
		document.getElementById(id2).className = "hide";
	}
}
function deletelogo(id) {
	if (confirm('Are you sure you want to delete the logo for this job post?')) {
		document.getElementById('phodel').value = 'yes';
		document.getElementById('job_logo_image').className = "hide";
		showhide('job_logo_browse','job_logo_change');
	} else {
		return false;
	}
}
function deleteimage() {
	if (confirm('Are you sure you want to delete your profile photo?')) {
		return true;
	} else {
		return false;
	}
}
function deleteresume() {
	if (confirm('Are you sure you want to delete your resume?')) {
		return true;
	} else {
		return false;
	}
}
function deletejob(dotdotpath, id) {
	if (confirm("Are you sure you want to delete this job?")) {
		document.location = dotdotpath + "_include/asp/post_Job_Delete.asp?id=" + id;
	} else {
		return false;
	}
}
function checkfiletype(id, ext) {
	var val = document.getElementById(id).value;
	var format = "";
	if (String(val).length < 3)
		format = val;
	else {
		var iLen = String(val).length;
		format = String(val).substring(iLen-3, iLen);
	}
	
	if (id == 'photo') {
		if (format == 'bmp' || format == 'gif' || format == 'jpg' || format == 'png') {
			return true;
		} else {
			document.getElementById('photo_message_box').style.display = '';
			return false;
		}
	}
	else if (format == ext) {
		return true;
	} else {
		document.getElementById('resume_message_box').style.display = '';
		return false;
	}
}
function findadev(dotdotpath) {
	q = document.getElementById('search_q').value;
	l = document.getElementById('search_l').value;
	
	if (q == 'eg. Java') { q = ''; }
	if (l == 'eg. Palo Alto, CA') { l = ''; }
	
	document.location = dotdotpath + 'profiles/?q=' + q + '&l=' + l;
}

function talent_store(i, v) {
	document.getElementById('talent_0' + i + '_v').value = v;
	
	var v_txt = '';
	
	switch (v) {
		case 0:;
		case 1: v_txt = 'Basic'; break;
		case 2: v_txt = 'Average'; break;
		case 3: v_txt = 'Good'; break;
		case 4: v_txt = 'Excellent'; break;
		case 5:;
		case 6: v_txt = 'Expert'; break;
		default: v_txt = ''; break;
	}
	document.getElementById('talent_0' + i + '_txt_disp').innerHTML = v_txt;
}

function profile_country_change() {
	var new_country = document.getElementById('profile_co').value;
	var new_state = '';
	
	switch (new_country) {
		case 'United States': new_state = 'state'; break;
		case 'Canada':;
		case 'France': new_state = 'province'; break;
		case 'United Kingdom': new_state = 'county'; break;
		case 'Australia': new_state = 'territory'; break;
		default: new_state = 'state'; break;
	}
	document.getElementById('profile_s_label').innerHTML = new_state;
}
function job_country_change() {
	var new_country = document.getElementById('job_co').value;
	var new_state = '';
	
	switch (new_country) {
		case 'us': new_state = 'state'; break;
		case 'ca':;
		case 'fr': new_state = 'province'; break;
		case 'gb': new_state = 'county'; break;
		case 'au': new_state = 'territory'; break;
		default: new_state = 'state'; break;
	}
	document.getElementById('job_s_label').innerHTML = new_state;
}

function popup(url,winname,w,h,feat)
{
	if (!(isNaN(w) || isNaN(h)))
	{
		var x=parseInt((screen.width-w)/2);
		var y=parseInt((screen.height-h)/2);
		if (x<0)	x=0;
		if (y<0)	y=0;
		
		if (feat!=null && feat!="")
		{
			feat=","+feat;
		}
		else
		{
			feat="";
		}
		feat="left="+x+",top="+y+",width="+w+",height="+h+feat;
	}
	window.open(url,winname,feat);
}

function imageSwap(dotdotpath, overOut, targetID, image) {
	var imageSuffix = "";
	if (overOut == "over") {
		imageSuffix = "_over";
	}
		
	document.getElementById(targetID).src = dotdotpath + "images/" + image + imageSuffix + ".jpg";
}

function linkToGame(gameTitle) {
	document.f_linkToGame.S_barBox.value = gameTitle;
	document.f_linkToGame.submit();
}

function cmsDelete(dotdotpath, GID) {
	var msg = "Are you sure you want to delete this title?";
	if (confirm(msg)) {
		document.location = dotdotpath + "_include/asp/post_Game_Delete.asp?id=" + GID;
	}
}

function creditDelete(dotdotpath, GID, CID) {
	var msg = "Are you sure you want to delete this credit?";
	if (confirm(msg)) {
		document.location = dotdotpath + "directory/credits/del.asp?id=" + GID + "&cid=" + CID;
	}
}

function showHidePlatforms() {
	if (document.CMSPlatformsShowHide == 1) {
		document.getElementById("PlatformsTier10").style.display = "none";
		document.CMSPlatformsShowHide = 0;
	} else {
		document.getElementById("PlatformsTier10").style.display = "";
		document.CMSPlatformsShowHide = 1;
	}
}

function JobTeaserUpdate() {
	document.f.JobTeaserUpdate.value = document.f.JobTeaser.length;
}

function showhideanswer(upperLimit)	{
	var answers=parseInt(selectgetvalue("BulletPointsCount"))
	for (var i=1; i<=answers; i++)
	{
		document.getElementById("bulletpoint_"+i).style.display="";
		//document.all["link"+i].style.display="";
	}
	for (var i=answers+1; i<=upperLimit; i++)
	{
		document.getElementById("bulletpoint_"+i).style.display="none";
	}
}

// CART FUNCTIONS
function cart_init() {
	document.cart_c = 1;
	document.cart_s = 1;
	document.cart_q = 1;
}
function set_cart_colour(d, v, pu) {
	document.cart_c = v;
	
	document.getElementById("product_big").src = d + "_images/products/" + pu + "_big_01.jpg";
}
function addtocart(d, p) {
	c = document.cart_c;
	s = document.getElementById("ProductSize").value;
	q = document.getElementById("ProductQuantity").value;
	
	document.location = d + "store/basket/add/?p=" + p + "&c=" + c + "&s=" + s + "&q=" + q;
}
function updatecart(d, cp) {
	q = document.getElementById("ProductQuantity_" + cp).value;
	
	document.location = d + "store/basket/update/?cp=" + cp + "&q=" + q;
}
function removefromcart(d, cp) {
	document.location = d + "store/basket/remove/?cp=" + cp;
}