function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
	
  if (elm.addEventListener){
	  
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
	  
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 
/**************************************************************************************************************/
// Create xmlhttp object based on browsertype
function getHTTPObject() {
	if (window.XMLHttpRequest)
	{
		  // If IE7, Mozilla, Safari, etc: Use native object
		  var xmlHttp = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject)
		{
		  // ...otherwise, use the ActiveX control for IE5.x and IE6
		  var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

/**************************************************************************************************************/
// Report media as spam/stolen/etc
function deleteImage(id, obj) {
	var sure = confirm ("Are you sure you want to delete this image?");
	if (sure)
	{
		obj.src = '/users/database/progress_circle.gif';
		

		var url = 'delete.php?image_id=' + id;

		

		loadHttp = getHTTPObject();
		loadHttp.open("GET", url, true);
		loadHttp.onreadystatechange = function()
		{
			if (loadHttp.readyState == 4)
			{
				if (loadHttp.responseText.indexOf('invalid') == -1)
				{
					obj.style.display="none";
				}
			}
		};
		loadHttp.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){
//		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
//		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
//		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
//		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
//		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
//		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
//		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
///////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////Floating message//////////////////////////////////////////////
function showfloatmessage(msg)
{
	$("float_message").innerHTML = msg;
	$("float_message").show();
}

function hidefloatmessage()
{
	$("float_message").innerHTML = "";
	$("float_message").hide();
}
