function addIdToUrl(projectId){
	var newURL = trueURL+"#"+projectId;
	window.location.href=newURL;
}
  
function loadProject(projectId, section){
	
	$.post("/scripts/php/postFunctions.php",{callFunction:"loadProject", projectId:projectId, section:section}, function(data){
  		//alert(data);
		$("#loadProject").html(data);
		
		addIdToUrl(projectId);
 	});
	
}


function loadImage(tgt, src, alt, info, titleTgt){
 
	//alert(src+" _ "+alt+" - "+info); 
	
	$("#"+tgt).attr({src:src,alt:alt});
	
	$("#"+titleTgt+"").html(alt+"<p>"+info+"</p>");
	
	
}

function subscribe(email){
	
	if(!email || email=="thank you!" || email=="your email..."){
		
		alert("you need to enter an email!");
		
		$('#subEmail').val('your email...')
		
	}else{
	
		$.post("/scripts/php/postFunctions.php",{callFunction : "subscribe", email : email}, function(data){		
			//alert(data);
			$('#subEmail').val('thank you!')
	});
	
	}

}

function unsubscribe(email, val){
 	$.post("/scripts/php/postFunctions.php",{callFunction : "unsubscribe", email:email, val:val}, function(data){		
	
		window.location.reload();
		
			$('#subEmail').val('thank you!')
		//alert(data);
		
	});

}

function flashLink(){
	
	var strHref = window.location.href;
	
	if ( strHref.indexOf("#") > -1 ){
		
		var newUrlArray=strHref.split("#");
		
		//alert("got # "+strHref+" new:"+newUrlArray[0]+newUrlArray[1]);
		//window.location.href ="http://www.roguefilms.com"+newUrlArray[1];
		
		return newUrlArray[1];
	}
	
 
}

function putHref(href) { 
	//alert(href);
	location.href = href; 
}





function deleteItem(table,itemField,itemId,itemToKill){
	
	var agree=confirm("Are you sure you wish to delete this item?");
	
		if (agree){
			$.post("/scripts/php/postFunctions.php",{callFunction : "deleteItem", table : table, itemField : itemField, itemId : itemId}, function(data){
 			
			if(removeItem){
				removeItem(itemToKill);
			}	
		
			window.location.reload();
		});
		
	}

}




function removeItem(itemToKill){
	
		$(itemToKill).remove();

}



function insert_bbcode(v, tgt){
 	
	try {
		if (document.selection){
			var str = document.selection.createRange().text;
			document.forms['contentForm'].elements[tgt].focus();
			var sel = document.selection.createRange();
			sel.text = "<" + v + ">" + str + "</" + v + ">";
			return;
		}else if ((typeof document.forms['contentForm'].elements[tgt].selectionStart) != 'undefined') {
			var txtarea = document.forms['contentForm'].elements[tgt];
			var selLength = txtarea.textLength;
			var selStart = txtarea.selectionStart;
			var selEnd = txtarea.selectionEnd;
			var s1 = (txtarea.value).substring(0,selStart);
			var s2 = (txtarea.value).substring(selStart, selEnd)
			var s3 = (txtarea.value).substring(selEnd, selLength);
			if(v =="a"){
				txtarea.value = s1 + "<a href='http://YOURLINK' target='_blank'>" + s2 + '</a>' + s3;
			}else{
				txtarea.value = s1 + '<' + v + '>' + s2 + '</' + v + '>' + s3;
			}
				txtarea.selectionStart = s1.length;
				txtarea.selectionEnd = s1.length + 5 + s2.length + v.length * 2;
			return;
		}
		else {

		}
	}
	catch(e){
	}
	
}