function datacheck() {
	selectallatt();
	document.frmarticle.submit();
}

function addelement(page, elementtype) {
	selectallatt();
	document.frmarticle.action = page;
	document.frmarticle.hdAddElement.value = elementtype;
	document.frmarticle.frmaction.value = '';
	document.frmarticle.submit();
}

function delelement(page, elindex) {
	selectallatt();
	document.frmarticle.action = page;
	document.frmarticle.hdDelElement.value = elindex;
	document.frmarticle.frmaction.value = '';
	document.frmarticle.submit();
}

function upelement(page, elindex) {
	selectallatt();
	document.frmarticle.action = page;
	document.frmarticle.hdUpElement.value = elindex;
	document.frmarticle.frmaction.value = '';
	document.frmarticle.submit();
}

function downelement(page, elindex) {
	selectallatt();
	document.frmarticle.action = page;
	document.frmarticle.hdDownElement.value = elindex;
	document.frmarticle.frmaction.value = '';
	document.frmarticle.submit();
}

function selectallatt() {
	var i, j, it, it2, tmp
	if (document.frmarticle.hdTotalAtt.value > 0) {
		for (i=0;i<document.frmarticle.hdTotalAtt.value;i++) {
			tmp = document.forms['frmarticle'].elements['hdAttName' + i].value;
			it = document.forms['frmarticle'].elements[tmp];
			for (j=0; j<it.length; j++) {
				it.options[j].selected = true;
				it2 =document.forms['frmarticle'].elements[tmp+'s'];
				if (it2.value != '')
				{
					it2.value = it2.value + ',';
				}
				it2.value = it2.value + it.options[j].value;
			}
		}
	}
	for (i=0;i<document.frmarticle.relateddoc.length;i++) {
		document.frmarticle.relateddoc.options[i].selected = true;
		if (document.frmarticle.relateddocs.value != '')
		{
			document.frmarticle.relateddocs.value = document.frmarticle.relateddocs.value + ',';
		}
		document.frmarticle.relateddocs.value = document.frmarticle.relateddocs.value + document.frmarticle.relateddoc.options[i].value;
	}
	for (i=0;i<document.frmarticle.otherdoc.length;i++) {
		document.frmarticle.otherdoc.options[i].selected = true;
		if (document.frmarticle.otherdocs.value != '')
		{
			document.frmarticle.otherdocs.value = document.frmarticle.otherdocs.value + ',';
		}
		document.frmarticle.otherdocs.value = document.frmarticle.otherdocs.value + document.frmarticle.otherdoc.options[i].value;
	}
	for (i=0;i<document.frmarticle.quoteimage.length;i++) {
		document.frmarticle.quoteimage.options[i].selected = true;
		if (document.frmarticle.quoteimages.value != '')
		{
			document.frmarticle.quoteimages.value = document.frmarticle.quoteimages.value + ',';
		}
		document.frmarticle.quoteimages.value = document.frmarticle.quoteimages.value + document.frmarticle.quoteimage.options[i].value;
	}
	for (i=0;i<document.frmarticle.cquoteimage.length;i++) {
		document.frmarticle.cquoteimage.options[i].selected = true;
		if (document.frmarticle.cquoteimages.value != '')
		{
			document.frmarticle.cquoteimages.value = document.frmarticle.cquoteimages.value + ',';
		}
		document.frmarticle.cquoteimages.value = document.frmarticle.cquoteimages.value + document.frmarticle.cquoteimage.options[i].value;
	}
	for (i=0;i<document.frmarticle.squoteimage.length;i++) {
		document.frmarticle.squoteimage.options[i].selected = true;
		if (document.frmarticle.squoteimages.value != '')
		{
			document.frmarticle.squoteimages.value = document.frmarticle.squoteimages.value + ',';
		}
		document.frmarticle.squoteimages.value = document.frmarticle.squoteimages.value + document.frmarticle.squoteimage.options[i].value;
	}
}

function selectallatt2() {
	var i, j, it, it2, tmp
	if (document.frmarticle.hdTotalAtt.value > 0) {
		for (i=0;i<document.frmarticle.hdTotalAtt.value;i++) {
			tmp = document.forms['frmarticle'].elements['hdAttName' + i].value;
			it = document.forms['frmarticle'].elements[tmp];
			for (j=0; j<it.length; j++) {
				it.options[j].selected = true;
				it2 =document.forms['frmarticle'].elements[tmp+'s'];
				if (it2.value != '')
				{
					it2.value = it2.value + ',';
				}
				it2.value = it2.value + it.options[j].value;
			}
		}
	}
}

function documentupload(frmName, fieldName, islist, doctype, location, documentid) {
	var x;
	x=window.open('document.php?formname='+frmName+'&fieldname='+fieldName+'&islist='+islist+'&doctype='+doctype+'&location='+location+'&documentid='+documentid,'Document','toolbar=0,location=0,dependent=1,directories=0,status=0,menubar=0,titlebar=0,scrollbars=1,resizable=1,width=625,height=300,top=100,left=50');
}

function removeattach(frmName, fieldName)	{
	var answer = confirm("Confirm remove the attachement?");

	if (answer){
		var i, item, it;
		
		it = document.forms[frmName].elements[fieldName];
		item = document.forms[frmName].elements[fieldName].selectedIndex;
		if (item > -1 ) {
			for (i=item;i<it.length-1;i++) {
				it.options[i].value = it.options[i+1].value;
				it.options[i].text = it.options[i+1].text;
			}
			document.forms[frmName].elements[fieldName].length = it.length - 1;
		}
	}
}

