﻿
var xmlhttp;
var xml_error;

var lx;
var ly
var fx;
var fy;
var last_xml;
var zlevel;
zlevel=100;

var last_scroll;
var menushowid;
menushowid=-1;



var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

function submitenter(myfield,e)
{


var key;
if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;

if (key>31)
if (key<128)
{

if (window.event)
	{

    window.event.keyCode=' !"#$%،گ)(×+و-./0123456789:ك,=.؟@ِذ}ىُىلآ÷ـ،/’د×؛َءٍف‘{ًْإ~جژچ^_پشذزيثبلاهتنمئدخحضقسفعرصطغظ<|>ّ'.charCodeAt(key-32);

    }
else if (e)
	{

	  e.which=' !"#$%،گ)(×+و-./0123456789:ك,=.؟@ِذ}ىُىلآ÷ـ،/’د×؛َءٍف‘{ًْإ~جژچ^_پشذزيثبلاهتنمئدخحضقسفعرصطغظ<|>ّ'.charCodeAt(key-32);

	}
   }
   	return true;
}

function submitenter2(myfield,e)
{


var key;
if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
if (key>31)
if (key<128)
{
if (window.event)
    window.event.keyCode=' !"#$%،گ)(×+و-./0123456789:ك,=.؟@ِذ}ىُىلآ÷ـ،/’د×؛َءٍف‘{ًْإ~جژچ^_پشذزيثبلاهتنمئدخحضقسفعرصطغظ<|>ّ'.charCodeAt(key-32);
else if (e)
   e.which=' !"#$%،گ)(×+و-./0123456789:ك,=.؟@ِذ}ىُىلآ÷ـ،/’د×؛َءٍف‘{ًْإ~جژچ^_پشذزيثبلاهتنمئدخحضقسفعرصطغظ<|>ّ'.charCodeAt(key-32);

   }
   	return true;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	//o = document.getElementById(objectId)
	o=objectId;
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	//o = document.getElementById(objectId)
	o=objectId
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}
function setiframesize(obj)
{
	
	h=obj.contentWindow.document.body.scrollHeight;
	
	obj.height=h;

	obj.style.visibility="";
}
function frameloaded()
{
	 xHTML=mainframe2.document.body.innerHTML;
	 table_frame.innerHTML=xHTML;
}
function displaymenu()
{
	menu_row.style.position="absolute"
	menu_row.filters.item(0).apply();	
	menu_row.style.visibility="";
	menu_row.style.top=window.document.body.scrollTop;
	menu_row.filters.item(0).play(0.4);
	
}
function doscroll()
{
 	//window.status =	window.document.body.scrollTop;

	 if (menushowid!=-1) window.clearTimeout(menushowid);

 	if (last_scroll!=0)
 		{
 			window_dic.style.posTop = window_dic.style.posTop + window.document.body.scrollTop - last_scroll;
 		}

 	
 	last_scroll=window.document.body.scrollTop;

 	if (window.document.body.scrollTop<100)
 		{
 			menu_row.style.visibility="";
 			menu_row.style.position="";
 		}
 		else
 		{
 			menu_row.style.visibility="hidden";
			menushowid=window.setTimeout("displaymenu();",1000)
 		}

}

