function pageScroll()
{
		window.scrollBy(-30, -30); 
		scrolldelay = setTimeout('pageScroll()',10);
		stopScroll();
}	

function stopScroll()
{
		myHeight = document.body.scrollTop;
		if(myHeight <= 0)
		{	
			clearTimeout(scrolldelay);
		}
}

function changeURL(url)
{
	var id = document.getElementById('searching');
	id.action = "index.php?"+url;
	id.submit();
}

function status_change(value, code)
{
	var id = document.getElementById('searching');

	if(value == "no")
	{
		document.getElementById('status').value = "yes";
	}
	else
	{
		document.getElementById('status').value = "no";
	}
	
	document.getElementById('code').value = code;
	id.submit();
}

function saveRecord(no)
{
	var id = document.getElementById('searching');

	document.getElementById('no').value = no;
	
	id.submit();
}

function deleteRecord(no)
{
	var r=confirm("Are you sure you want to delete this product?")
	if(r==true)
	{
		document.getElementById('no').value = no;
		document.getElementById('del').value = true;
		
		var id = document.getElementById('searching');
		id.submit();		
	}
}

function deleteClient(id, form)
{
	var r=confirm("Are you sure you want to delete this record?")
	if(r==true)
	{
		document.getElementById('id').value = id;
		document.getElementById('delete').value = true;
		
		var id = document.getElementById(form);
		id.submit();		
	}
}

function newWindow(path, name, height, width)
{
	parentWindow = window.open(path, name, "location=no, directories=no, menubar=no, toolbar=no, status=no, scrollbars=yes, resizable=yes, height="+height+", width="+width);
}

function validate_inputs(form_id, submit_name)
{
	var val = "";
	var item = "";
	var error = "";
	var	item_id = "";
	var elem = document.getElementById(form_id).elements;
	
	for(var i = 0; i < elem.length; i++)
	{
		var itm= elem[i].name;
		item = itm.toString();
		
		var item_val = elem[i].value;
		item_val = item_val.toString();
		
		if(item.search("-") > -1 && item_val == "")
		{	
			item_id += "required_"+item.substring(1);
			error += item_id;

			document.getElementById(item_id).innerHTML = "<span class='required'>"+document.getElementById(item_id).innerHTML+"</span>";
			//document.getElementById('notification').innerHTML = "<br><em>please fill in all the required fields!</em><br><br>";			
		}
		item_id = "";
	} 
	
	document.getElementById(submit_name).value = 'submit';
	
	var form = document.getElementById(form_id);

	if(error == "")
	{
		alert(form_id);
		alert(submit_name);
		form.submit();
	}	
}

var image_count = 2;

function multiple_files(object)
{
	if(image_count < 5)
	{
		var ni = document.getElementById('image_content');
		
		var newdiv = document.createElement('div');
		
		newdiv.setAttribute('id',image_count);
		//newdiv.innerHTML = object.value+"&nbsp;&nbsp;/&nbsp;&nbsp;<a style='cursor:pointer' onclick=\"remove_file('"+image_count+"')\">delete</a>";
		newdiv.innerHTML = "<a style='cursor:pointer' onclick=\"remove_file('"+image_count+"')\">delete</a>&nbsp;&nbsp;/&nbsp;&nbsp;<input type='file' class='box' name='image"+image_count+"' accept='jpg' onchange=\"multiple_files(this)\"/>";
		ni.appendChild(newdiv);
		document.getElementById('image_path').value += object.value+", ";
		//document.getElementById('tmp_name').value += object.value+", ";
		
		image_count++;
	}
	else
	{
		alert('Only 4 image uploads are allowed!');
	}
}

function remove_file(id)
{
  var d = document.getElementById('image_content');
  var olddiv = document.getElementById(id);
  d.removeChild(olddiv);
}

function preload_images()
{
	images = new Array();
	
	images[0]="resume/autofind.png";
	images[1]="resume/cosmo.png";
	images[2]="resume/fia.png";
	images[3]="resume/joutaal.png";
	images[4]="resume/technolase.png";	
	images[5]="resume/urbangreen.png";	
	images[6]="images/header.png";
	images[7]="images/content_images/home.jpg";
	images[8]="images/content_images/services.jpg";	
	images[9]="images/content_images/contact us.jpg";	
	images[10]="resume/kickass.png";	
	images[11]="resume/franco.png";		
	
	for(i=0; i<=images.length; i++) 
	{
		var img = new Image(300, 200);
		img.src=images[i];
	}

}

function image_change(name)
{
	document.getElementById('resume_pic').src = './resume/' + name + '.png';
}

var xmlhttp;
var div_id;

function showContent(str, url, id)
{
	div_id = id;
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	//var url="getcustomer.asp";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById(div_id).innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function image_load()
{
	if(document.images)
	{
		var img_arr = new Array();
		
		img_arr[0] = "autofind";
		img_arr[1] = "braamleroux";
		img_arr[2] = "mortgage";
		img_arr[3] = "joutaal";
		img_arr[4] = "urbangreen";
		
		for(x=0; x<5; x++)
		{
			img_arr[x] = new Image(300,200); 
			img_arr[x].src="./resume/" + img_arr[x] + '.png'; 
		}
	}
}