function addcheck()
{
	var msg = "";
	if(document.industry.name.value=="")
	{
		msg += "Please enter Name\n";
	}
	if (document.industry.tfile.value=="")
	{
		msg += "Please browse Thumbnail File\n";
	}
	if (document.industry.bfile.value=="")
	{
		msg += "Please browse Main Image File\n";
	}

	if(msg!="")
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
}
function editcheck()
{
	var msg = "";
	if(document.industry.name.value=="")
	{
		msg += "Please enter Name\n";
	}
	if(msg!="")
	{
		alert(msg);
		return false;
	}
	else
	{
		return true;
	}
}
function showoption()
{
	document.getElementById("showoption").style.display = "";
	document.getElementById("closeoption").focus();
}
function hideoption()
{
	document.getElementById("showoption").style.display = "none";
}
function showhideindustries()
{
	var total = document.industry.totalindustries.value;
	if(document.industry.industries.checked)
	{
		for(i=0;i<total;i++)
		{
			ck = eval('"industry'+i+'"');
			document.getElementById(ck).checked = true;
		}
	}
	else
	{
		for(i=0;i<total;i++)
		{
			ck = eval('"industry'+i+'"');
			document.getElementById(ck).checked = false;
		}
	}
}
function showhideindustries2()
{
	var total = document.industry.totalindustries.value;
	var msg = "";
	for(i=0;i<total;i++)
	{
		ck = eval('"industry'+i+'"');
		if(!document.getElementById(ck).checked)
		{
			msg += "false";
		}
	}
	if(msg!="")
	{
		document.industry.industries.checked = false;
	}
	else
	{
		document.industry.industries.checked = true;
	}
}
function showhidetechnologies()
{
	var total = document.industry.totaltechnologies.value;
	if(document.industry.technologies.checked)
	{
		for(i=0;i<total;i++)
		{
			ck = eval('"technology'+i+'"');
			document.getElementById(ck).checked = true;
		}
	}
	else
	{
		for(i=0;i<total;i++)
		{
			ck = eval('"technology'+i+'"');
			document.getElementById(ck).checked = false;
		}
	}
}
function showhidetechnologies2()
{
	var total = document.industry.totaltechnologies.value;
	var msg = "";
	for(i=0;i<total;i++)
	{
		ck = eval('"technology'+i+'"');
		if(!document.getElementById(ck).checked)
		{
			msg += "false";
		}
	}
	if(msg!="")
	{
		document.industry.technologies.checked = false;
	}
	else
	{
		document.industry.technologies.checked = true;
	}
}


function selectoption(check,type)
{
	if(check.checked){
		document.industry.location2.options[0] = new Option(check.title,'');
	}
	else
	{
		if(type=="ind")
		{
			var j=0;
			var total = document.industry.totalindustries.value;
			for(i=0;i<total;i++)
			{
				ck = eval('"industry'+i+'"');
				if(document.getElementById(ck).checked)
				{
					document.industry.location2.options[0] = new Option(document.getElementById(ck).title,'');
				}
				else
				{
					j++;
				}
			}
			var k=0;
			var total2 = document.industry.totaltechnologies.value;
			for(i=0;i<total2;i++)
			{
				ck = eval('"technology'+i+'"');
				if(!document.getElementById(ck).checked)
				{
					k++;
				}
			}
		}
		if(type=="tech")
		{
			var j=0;
			var total = document.industry.totalindustries.value;
			for(i=0;i<total;i++)
			{
				ck = eval('"industry'+i+'"');
				if(!document.getElementById(ck).checked)
				{
					j++;
				}
			}
			var k=0;
			var total2 = document.industry.totaltechnologies.value;
			for(i=0;i<total2;i++)
			{
				ck = eval('"technology'+i+'"');
				if(document.getElementById(ck).checked)
				{
					document.industry.location2.options[0] = new Option(document.getElementById(ck).title,'');
				}
				else
				{
					k++;
				}
			}
		}
		if((j==total)&&(k==total2))
		{
			document.industry.location2.options[0] = new Option('- select location -','');
		}
		if((j!=total)&&(k==total2))
		{
			var total = document.industry.totalindustries.value;
			for(i=0;i<total;i++)
			{
				ck = eval('"industry'+i+'"');
				if(document.getElementById(ck).checked)
				{
					document.industry.location2.options[0] = new Option(document.getElementById(ck).title,'');
				}
			}
		}
		if((j==total)&&(k!=total2))
		{
			var total2 = document.industry.totaltechnologies.value;
			for(i=0;i<total2;i++)
			{
				ck = eval('"technology'+i+'"');
				if(document.getElementById(ck).checked)
				{
					document.industry.location2.options[0] = new Option(document.getElementById(ck).title,'');
				}
			}
		}
	}
}