function htmlEncode(source, display, tabs)
{
	function special(source)
	{
		var result = '';
		for (var i = 0; i < source.length; i++)
		{
			var c = source.charAt(i);
			if (c < ' ' || c > '~')
			{
				c = '&#' + c.charCodeAt() + ';';
			}
			result += c;
		}
		return result;
	}
	
	function format(source)
	{
		// Use only integer part of tabs, and default to 4
		tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
		
		// split along line breaks
		var lines = source.split(/\r\n|\r|\n/);
		
		// expand tabs
		for (var i = 0; i < lines.length; i++)
		{
			var line = lines[i];
			var newLine = '';
			for (var p = 0; p < line.length; p++)
			{
				var c = line.charAt(p);
				if (c === '\t')
				{
					var spaces = tabs - (newLine.length % tabs);
					for (var s = 0; s < spaces; s++)
					{
						newLine += ' ';
					}
				}
				else
				{
					newLine += c;
				}
			}
			// If a line starts or ends with a space, it evaporates in html
			// unless it's an nbsp.
			newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
			lines[i] = newLine;
		}
		
		// re-join lines
		var result = lines.join('<br />');
		
		// break up contiguous blocks of spaces with non-breaking spaces
		result = result.replace(/  /g, ' &nbsp;');
		
		// tada!
		return result;
	}

	var result = source;
	
	// ampersands (&)
	result = result.replace(/\&/g,'&amp;');

	// less-thans (<)
	result = result.replace(/\</g,'&lt;');

	// greater-thans (>)
	result = result.replace(/\>/g,'&gt;');
	
	if (display)
	{
		// format for display
		result = format(result);
	}
	else
	{
		// Replace quotes if it isn't for display,
		// since it's probably going in an html attribute.
		result = result.replace(new RegExp('"','g'), '&quot;');
	}

	// special characters
	result = special(result);
	
	// tada!
	return result;
}


function xmlsubmit2(frmname)
{
	var x;
	var i;
	var part;
	var args;
	args="";
	if (document.getElementById(frmname)!=null)
	{
		x=	document.getElementById(frmname)

		var x=document.getElementById(frmname);
		for (var i=0;i<x.length;i++)
		  {
		
				
				part=""
				
				tag_type=x.elements[i].tagName;
			//	vl=urlencode(x.elements[i].value);
				
				if (tag_type=="INPUT")
					{
						
						if (x.elements[i].type=="" || x.elements[i].type=="text") part=x.elements[i].name + "=" +(x.elements[i].value) + "&";
						
						if (x.elements[i].type=="" || x.elements[i].type=="text") part=x.elements[i].name + "=" +(x.elements[i].value) + "&";
						
						if (x.elements[i].type=="checkbox")
							{
								if (x.elements[i].checked==true)
									{
										part=x.elements[i].name + "=" +x.elements[i].value + "&";
									}
							}
							
						if (x.elements[i].type=="hidden")
							{
								part=x.elements[i].name + "=" +(x.elements[i].value) + "&";
							}							
							
						if (x.elements[i].type=="radio")
							{
								if (x.elements[i].checked==true)
									{
										part=x.elements[i].name + "=" +x.elements[i].value + "&";
									}
							}
	
					}
				
				if (tag_type=="TEXTAREA") part=x.elements[i].name + "=" +(x.elements[i].value) + "&";
	
				if (tag_type=="SELECT")
					{

						v=x.elements[i].value			
						//v=x.elements[i].options(x.elements[i].selectedIndex).value;			
						//if (v=="") v=x.elements[i].options(x.elements[i].selectedIndex).text;
						part=x.elements[i].name + "=" +v + "&";
					}
					
	
				
				
				if (part!="")
					args=args+part;				

	
			}
			
			//u=document.all(frmname).action+"?"+args;
		    u=document.getElementById(frmname).action+"?"+args;


			openpage(u);




	
	}
	else
	{
		alert("Error sending form data , form '"+frmname+"' not present.")
	}

}