function viewattach(frmName, fieldName)	{
	var i, item, it, tmp, x, j;
	
	it = document.forms[frmName].elements[fieldName];
	item = document.forms[frmName].elements[fieldName].selectedIndex;
	if (item > -1 ) {
		j = it.options[item].value.indexOf("_000_",0);
		tmp = it.options[item].value.substring(j+5,it.options[item].value.length);
		x=window.open(tmp,'ViewDocument','toolbar=1,location=0,dependent=1,directories=0,status=0,menubar=1,titlebar=0,scrollbars=1,resizable=1,width=800,height=400,top=100,left=50');
	}
}

function viewattach2(frmName, fieldName)	{
	var i, item, it, tmp, x, j, k, tmp2;
	
	it = document.forms[frmName].elements[fieldName];
	item = document.forms[frmName].elements[fieldName].selectedIndex;
	if (item > -1 ) {
		j = it.options[item].value.indexOf("_000_",0);
		tmp = it.options[item].value.substring(j+5,it.options[item].value.length);
		k = tmp.indexOf("_111_",0);
		tmp2 = tmp.substring(0,k);
		x=window.open(tmp2,'ViewDocument','toolbar=1,location=0,dependent=1,directories=0,status=0,menubar=1,titlebar=0,scrollbars=1,resizable=1,width=800,height=400,top=100,left=50');
	}
}

function showattachment(path, atttype) {
	var x;
	x=window.open(path,'Show'+ atttype,'toolbar=1,location=0,dependent=1,directories=0,status=0,menubar=1,titlebar=0,scrollbars=1,resizable=1,width=800,height=400,top=100,left=50');
}

function goup(formname, fieldname) {
var index, stext, svalue;
index = document.forms[formname].elements[fieldname].selectedIndex;
if (index > 0) {
	svalue = document.forms[formname].elements[fieldname].options[index].value;
	stext = document.forms[formname].elements[fieldname].options[index].text;
	document.forms[formname].elements[fieldname].options[index].value = document.forms[formname].elements[fieldname].options[index-1].value
	document.forms[formname].elements[fieldname].options[index].text = document.forms[formname].elements[fieldname].options[index-1].text
	document.forms[formname].elements[fieldname].options[index-1].value = svalue
	document.forms[formname].elements[fieldname].options[index-1].text = stext
	document.forms[formname].elements[fieldname].selectedIndex = index - 1;
}
}

function godown(formname, fieldname) {
var index, stext, svalue;
index = document.forms[formname].elements[fieldname].selectedIndex;
if (index > -1) {
if (index < document.forms[formname].elements[fieldname].length -1) {
	svalue = document.forms[formname].elements[fieldname].options[index].value;
	stext = document.forms[formname].elements[fieldname].options[index].text;
	document.forms[formname].elements[fieldname].options[index].value = document.forms[formname].elements[fieldname].options[index+1].value
	document.forms[formname].elements[fieldname].options[index].text = document.forms[formname].elements[fieldname].options[index+1].text
	document.forms[formname].elements[fieldname].options[index+1].value = svalue
	document.forms[formname].elements[fieldname].options[index+1].text = stext
	document.forms[formname].elements[fieldname].selectedIndex = index + 1;
}
}
}


function one2two() {
	m1 = document.frmarticle.relateddoc;
	m2 = document.frmarticle.otherdoc;
    m1len = m1.length ;
    for ( i=0; i<m1len ; i++){
        if (m1.options[i].selected == true ) {
            m2len = m2.length;
            m2.options[m2len]= new Option(m1.options[i].text, m1.options[i].value);
        }
    }

    for ( i = (m1len -1); i>=0; i--){
        if (m1.options[i].selected == true ) {
            m1.options[i] = null;
        }
    }
}

function two2one() {
	m1 = document.frmarticle.relateddoc;
	m2 = document.frmarticle.otherdoc;
    m2len = m2.length ;
        for ( i=0; i<m2len ; i++){
            if (m2.options[i].selected == true ) {
                m1len = m1.length;
                m1.options[m1len]= new Option(m2.options[i].text, m2.options[i].value);
            }
        }
        for ( i=(m2len-1); i>=0; i--) {
            if (m2.options[i].selected == true ) {
                m2.options[i] = null;
            }
        }
}

function deleteitem(id) {
	if (confirm("Are you sure you want to delete the article?")) {
		window.location = 'ListArticle_submit.asp?documentid=' + id;
	}
}

function isDigit(num) {
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
}

function isNumeric(val)
{
	var i = (arguments.length>1) ? arguments[1] : '';
	if ((i=='') || (i=='+')){
		if (!isDigit(val.charAt(0))) return false;
	}
	if (i=='-'){
		if (val.charAt(0) != '-') return false;
	}
	return(parseFloat(val,10)==(val*1));
}

function verifyEmail(s){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(s)) return true;
	return false;
}

function isValidLengthMore(str1, strSize)
{
	var slen=str1.length	
	if (slen>strSize)
		{return false;}
	else
    	return true;
}

function isValidLengthLess(str1, strSize)
{
	var slen=str1.length	
	if (slen<strSize)
		{return false;}
	else
    	return true;
}

function popup(url, name)
{
	var x;
	x=window.open(url,name,'toolbar=1,location=0,dependent=1,directories=0,status=0,menubar=1,titlebar=0,scrollbars=1,resizable=1,width=650,height=550,top=50,left=50');

}