function delete_all()
	{
	  var total = document.allindustry.total.value;
	  var check2 = "0";
	  for(i=0;i<total;i++)
	  {
		var c = eval('"ch'+i+'"');
		var ch = document.getElementById(c);
		if(ch.checked)
		{
			check2 = "1";
			i=total+1;
		}
	  }
	  if(check2 == "0")
	  {
		alert("No Recored is Selected.");
		return false;
	  }
	  else
	  {
		if(confirm("Are You Sure to Delete Seleted Records?"))
		{
			return true;
		}
		else
		{
			return false;
		}
	  }
}
function checkall()
{
	  var total = document.allindustry.total.value;
	  if(document.allindustry.ch.checked)
	  {
			for(i=0;i<total;i++)
			{
				var c = eval('"ch'+i+'"');
				var ch = document.getElementById(c);
				ch.checked = true;
			}
	  }
	  else
	  {
		  for(i=0;i<total;i++)
			{
				var c = eval('"ch'+i+'"');
				var ch = document.getElementById(c);
				ch.checked = false;
			}
	}
}
function checkall2()
{
	var total = document.allindustry.total.value;
	var msg = "";
	for(i=0;i<total;i++)
	{
		var c = eval('"ch'+i+'"');
		var ch = document.getElementById(c);
		if(!ch.checked)
		{
			msg += "false";
		}
	}
	if(msg!="")
	{
		document.allindustry.ch.checked = false;
	}
	else
	{
		document.allindustry.ch.checked = true;
	}
	  
}
function deleterecord(id)
{
	if(confirm("Are You Sure to Delete Seleted Records?"))
	{
		window.location.href= "manage-portfolio.php?action=delete&id="+id;
	}
}

function update_selected()
	{
	  var total = document.allindustry.total.value;
	  var check2 = "0";
	  for(i=0;i<total;i++)
	  {
		var c = eval('"ch'+i+'"');
		var ch = document.getElementById(c);
		if(ch.checked)
		{
			check2 = "1";
			i=total+1;
		}
	  }
	  if(check2 == "0")
	  {
		alert("No Recored is Selected.");
		return false;
	  }
	  else
	  {
		if(confirm("Are You Sure to update seleted Records?"))
		{
			document.allindustry.submit();
		}
		else
		{
			return false;
		}
	  }
}

function showurl(val)
{
	
	if(val)
	{
		document.getElementById("urlshow").style.display = '';
	}
	else{
		
		document.getElementById("urlshow").style.display = "none";
	}
}
function smallbig(val)
{
	if(val)
	{
		document.getElementById("ltit").style.display = 'none';
		document.getElementById("lkey").style.display = 'none';
		document.getElementById("lmdes").style.display = 'none';

		document.getElementById("ldes").style.display = 'none';
		document.getElementById("screen").style.display = 'none';
	}
	else{
		document.getElementById("ltit").style.display = '';
		document.getElementById("lkey").style.display = '';
		document.getElementById("lmdes").style.display = '';

		document.getElementById("ldes").style.display = '';
		document.getElementById("screen").style.display = '';
	}
}
function morefile()
{
	var page = parseInt(document.industry.totalscreen.value)+1;
	var div = eval('"morefile'+document.industry.totalscreen.value+'"');
	document.getElementById(div).innerHTML = "<img src='/images/loading2.gif' align='left'>Loading...";
	new Ajax.Updater(div, 'morefile.php?page='+page);
	document.industry.totalscreen.value = page;
}
function removefile(id)
{
	var div = eval('"removefile'+(id)+'"');
	document.getElementById(div).innerHTML = "";
	document.industry.totalscreen.value = parseInt(document.industry.totalscreen.value)-1;
}
function removefile2(id,iid,pid)
{
	var div = eval('"oldremovefile'+(id)+'"');
	document.getElementById(div).innerHTML = "<img src='/images/loading2.gif' align='left'>Loading...";
	window.location.href= "edit-portfolio.php?action=del&iid="+iid+"&id="+pid;

}
function addstats2(type,id)
{
	var url = "http://www.candidinfo.net/portfolio/stats.php";
	var pars = 'type=' + type + "&id=" +id;
	var myAjax = new Ajax.Request( url, { method: 'get', parameters: pars, onComplete: showResponse });
}
function showResponse(originalRequest)
{
		var data =  originalRequest.responseText;
		alert(data);
}

function addstats(type,id) {
	var strURL = "/portfolio/stats.php";
	var pars = 'type=' + type + "&id=" +id;
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	else
	{
		self.xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
	}

    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {

        if (self.xmlHttpReq.readyState == 4) {

			updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(pars);
	
}

function updatepage(str){
    if(str!="")
		alert(str);
}
function gotosite(url)
{
	window.location.href= url+"/";
}
function SetTime(url)
{
	setTimeout("gotosite('"+url+"')", 1000);
}