function xmlsubmit(frmname)
{
	var x;
	var i;
	var part;
	var args;
	args="";
	if (document.all(frmname)!=null)
	{
		x=	document.getElementById(frmname)
		
		for (i=0;i<x.length;i++)
			{
				part=""
				tag_type=x(i).tagName;

				
				if (tag_type=="INPUT")
					{
						//v=escape(x(i).value)
						
						v=Url.encode((x(i).value))
						
						
						if (x(i).type=="" || x(i).type=="text") part=x(i).name + "=" +(v) + "&";
						
						if (x(i).type=="" || x(i).type=="text") part=x(i).name + "=" +(v) + "&";
						
						if (x(i).type=="checkbox")
							{
								if (x(i).checked==true)
									{
										part=x(i).name + "=" +v + "&";
									}
							}
							
						if (x(i).type=="hidden")
							{
								part=x(i).name + "=" +(v) + "&";
							}							
							
						if (x(i).type=="radio")
							{
								if (x(i).checked==true)
									{
										part=x(i).name + "=" +v + "&";
									}
							}
	
					}
				
				if (tag_type=="TEXTAREA") part=x(i).name + "=" +(v) + "&";
	
				if (tag_type=="SELECT")
					{

						v=x(i).options(x(i).selectedIndex).value;
						
						if (v=="") v=x(i).options(x(i).selectedIndex).text;

						part=x(i).name + "=" +v + "&";
					}
					
	
				
				
				if (part!="")
					args=args+part;				

	
			}
			
			//u=document.all(frmname).action+"?"+args;
		    u=document.all(frmname).action+"?"+args;

			openpage(u);




	
	}
	else
	{
		alert("Error sending form data , form '"+frmname+"' not present.")
	}

}


function openpopup(url)
{

	table_popup.style.visibility="";
	table_popup.style.left=(window.document.body.clientWidth-350)/2;
	table_popup.style.width=350;
	table_popup.style.top=(window.document.body.clientHeight -150)/2;
	zlevel++;
	table_popup.style.zIndex=zlevel;	
	gethtml(url,"popup_cell");
}

function submitsearch()
{
	xsearch=document.all("search").value
	if (xsearch!='')
		{
				xpage=document.all("Page").value			
				openpage("search.asp?search="+xsearch+"&page="+xpage);
		}

}

function onenter(obj)
{
	x=window.event.keyCode;
	if (x==13) {
				window.event.keyCode=0;
	             eval (obj);
	             
	 		   }
	
}


function sendlogin()
{
	a="signin.asp?USER="+document.all("txt_username").value+"&PASS="+document.all("txt_password").value
	z=gethtml2(a,"login_frame");
	if (z.match('Login successful!'))
		{
			gethtml("usertab.asp","window_usertab");
			
		}
		
}


function showlogin()
{
	table_login.style.visibility="";
	table_login.style.left=(window.document.body.clientWidth-350)/2;
	table_login.style.width=350;
	table_login.style.top=(window.document.body.clientHeight -150)/2;
	//document.all("txt_username").value="";
	//document.all("txt_password").value="";	
	//document.all("txt_email").value="";		

}

function checkdicclick()
{
	x=window.event.keyCode
	if (x==13) translate();
}
function checkhistory(obj)
{


	x=obj.contentWindow.document.body.innerHTML;


	
	
	z="";

	
	if (x.search("OK=") >=0 )
		{
			
			z=x.substring(3,x.length)
			z=z.toString();
			
			//z=z.replace('=','');


			while (z.search("_and_")!=-1)
			{
			 z=z.replace('_and_','&');
			}	
			


			openpage_xml(z);		
		}
		else
		{
			//alert("Cannot open page , some server problem !");
		}

}

function highlightcell(obj)
{
	obj.bgColor='#F7F7F3';
}

function dehighlightcell(obj)
{
	obj.bgColor='#E2E0D9';
}

function movewindow(obj)
{
	if (window.event.button==1)
		{
			if ((fx+window.event.x-lx>0) && (fx+window.event.x-lx<window.document.body.clientWidth-300) )
				{
					obj.style.left=fx+window.event.x-lx;
				}
			if ((fy+window.event.y-ly>0) && (fy+window.event.y-ly<window.document.body.clientHeight-150) )
				{
					obj.style.top=fy+window.event.y-ly;
				}

		}
		else
		{
			lx=window.event.x;
			ly=window.event.y;
			fx=obj.style.posLeft;
			fy=obj.style.posTop;
		}

}

function getword()
{
	if (document.selection.type=="Text")
		{
			var a;
			a=document.selection.createRange();
			if (a.text!="")
				{
					
					opendic();
					dictext.value=a.text;
					translate();
				}
		}
}


