/*
var base = document.getElementsByTagName ("base");
var httpUrl = base[0].href + 'isapi/isapi.dll';
var xmlHttp;

function BuildXmlHttpReference ()
{
	if (typeof (XMLHttpRequest) != 'undefined')
		xmlHttp = new XMLHttpRequest();
	else 
	{
		try 
		{
			xmlHttp = new ActiveXObject ("Msxml2.XMLHTTP");
		}
		catch (e) 
		{
			try 
			{
				xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert (e.message);
			}
		}
	}
}
*/
function update (theform) {
	if (check_form(theform))
		theform.submit();
}

function screen_changed (object) {
	object.value = "yes";
}

function goto_page(theform,page) {
	theform.current_page.value = page;
	theform.submit();
}

function row_changed (theform,row) {
	theform.elements['row_changed_'+row].value = "yes";
}

function submit_form (target) {
	document.forms[0].action = target
	document.forms[0].target = "_self"
	document.forms[0].submit()
}

function order_by (theform,sortorder) {
	theform.sortorder.value = sortorder
	theform.submit()
}

function confirm_delete (delete_message) {
	return confirm(delete_message);
}

function round_decimal (number, precision) {
	var value,i

	value = Math.round (number * Math.pow(10,precision))
	value = ""+value

	len = value.length
	if (len <= precision) {
		for (i=0; i<precision-len; i++)
			value = "0"+value
		value = "0." + value
	} else
		value = value.substring(0,len-precision)+"."+value.substring(len-precision,len)

	return value
}

function check_date (input_date) {
	var day_of_month = new Array(12);
	day_of_month[0] = 31;
	day_of_month[1]=28;
	day_of_month[2]=31;
	day_of_month[3]=30;
	day_of_month[4]=31;
	day_of_month[5]=30;
	day_of_month[6]=31;
	day_of_month[7]=31;
	day_of_month[8]=30;
	day_of_month[9]=31;
	day_of_month[10]=30;
	day_of_month[11]=31;
	var i = 0;
	var j,month,message,day,year;
	var result = input_date;

	i = input_date.indexOf('/',i);

	if (i>=0) {

		month = input_date.substring(0,i);
		j = i+1;
		if (parseInt(month,10) <= 0 || parseInt(month,10) >12) {
			alert(invalid_date);
			return false;
		}
	} else {
		alert(invalid_date);
		return false;
	}
	i = input_date.indexOf('/',j);
	if (i>=0) {
		day = input_date.substring(j,i);
		k = i + 1;
		year = input_date.substring(k,input_date.length);
		if (parseInt(year,10) < 0) {
			alert(invalid_date);
			return false;
		}
		if ((parseInt(year,10) % 4) == 0) {
			day_of_month[1]=29;
		} else
			day_of_month[1]=28;
		if (parseInt(day,10) <=0 || parseInt(day,10) > day_of_month[month-1]) {
			alert(invalid_date);
			return false;
		}
	} else {
		alert(invalid_date);
		return false;
	}
	return true;
}

function select_cal (obj) {
	selected_cal = obj.id;
}

function select_date (day,month,year) {
	if (selected_cal == "cal_start") 
		document.forms[0].start_date.value = month+"/"+day+"/"+year;
	else
		document.forms[0].end_date.value = month+"/"+day+"/"+year;
	toggle_calendar (selected_cal);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function copyValue (f) {
	var string = editorctl.DocumentHTML;
	if (arguments.length > 1)
	{
		string = string.replace (/\'/g,"&#039");
		string = string.replace (/\r\n/g, "");
	}
	f.elements.description.value = string;
	return true;
}

function add_product (theform,item,product_id) {
	total_product = parseInt (theform.total_product.value,10);
	for (i=0; i<total_product; i++) {
		if (theform.elements['qty_'+i].value != "") {
			quantity = parseFloat (theform.elements['qty_'+i].value,10)
			if (isNaN(quantity) || quantity <= 0) {
				alert (invalid_quantity);
				return false;
			}
		}
	}

	theform.submit();
}

function GetContent(pagename,divname)
{
	var hash = Math.random();	
	var url = pagename+'.aspx';
	var pars = 'hash='+hash;
	
	var ajax = new Ajax.Updater({success: divname},url,{method: 'post', parameters: pars, evalScripts: true});
} 
/*
function get_banner (banner_num) 
{
	var url = httpUrl + '?get_banner&banner_num='+banner_num;
	BuildXmlHttpReference ();
	if (xmlHttp)
	{
		xmlHttp.open ("GET", url, false);
		xmlHttp.send (null);
		var xmldoc = xmlHttp.responseXML;

		var id, file_type, file_name, target, width, height, alt;

		var banner = xmldoc.getElementsByTagName ("banner");

		for (i=0; i<banner.length ; i++)
		{
			var node = banner[i].childNodes;

			for (j=0; j<node.length; j++ )
			{
				if (node[j].nodeName == "id")
				{
					id = node[j].firstChild.nodeValue;
				}
				else if (node[j].nodeName == "file_type")
				{
					file_type = node[j].firstChild.nodeValue;
				} else if (node[j].nodeName == "file_name")
				{
					file_name = node[j].firstChild.nodeValue;
				} else if (node[j].nodeName == "width")
				{
					width = node[j].firstChild.nodeValue;
				} else if (node[j].nodeName == "height")
				{
					height = node[j].firstChild.nodeValue;
				} else if (node[j].nodeName == "alt")
				{
					alt = node[j].firstChild.nodeValue;
				} else if (node[j].nodeName == "target")
				{
					target = node[j].firstChild.nodeValue;
				}  
			}
		}

		if (i > 0)
		{
			if (file_type == "image")
			{
				document.write ("<a href="+httpUrl+"?clickad&id="+id);
				if (alt != "")
				{
					document.write (' alt="'+alt+'"');
				}

				if (target != "")
				{
					document.write (' target="'+target+'"');
				}
				
				document.write ("><img border=0 src="+base[0].href+"banners/"+file_name+"></a>");
			} else {
				document.writeln ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="'+width+'" height="'+height+'">');
				document.writeln ('<param name="movie" value="'+base[0].href+'banners/'+file_name+'"/>');
				document.writeln ('<embed src="'+base[0].href+'banners/'+file_name+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>');
			}
		}
	}
}
*/

