// Last Modified: 7/1/08 - ki

var isSafari = (navigator.userAgent.indexOf('Safari') != -1) ? true : false;

function display(obj) {
	var doc = document.getElementById(obj).style;
	doc.display = "inline";
	
}

function displayText(obj) {
	var doc = document.getElementById(obj).style;
	
	doc.display = "inline";
	
}

function displayNext(obj, num) {
	var newnum;
	var nextnum;
	
	newnum = num + 1;
	newnum = end(newnum, designEnd, section);
	nextnum = whichOrder(project, newnum);
	display(obj+nextnum);
	designCurrent = newnum;
		
}

function displayPrevious(obj, num) {
	var newnum;
	var previousnum;
	
	newnum = num - 1;
	newnum = begin(newnum, designEnd, section);
	previousnum = whichOrder(project, newnum);
	display(obj+previousnum);
	designCurrent = newnum;
	
}

function hideAllMain(obj,tot) {

	for (var i = 0; i < tot; i++) {
		var j = whichOrder(project, i);
		var doc = document.getElementById(obj+j).style;
		doc.display = "none";

	}
}

function hideAll(obj,tot) {
	for (var i = 1; i <= tot; i++) {
		var doc = document.getElementById(obj+i).style;
		doc.display = "none";
	}
}

function hide(obj) {
	var doc = document.getElementById(obj).style;
	doc.display = "none";
}

function end(num, tot, sec) {
	if (num == tot)
	{
		if (sec == section_total) {
			window.location = "design.php?subpage=" + nextProject(project) + "#bottom";
		} else {
			sec = sec + 1;
			window.location = "design.php?subpage=" + project + "&part=" + sec + "#bottom";
		}

	} else 
	{
		return num;
	}
}

function begin(num, tot, sec) {

	if (num == -1)
	{
		if (sec == 1) {
			window.location = "design.php?subpage=" + previousProject(project) + "#bottom";
		} else {
			sec = sec - 1;
			window.location = "design.php?subpage=" + project + "&current=5" + "&part=" + sec + "#bottom";
		}
	} else 
	{
		return num;
	}
}

function nextProject(currentProj) {
	switch (currentProj)
	{
		case "gh":
			return "il";
			break;
		case "il": 
			return "pub";
			break;
		case "pub":
			return "lo";
			break;
		case "lo":
			return "pos";
			break;
		case "pos":
			return "prod";
			break;
		case "prod":
			return "fo";
			break;
		case "fo":
			return "prom";
			break;
		case "prom":
			return "type";
			break;
		case "type":
			return "web";
			break;
		case "web":
			return "oth";
			break;
		case "oth":
			return "gh";
			break;
	
	}
}

function previousProject(currentProj) {
	switch (currentProj)
	{
		case "gh":
			return "oth&&part=" + section_total_previous + "&current=" + designOrder_oth_end.length;
			break;
		case "il": 
			return "gh&part=" + section_total_previous + "&current=" + designOrder_gh_end.length;
			break;
		case "pub":
			return "il&part=" + section_total_previous + "&current=" + designOrder_il_end.length;
			break;
		case "lo":
			return "pub&part=" + section_total_previous + "&current=" + designOrder_pub_end.length;
			break;
		case "pos":
			return "lo&part=" + section_total_previous + "&current=" + designOrder_lo_end.length;
			break;
		case "prod":
			return "pos&part=" + section_total_previous + "&current=" + designOrder_pos_end.length;
			break;
		case "fo":
			return "prod&part=" + section_total_previous + "&current=" + designOrder_prod_end.length;
			break;
		case "prom":
			return "fo&part=" + section_total_previous + "&current=" + designOrder_fo_end.length;
			break;
		case "type":
			return "prom&part=" + section_total_previous + "&current=" + designOrder_prom_end.length;
			break;
		case "web":
			return "type&part=" + section_total_previous + "&current=" + designOrder_type_end.length;
			break;
		case "oth":
			return "web&&part=" + section_total_previous + "&current=" + designOrder_web_end.length;
			break;
	
	}
}


var allImgs = new Array();

function preloadImages() {
	for (var i=0; i < allImgs.length; i=i+2) {
		preloadImage(allImgs[i], allImgs[i+1]);
	}
}

function preloadImage(obj, tot) {
	for (var i=1; i < tot; i++) {
		var img = new Image();
		img.src = "images/" + obj + i + ".jpg";
	}
}


var waktu=0;

function kiri(){
isi.scrollBy(-10,0);waktu=setTimeout('kiri()',60);
}
function kanan(){
isi.scrollBy(10,0);waktu=setTimeout('kanan()',60);
}
function selesai() {
clearTimeout(waktu);
}

function changeDisp(obj, num, tot) {
	for (var i = 1; i <= tot; i++) {
		var sub = document.getElementById(obj+i).style;
		if (i == num) {
			if (sub.display == "block") {
				sub.display = "none";
				decreaseHeight('scrollArea2', 450);
			} else {
				sub.display = "block";
			}
		} else {
			sub.display = "none";
			decreaseHeight('scrollArea2', 450);
		}
	}
}

function closeDisp(obj, tot) {
	for (var i = 1; i <= tot; i++) {
		var sub = document.getElementById(obj+"Cont"+i).style;
		var sub2 = document.getElementById(obj+i).style;
			sub.display = "none";
			sub2.display = "inline";
	}
}

function increaseHeight(obj, height) {
	var doc = window.top.document.getElementById(obj).style;
	doc.height = height;
}

function decreaseHeight(obj, height) {
	var doc = window.top.document.getElementById(obj).style;
	doc.height = height;
}


function checkForm()
{
   var cname, cemail;
   with(window.document.elistform)
   {
      cname    = name;
      cemail   = email;
   }

   if(trim(cname.value) == '')
   {
      alert('Please enter your name');
      cname.focus();
      return false;
   }
   else if(trim(cemail.value) == '')
   {
      alert('Please enter your email');
      cemail.focus();
      return false;
   }
   else if(!isEmail(trim(cemail.value)))
   {
      alert('Email address is not valid');
      cemail.focus();
      return false;
   }
      else
   {
      cname.value    = trim(cname.value);
      cemail.value   = trim(cemail.value);
      return true;
   }
}

 function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function isEmail(str)
{
   var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|ame|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|k|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;

return regex.test(str);
}