function translate()
{
	a="dic.asp?word="+document.all('dictext').value;
	gethtml(a,"dic_frame");
}
function opendic()
{


	if (navigator.appName=="Microsoft Internet Explorer")
	{
			window_dic.style.visibility="";
			window_dic.style.zIndex=zlevel;		
			
			dictext.value="";
			dictext.select();
		
			if (window.event.x-320<window.document.body.clientWidth-320)
				{
					if (window.event.x-320<0)
						{
							window_dic.style.left=10;		
						}
						else
						{	
							window_dic.style.left=window.event.x-320;							
						}
				}
				else
				{	
						window_dic.style.left=window.document.body.clientWidth-320;		
				}
		
			if (window.event.y<window.document.body.clientHeight-220)
				{
					window_dic.style.top=window.event.y+20;		
				}
				else
				{
					window_dic.style.top=window.document.body.clientHeight-220;		
				}
	}
	else
	{
			window_dic.style.visibility="";
			window_dic.style.left=(window.document.body.clientWidth-350)/2;
			window_dic.style.width=350;
			window_dic.style.top=(window.document.body.clientHeight -150)/2;
			zlevel++;
			window_dic.style.zIndex=zlevel;	
	}
	return false; 
}

function dosearch()
{
	s=document.getElementById("searchmain").value;
	if (s!='')
	{
	x=mainframe.document.location.toString();
	y="all";
	z=x.search('projects.asp');
	if (z!=-1)  y="projects"
	z=x.search('news.asp');
	if (z!=-1)  y="projects";
	openpage("search.asp?search="+s)	;
	}
//	navframe("search.asp");
}


function setlink(html)
{

	var i;
	var x;
	x=0;
	i=0;

	while (x!=-1)
	{
		x=html.indexOf('href=',i);
		if (x>0)
		{
			y=html.indexOf('"',x+7);
			
			html1=html.substr(0,x+6);
			html2=html.substr(x+6,y-x-6);
			html3=html.substr(y);
			extlink=0
			if (html2.search('http://')!=-1) extlink=1;
			if (html2.search('javascript:')!=-1) extlink=1;
			if (html2.search('https://')!=-1) extlink=1;
			if (html2.search('ftp://')!=-1) extlink=1;
			if (html2.search('www.')!=-1) extlink=1;
			if (html2.search('@')!=-1) extlink=1;
			
			if (extlink==0)
				{
					html2="javascript:openpage('"+html2+"');";
					html2=html2+'" target="_top';
				}
				else
				{
				html2=html2+'" target="_blank';
				}				
			html=html1+html2+html3

		}
		i=x+10;
	}
	
	  return html;
}

function closeerror2()
{

	table_error.style.visibility="hidden";
	table_error.style.left=-2000;
	table_error.style.top=-2000;

	table_login.style.visibility="hidden";
	table_login.style.left=-2000;
	table_login.style.top=-2000;

	table_popup.style.visibility="hidden";
	table_popup.style.left=-2000;
	table_popup.style.top=-2000;

	error_frame.height=1;


}


function closeerror()
{


	table_error.style.visibility="hidden";
	table_error.style.left=-2000;
	table_error.style.top=-2000;

//	table_popup.style.visibility="hidden";
//	table_popup.style.left=-2000;
//	table_popup.style.top=-2000;


	error_frame.height=1;

}
function showdetail()
{
	table_error.style.visibility="";
	table_error.style.left=(window.document.body.clientWidth-650)/2;
	table_error.style.top=100;
	table_error.style.width=650;
	error_frame.height=300;
	error_frame.width=630;
	error_msg.document.body.innerHTML=xml_error;

}
function showerror()
{
	table_error.style.visibility="";
	table_error.style.left=(window.document.body.clientWidth-450)/2;
	table_error.style.width=450;
	table_error.style.top=(window.document.body.clientHeight -150)/2;
}

