function startWork() {
	var w,h;
	if (self.innerHeight) // all except Explorer
	{
		w = self.innerWidth;
		h = self.innerHeight;
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	else if (document.body) // other Explorers
	{
		w = document.body.clientWidth;
		h = document.body.clientHeight;
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	else // other Browsers
	{
		w = screen.availWidth;
		h = screen.availHeight;
		x = 0;
		y = 0;
	}

	if (document.getElementById) {
		var workingDiv = document.getElementById('working');
	} else if (document.all) {
		var workingDiv = document.all['working'];
	}
	
	var showMe = workingDiv.style;
	showMe.position = "absolute";
	showMe.display = showMe.display ? "":"block";
	showMe.left = ((w - 300)/2) + x;
	showMe.top = ((h - 60)/2) + y;
}

function validate(form) {
	form.Submit.disabled=true;
	form.Submit.value='Submitting Registration Form...';
	startWork();
	return true;
}

function emptyField(str) {
	if (str.length>0) 
		return false;
	else 
		return true;
}

function isValidChar(str,invalidChars) {
	var result = true;
	for (i = 0; i < str.length; i++) {
		if (invalidChars.indexOf(str.charAt(i)) != -1) result = false;
	}
	return result;
}

function checkField(field,invalidChars,isempty) {
	if (emptyField(field)==isempty && isValidChar(field,invalidChars))
		return true;
	else
		return false;
}

function doSelect(obj,num) {
	obSel = document.getElementById(obj);
	obSel.selectedIndex = num;
}

function popUp(url,wid,hei) {
	popup=window.open(url,'','width='+wid+',height='+hei+',scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no');
	popup.focus();
}

function doEdit(content) {
	popUp('/gdadmin/content_manage.asp?action=EDIT&content='+content,650,500);
}

function doDelete(content) {
	answer = confirm('Are you sure?\r\nAgreeing will permanently delete this content.');
	if (answer==true) {
		popUp('/gdadmin/content_manage.asp?action=DELETE&content='+content,650,450);
	}
}

function doAdd(cid,pid,size) {
	popUp('/gdadmin/content_manage.asp?action=ADD&cid='+cid+'&pid='+pid+'&size='+size,650,450);
}

function doBrowse(cid,pid,size,field,path) {
	url = '/gdadmin/content_browse.asp?cid='+cid+'&pid='+pid+'&size='+size+'&field='+field+'&path='+path;
	wid = 600;
	hei = 450;
	popup=window.open(url,'bwin','width='+wid+',height='+hei+',scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no');
	popup.focus();
}

function doUpload(cid,pid,size) {
	popUp('/gdadmin/content_upload.asp?cid='+cid+'&pid='+pid+'&size='+size,480,120);
}

function fillForm(vField,vValue) {
	eval("document.forms[0]."+vField+".value='/media"+vValue+"'");
	bwin=window.open('','bwin','');
	bwin.close();
}

function doChange(d,fyear,fmonth,fday) {
	myDate = new Date(d);
	myYear = myDate.getYear();
	// Y2K Bug Fix
	if (myYear < 2000) myYear += 1900;
	myMonth = myDate.getMonth()+1;
	myDay = myDate.getDate();
	// Set the dropdowns for month, date, year
	if (fyear!=='') {
		yfield = eval('document.form1.'+fyear);
		setSelect(yfield,myYear);
	}
	if (fmonth!=='') {
		mfield = eval('document.form1.'+fmonth);
		setSelect(mfield,myMonth);
	}
	if (fday!=='') {
		dfield = eval('document.form1.'+fday);
		setSelect(dfield,myDay);
	}
}

function setSelect(f,v) {
	for(i = 0; i < f.length; i++) {
		if(f[i].value == v) {
			f.selectedIndex = i;
		}
	}	
}

function checkTypePayment(obj){
  if (obj.options[obj.selectedIndex].value!='NULL'){
    tmp_paymentid=obj.options[obj.selectedIndex].value
  }else{
    obj.value=tmp_paymentid;
  }
}
  
function CheckForm(obj){
  if (obj.paymentid.options[obj.paymentid.selectedIndex].value=='NULL'){
     alert(set_lang['SELECT_PAYMENT_OPTION']);
     obj.paymentid.focus();
     return false;
  }
  
  return TRUE;
}