function openpage(url)
{

	location="#"+url
	url=url.replace("../dbmanager/","")
	closeerror2();
	ex=0
	if (url=="") ex=1;
	if (url==" ") ex=1;	
	if (url=="-") ex=1;		


	if (ex==0)
	{


		if (url=='index.asp') return 0;		




		loading_frame.style.visibility="";
		loading_frame.style.left=0;
		loading_frame.style.top=72;  
		loading_frame.style.width="100%";

		urlx=url;
		
		while (urlx.search('&')!=-1)
		{
		 urlx=urlx.replace('&','_and_');
		}
		


		mainframe.document.location="history.asp?URL="+urlx;

		mainframe.src="history.asp?URL="+urlx;
		


	}

	
//	openpage_iframe(url);
}
var openurl;
function openpage_xml(url)
{

	ex=0
	if (url=="") ex=1;
	if (url==" ") ex=1;	
	if (url=="-") ex=1;		
	openurl=url;
	if (ex==0)
	{
		loading_frame.style.visibility="";
		loading_frame.style.left=0;
		loading_frame.style.top=72;  
		loading_frame.style.width="100%";
	
		loading_frame.style.height=window.document.body.clientHeight-72 ;  
	


		if (window.XMLHttpRequest)
		  {
		  xmlhttp=new XMLHttpRequest()
		  }
		// code for IE
		else if (window.ActiveXObject)
		  {
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		  }
		if (xmlhttp!=null)
		  {

			  xmlhttp.onreadystatechange=state_Change		  
			  xmlhttp.open("GET",url,true)
			  xmlhttp.send(null)

		  }

		}

}
//---------------------------------------------------------------
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{


   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    

}

function state_Change()
{

document.body.scrollTop=0
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
  {
  loading_frame.style.visibility="hidden";
  html=xmlhttp.responseText;
  // if "OK"
  if (xmlhttp.status==200)
  {
  		if (html.search('NOACCESS'))
  			{
				html=setlink(html);
				table_frame.innerHTML=html;

				if (openurl.search("main.asp")>=0 )
					{
						mrqnews.start();
						showtab(1);
						correctPNG();				
						doscroll();			
					}
				
			}
			else
			{
				openpopup('errora.htm');
			}

  }
  else
  {

		  xml_error=html;
		  xml_error=xml_error.replace('href','_href');
		  showerror();	  
  }
  }
}
//---------------------------------------------------------------

function openpage_iframe(url)
{
	ex=0
	if (url=="") ex=1;
	if (url==" ") ex=1;	
	if (url=="-") ex=1;		

	if (ex==0)
	{
		loading_frame.style.visibility="";
		loading_frame.style.left=0;
		loading_frame.style.top=72;  
		loading_frame.style.width="100%";
	
		loading_frame.style.height=window.document.body.clientHeight-72 ;  
	
	
		mainframe.document.location=url;
		mainframe.src=url;
	}
}

function showpage()
{
	var html;   
	loading_frame.style.visibility="hidden";    		
	html = mainframe.document.body.innerHTML;


  if (html.search("HTTP Error")==-1)
  	{
		html=setlink(html);
		table_frame.innerHTML=html;
	}
	else
	{
		  xml_error=html;
		  xml_error=xml_error.replace('href','_href');
		  showerror();		
	}	
}



function makeover(obj)
{
	var a;
	a=obj.src;
	if (a.search('_over.gif')==-1)
		{
			a=a.replace('.gif','_over.gif');
			obj.src=a;		
		}		
}
function makenormal(obj)
{
	var a;
	a=obj.src;
	if (a.search('_over.gif')!=-1)
		{
			a=a.replace('_over.gif','.gif');
			obj.src=a;		
		}		
}

function gethtml(url,objname)
{

	o=document.getElementById("msgwait")
	o.style.left=(document.body.clientWidth-50)/2
	o.style.top=(document.body.clientHeight-50)/2
	o.style.visibility=""
	window.setTimeout("gethtml2('"+url+"','"+objname+"');",100);

}
function gethtml2(url,objname)
{
var xmlhttp;
xmlhttp=null;

last_xml="";
obj=document.all(objname);

// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  	  
	  xmlhttp.open("GET",url,false)
	  xmlhttp.send(null)
	  if (xmlhttp.status==200)
	  	{
	  	  //	alert(obj.id);
	  	  xhtm = xmlhttp.responseText;
		  obj.innerHTML = xhtm;
		  document.getElementById("msgwait").style.visibility="hidden";
		  xhtm=xhtm.toString();
		  
			z=gettag(xhtm,'script')

			eval(z);
		  return xhtm;
	    }
	    else
	    {
	    //obj.innerHTML="<font face='Tahoma' size='1'>Error Loading Data!</font>";	
	    obj.innerHTML=xmlhttp.responseText;
	    document.getElementById("msgwait").style.visibility="hidden";
		 
	    }
  }
  
}

/*******************************************/


function getxml(url)
{
var xmlhttp;
xmlhttp=null;




// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  	  
	  xmlhttp.open("GET",url,false)
	  xmlhttp.send(null)
	  if (xmlhttp.status==200)
	  	{
	  	  //	alert(obj.id);
	  	  xhtm = xmlhttp.responseText;
		  return xhtm;
	    }
	    else
	    {
	     xhtm = xmlhttp.responseText;
		 return xhtm;
	    }
  }
  
}



/**********************************************/
function send_mail_level1()
{



 var permission;
    permission=0;
    
 //  form_prereg1.XaddressEN.style.backgroundColor="";

    form_prereg1.password.style.backgroundColor="";    
    form_prereg1.XaddressFA.style.backgroundColor="";    
    form_prereg1.XgivennameFa.style.backgroundColor="";
    form_prereg1.XgivennameEn.style.backgroundColor="";
    form_prereg1.XLastnameFa.style.backgroundColor="";
    form_prereg1.XLastnameEn.style.backgroundColor="";
    form_prereg1.BirthYear.style.backgroundColor="";
    form_prereg1.BirthDay.style.backgroundColor="";
  //  form_prereg1.XmelliCode.style.backgroundColor="";
    form_prereg1.Xemail.style.backgroundColor="";
    form_prereg1.Xemail2.style.backgroundColor="";
    form_prereg1.Xtel01.style.backgroundColor="";
    form_prereg1.check1.style.backgroundColor="";
    

    
    if (form_prereg1.XgivennameFa.value=="") { permission=1; form_prereg1.XgivennameFa.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.XgivennameEn.value=="") { permission=1; form_prereg1.XgivennameEn.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.XLastnameFa.value=="") { permission=1; form_prereg1.XLastnameFa.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.XLastnameEn.value=="") { permission=1; form_prereg1.XLastnameEn.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.BirthYear.value.length == 2) {form_prereg1.BirthYear.value="13"+form_prereg1.BirthYear.value}
    if (form_prereg1.BirthYear.value.length != 4) { permission=1; form_prereg1.BirthYear.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.BirthDay.value.length < 1) { permission=1; form_prereg1.BirthDay.style.backgroundColor="#FFFF00"; }
 //   if (form_prereg1.XmelliCode.value.length < 10) { permission=1; form_prereg1.XmelliCode.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.Xemail.value.indexOf("@") == -1 || form_prereg1.Xemail.value.indexOf(".") == -1 || form_prereg1.Xemail.value.length < 8 ) { permission=1; form_prereg1.Xemail.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.Xemail2.value.indexOf("@") == -1 || form_prereg1.Xemail2.value.indexOf(".") == -1 || form_prereg1.Xemail2.value.length < 8 ) { permission=1; form_prereg1.Xemail2.style.backgroundColor="#FFFF00"; }
    
    if (form_prereg1.Xtel01.value.length < "6") { permission=1; form_prereg1.Xtel01.style.backgroundColor="#FFFF00"; }
    if (form_prereg1.check1.checked==false) { permission=1; form_prereg1.check1.style.backgroundColor="#FFFF00"; }    
    
    if ((form_prereg1.XaddressFA.value.length>90)) 
    	{    	
    	if (form_prereg1.XaddressFA.value.length>90) { form_prereg1.XaddressFA.style.backgroundColor="#FFFF00"; form_prereg1.XaddressFA.value="" }
    	permission=1; 
    	alert('&#1570;&#1583;&#1585;&#1587; &#1608;&#1575;&#1585;&#1583; &#1588;&#1583;&#1607; &#1576;&#1586;&#1585;&#1711;&#1578;&#1585; &#1575;&#1586; &#1581;&#1583; &#1605;&#1580;&#1575;&#1586; &#1605;&#1610; &#1576;&#1575;&#1588;&#1583;!');
    	}

    if (permission==1)
		{
			//alert("Please fill all marked fields");
			msgbox ("&#1604;&#1591;&#1601;&#1575; &#1603;&#1604;&#1610;&#1607; &#1601;&#1610;&#1604;&#1583;&#1607;&#1575;&#1610; &#1587;&#1578;&#1575;&#1585;&#1607; &#1583;&#1575;&#1585; &#1585;&#1575; &#1662;&#1585; &#1603;&#1606;&#1610;&#1583;");
		}

	if ((form_prereg1.Xemail.value!=form_prereg1.Xemail2.value) && permission==0)
		{ 	permission=1; 
				msgbox ("&#1570;&#1583;&#1585;&#1587; &#1662;&#1587;&#1578; &#1575;&#1604;&#1603;&#1578;&#1585;&#1608;&#1606;&#1610;&#1603;&#1610; &#1608; &#1578;&#1575;&#1610;&#1610;&#1583; &#1570;&#1606; &#1605;&#1610; &#1576;&#1575;&#1610;&#1587;&#1578; &#1610;&#1603;&#1610; &#1576;&#1575;&#1588;&#1606;&#1583;")
			form_prereg1.Xemail.style.backgroundColor="#FFFF00"; form_prereg1.Xemail2.style.backgroundColor="#FFFF00";
		}


	if (permission==0)
	{
			  d = new Date();
			  y = d.getFullYear();
			  y=y-621-form_prereg1.BirthYear.value;

			 if (y<18 || y>100 )
		     {
				form_prereg1.BirthYear.value="";
			    form_prereg1.BirthYear.style.backgroundColor="#FFFF00";
			    permission=-1
				    msgbox('&#1601;&#1602;&#1591; &#1575;&#1601;&#1585;&#1575;&#1583; &#1576;&#1586;&#1585;&#1711;&#1578;&#1585; &#1575;&#1586; 18 &#1587;&#1575;&#1604; &#1605;&#1580;&#1575;&#1586; &#1576;&#1607; &#1579;&#1576;&#1578; &#1606;&#1575;&#1605; &#1605;&#1610;&#8204;&#1576;&#1575;&#1588;&#1606;&#1583;.')
		    }

	}
	
	if (permission==0)
	{
	pw=form_prereg1.password.value;

	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  }
	if (xmlhttp!=null)
	  {
	  	
	  	  url="prereg_checkpassclinet.asp?password="+pw
	  	  
		  xmlhttp.open("GET",url,false)
		  xmlhttp.send(null)

		  if (xmlhttp.status==200)
		  	{
		  	  //	alert(obj.id);

		  	  
		  	  if (xmlhttp.responseText!="OK") 
		  	  	{
		  	  		form_prereg1.password.style.backgroundColor="#FFFF00";
			  	  		msgbox("&#1603;&#1604;&#1605;&#1607; <span lang='fa'>&#1585;&#1605;&#1586; &#1578;&#1575;&#1610;&#1610;&#1583; &#1575;&#1588;&#1578;&#1576;&#1575;&#1607; &#1605;&#1610;&#8204;&#1576;&#1575;&#1588;&#1583;")
		  	  		permission=-1
		  	  	}
		  	  	
		    }
	  }
	}
	
	
	if (permission==0)
        {

        	form_prereg1.B1.disabled=1
        	form_prereg1.B2.disabled=1

			xmlsubmit('form_prereg1');
        	form_prereg1.B1.disabled=0
        	form_prereg1.B2.disabled=0
			
	    }
	    

	
	
	    

}


function msgbox(msg)
{
	obj=document.getElementById("table_msgbox")

//	window.document.attachEvent('onclick',closeerror3);
	t=window.document.body.scrollTop
	
	document.getElementById("table_msgbox_msg").innerHTML="<font face=tahoma size=2>"+msg+"</font>";
	document.getElementById("table_msgbox_msg").dir="rtl"
	document.getElementById("table_msgbox_msg").align="center"	
	obj.style.left=(window.document.body.clientWidth-350)/2;
	obj.style.width=350;
	obj.style.top=t+(window.document.body.clientHeight -150)/2;
	zlevel++;
	obj.style.zIndex=zlevel;	
	obj.style.visibility="";
	
	window.setTimeout(closeerror3,2000);
	//table_msgbox_button

}

function closeerror3()
{
document.getElementById("table_msgbox").style.visibility="hidden"

}
function send_mail_level2()
{


 var permission;
    permission=0;
    if (form_prereg3.XpaidID.value=="") permission=1;
    if (form_prereg3.XpaidID2.value=="") permission=1;    
    if (form_prereg3.XpaidID.value!=form_prereg3.XpaidID2.value) permission=1;    
    if (form_prereg3.BirthYear.value.length < 1) permission=1;
    if (form_prereg3.BirthDay.value.length < 1) permission=1;
    if (permission==1)
		{
			msgbox("&#1575;&#1591;&#1604;&#1575;&#1593;&#1575;&#1578; &#1601;&#1610;&#1588; &#1576;&#1575;&#1606;&#1603;&#1610; &#1585;&#1575; &#1576;&#1607; &#1591;&#1608;&#1585; &#1603;&#1575;&#1605;&#1604; &#1608;&#1575;&#1585;&#1583; &#1603;&#1606;&#1610;&#1583;&#1548;&nbsp; &#1580;&#1607;&#1578; &#1575;&#1591;&#1605;&#1610;&#1606;&#1575;&#1606; &#1575;&#1586; &#1589;&#1581;&#1578; &#1588;&#1605;&#1575;&#1585;&#1607; &#1601;&#1610;&#1588; &#1576;&#1575;&#1606;&#1603;&#1610; &#1575;&#1610;&#1606; &#1588;&#1605;&#1575;&#1585;&#1607; 2 &#1576;&#1575;&#1585; &#1575;&#1586; &#1588;&#1605;&#1575; &#1583;&#1585;&#1582;&#1608;&#1575;&#1587;&#1578; &#1588;&#1583;&#1607; &#1575;&#1587;&#1578;.");
		}
	
	if (permission==0)
        {
			xmlsubmit('form_prereg3')
	    }

}


function preregstart(c)
{
var browserName=navigator.appName
if (browserName=="Microsoft Internet Explorer")
	{
		openpage("prereg_form.asp?security="+c)
	}
	else
	{
		msgbox ('<span lang="fa">&#1601;&#1602;&#1591; &#1575;&#1586; &#1605;&#1585;&#1608;&#1585;&#1711;&#1585; </span>Internet Explorer<span lang="fa"> &#1580;&#1607;&#1578;&nbsp;&#1579;&#1576;&#1578; &#1606;&#1575;&#1605; &#1575;&#1587;&#1578;&#1601;&#1575;&#1583;&#1607; &#1603;&#1606;&#1610;&#1583;. &#1607;&#1605; &#1575;&#1603;&#1606;&#1608;&#1606; &#1605;&#1585;&#1608;&#1585;&#1711;&#1585; </span>'+browserName+'<span lang="fa"> &#1662;&#1588;&#1578;&#1610;&#1576;&#1575;&#1606;&#1610;&nbsp;&#1606;&#1605;&#1610;&#8204;&#1588;&#1608;&#1583;.</span>')
	}
//(browserName)
}

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

