/*
	Copyright Infinite Solutions Co.,Ltd 2009;
	mediaweb.js v 2.0 2009.06.03;
	Infinite Solutions JS Main File
*/


function AjaxRequest() {
  var req = new Object();
  
  req.timeout = null;
  req.generateUniqueUrl = true;
  req.url = window.location.href;
  req.method = "GET";
  req.async = true;
  req.username = null;
  req.password = null;
  req.parameters = new Object();
  req.requestIndex = AjaxRequest.numAjaxRequests++;
  req.responseReceived = false;
  req.groupName = null;
  req.queryString = "";
  req.responseText = null;
  req.responseXML = null;
  req.status = null;
  req.statusText = null;
  req.aborted = false;
  req.xmlHttpRequest = null;
  req.enctype='application/x-www-form-urlencoded';
  req.onTimeout = null; 
  req.onLoading = null;
  req.onLoaded = null;
  req.onInteractive = null;
  req.onComplete = null;
  req.onSuccess = null;
  req.onError = null;
  req.onGroupBegin = null;
  req.onGroupEnd = null;

req.xmlHttpRequest = AjaxRequest.getXmlHttpRequest();
  if (req.xmlHttpRequest==null) { return null; }
  
  // -------------------------------------------------------
  // Attach the event handlers for the XMLHttpRequest object
  // -------------------------------------------------------
  req.xmlHttpRequest.onreadystatechange = 
  function() {
    if (req==null || req.xmlHttpRequest==null) { return; }
    if (req.xmlHttpRequest.readyState==1) { req.onLoadingInternal(req); }
    if (req.xmlHttpRequest.readyState==2) { req.onLoadedInternal(req); }
    if (req.xmlHttpRequest.readyState==3) { req.onInteractiveInternal(req); }
    if (req.xmlHttpRequest.readyState==4) { req.onCompleteInternal(req); }
  };
  
  // ---------------------------------------------------------------------------
  // Internal event handlers that fire, and in turn fire the user event handlers
  // ---------------------------------------------------------------------------
  req.onLoadingInternalHandled = false;
  req.onLoadedInternalHandled = false;
  req.onInteractiveInternalHandled = false;
  req.onCompleteInternalHandled = false;
  req.onLoadingInternal = 
    function() {
      if (req.onLoadingInternalHandled) { return; }
      AjaxRequest.numActiveAjaxRequests++;
      if (AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function") {
        AjaxRequestBegin();
      }
      if (req.groupName!=null) {
        if (typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined") {
          AjaxRequest.numActiveAjaxGroupRequests[req.groupName] = 0;
        }
        AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
        if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function") {
          req.onGroupBegin(req.groupName);
        }
      }
      if (typeof(req.onLoading)=="function") {
        req.onLoading(req);
      }
      req.onLoadingInternalHandled = true;
    };
  req.onLoadedInternal = 
    function() {
      if (req.onLoadedInternalHandled) { return; }
      if (typeof(req.onLoaded)=="function") {
        req.onLoaded(req);
      }
      req.onLoadedInternalHandled = true;
    };
  req.onInteractiveInternal = 
    function() {
      if (req.onInteractiveInternalHandled) { return; }
      if (typeof(req.onInteractive)=="function") {
        req.onInteractive(req);
      }
      req.onInteractiveInternalHandled = true;
    };
  req.onCompleteInternal = 
    function() {
      if (req.onCompleteInternalHandled || req.aborted) { return; }
      req.onCompleteInternalHandled = true;
      AjaxRequest.numActiveAjaxRequests--;
      if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
        AjaxRequestEnd(req.groupName);
      }
      if (req.groupName!=null) {
        AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
        if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
          req.onGroupEnd(req.groupName);
        }
      }
      req.responseReceived = true;
      req.status = req.xmlHttpRequest.status;
      req.statusText = req.xmlHttpRequest.statusText;
      req.responseText = req.xmlHttpRequest.responseText;
      req.responseXML = req.xmlHttpRequest.responseXML;
      if (typeof(req.onComplete)=="function") {
        req.onComplete(req);
      }
      if (req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function") {
        req.onSuccess(req);
      }
      else if (typeof(req.onError)=="function") {
        req.onError(req);
      }

      // Clean up so IE doesn't leak memory
      delete req.xmlHttpRequest['onreadystatechange'];
      req.xmlHttpRequest = null;
    };
  req.onTimeoutInternal = 
    function() {
      if (req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled) {
        req.aborted = true;
        req.xmlHttpRequest.abort();
        AjaxRequest.numActiveAjaxRequests--;
        if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
          AjaxRequestEnd(req.groupName);
        }
        if (req.groupName!=null) {
          AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
          if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
            req.onGroupEnd(req.groupName);
          }
        }
        if (typeof(req.onTimeout)=="function") {
          req.onTimeout(req);
        }
      delete req.xmlHttpRequest['onreadystatechange'];
      req.xmlHttpRequest = null;
      }
    };

  // ----------------
  // Instance methods
  // ----------------
  req.process = 
    function() {
      if (req.xmlHttpRequest!=null) {
        if (req.generateUniqueUrl && req.method=="GET") {
          req.parameters["AjaxRequestUniqueId"] = new Date().getTime() + "" + req.requestIndex;
        }
        var content = null; 
		if(isubmittype=="file")
				req.enctype='multipart/form-data; boundary=AaB03x';
		if(req.enctype=="multipart/form-data; boundary=AaB03x")
		{
			var boundary = '--AaB03x'; 
			for (var i in req.parameters) { 			
         		req.queryString +=  boundary + '\n' 
				+ 'Content-Disposition: form-data; name="'+encodeURIComponent(i)+'"; '+'\n' 
				+ '\n' + req.parameters[i] + '\n';
			}
			if(isubmittype=="file"){

				var typename = new Array();
				var typename=isubmitvalue.split('.');
				req.queryString += boundary + '\n'  
				+ 'Content-Disposition: form-data; name="'+encodeURIComponent(isubmitname)+'"; filename="' 
				+ isubmitvalue + '"'+'\n'
				+'Content-Type: '+typename[1]+'\n'				
				+ '\n'+'\n'+'hgfh'+'\n'+'\n';
		
			}
  			req.queryString +=boundary;
		 }
		 else
		 {
        	for (var i in req.parameters) {
          		if (req.queryString.length>0) { req.queryString += "&"; }
          		req.queryString += encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);
        	}
		 }
        if (req.method=="GET") {
          if (req.queryString.length>0) {
            req.url += ((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;
          }
        }
		
        req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
        if (req.method=="POST") {
          if (typeof(req.xmlHttpRequest.setRequestHeader)!="undefined") {
            req.xmlHttpRequest.setRequestHeader('Content-type', req.enctype);	
			//alert(req.enctype+req.queryString);
			
          }
          content = req.queryString;
        }
        if (req.timeout>0) {
          setTimeout(req.onTimeoutInternal,req.timeout);
        }
		
        req.xmlHttpRequest.send(content);
      }
    };

  req.handleArguments = 
    function(args) {
      for (var i in args) {
        if (typeof(req[i])=="undefined") {
          req.parameters[i] = args[i];
        }
        else {
          req[i] = args[i];
        }
      }
    };

  req.getAllResponseHeaders =
    function() {
      if (req.xmlHttpRequest!=null) {
        if (req.responseReceived) {
          return req.xmlHttpRequest.getAllResponseHeaders();
        }
        alert("Cannot getAllResponseHeaders because a response has not yet been received");
      }
    };

  req.getResponseHeader =
    function(headerName) {
      if (req.xmlHttpRequest!=null) {
        if (req.responseReceived) {
          return req.xmlHttpRequest.getResponseHeader(headerName);
        }
        alert("Cannot getResponseHeader because a response has not yet been received");
      }
    };

  return req;
}

// ---------------------------------------
// Static methods of the AjaxRequest class
// ---------------------------------------

AjaxRequest.getXmlHttpRequest = function() {
  if (window.XMLHttpRequest) {
    return new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
      
    try {
      return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        return new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        return null;
      }
    }
    
  }
  else {
    return null;
  }
};

AjaxRequest.isActive = function() {
  return (AjaxRequest.numActiveAjaxRequests>0);
};

AjaxRequest.get = function(args) {
  AjaxRequest.doRequest("GET",args);
};

AjaxRequest.post = function(args) {
  AjaxRequest.doRequest("POST",args);
};

AjaxRequest.doRequest = function(method,args) {
  if (typeof(args)!="undefined" && args!=null) {
    var myRequest = new AjaxRequest();
    myRequest.method = method;
    myRequest.handleArguments(args);
    myRequest.process();
  }
}  ;

AjaxRequest.submit = function(theform, args) {
  var myRequest = new AjaxRequest();
  if (myRequest==null) { return false; }
  var serializedForm = AjaxRequest.serializeForm(theform);
  myRequest.method = theform.method.toUpperCase();
  myRequest.url = theform.action;
  if(theform.enctype=="multipart/form-data")
  	myRequest.enctype='multipart/form-data; boundary=AaB03x';
  myRequest.handleArguments(args);
  myRequest.queryString = serializedForm;
  myRequest.process();
  return true;
};

AjaxRequest.serializeForm = function(theform) {
  var els = theform.elements;
  var len = els.length;
  var queryString = "";
  var boundary = '--AaB03x'; 
  this.addField = 
    function(name,value,type) { 
	if(theform.enctype=="multipart/form-data" ){
			//req.queryString='';
			if(type=="file") 	
   				queryString += boundary + '\n'  
				+ 'Content-Disposition: file; name="'+encodeURIComponent(name)+'"; filename="' 
				+ value + '"' + '\n'+'\n'+'\n';
			else
				queryString += boundary + '\n'  
				+ 'Content-Disposition: form-data; name="'+encodeURIComponent(name)+'"; '+'\n' 
				+ '\n' + value + '\n';
		}
		else
		{
      if (queryString.length>0) { 
        queryString += "&";
      }
      queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
		}
    };
  for (var i=0; i<len; i++) {
    var el = els[i];
    if (!el.disabled) {
      switch(el.type) {
        case 'text': case 'password': case 'hidden': case 'textarea': case 'file':
          this.addField(el.name,el.value,el.type);
          break;
        case 'select-one':
          if (el.selectedIndex>=0) {
            this.addField(el.name,el.options[el.selectedIndex].value,el.type);
          }
          break;
        case 'select-multiple':
          for (var j=0; j<el.options.length; j++) {
            if (el.options[j].selected) {
              this.addField(el.name,el.options[j].value,el.type);
            }
          }
          break;
        case 'checkbox': case 'radio':
          if (el.checked) {
            this.addField(el.name,el.value,el.type);
          }
          break;	
		case 'submit': case 'button':
		  if(el.name==isubmitname && el.value==isubmitvalue && ( isubmittype=="submit" || isubmittype=="button"))
		  	this.addField(el.name,el.value,el.type);
      }
    }
  }
 
  return queryString;
};

// -----------------------
// Static Class variables
// -----------------------

AjaxRequest.numActiveAjaxRequests = 0;
AjaxRequest.numActiveAjaxGroupRequests = new Object();
AjaxRequest.numAjaxRequests = 0;

var isubmitname;
var isubmitvalue;
var isubmittype;

function toconvert(otoutf,oelement)
{
	var sourceareastr = oelement.value;
	var strlen = sourceareastr.length;
	var str="";
	if (otoutf=='wintoutf') { 
		 for (i = 0; i < strlen;  i++) { 
		  	var codestr = sourceareastr.charCodeAt(i);
		   	switch(codestr) {
				case 184: codestr=1105;break; 
				case 168: codestr=1025;break; 
			
				case 175: codestr=1198; break; 
				case 191: codestr=1199; break; 
				
				case 170: codestr=1256; break; 
				case 186: codestr=1257; break; 
		   }
		   if (256>codestr && codestr>191) 
		   		codestr=codestr+848;
		   switch(codestr) {
				case 1111: codestr=1199;break;   
				case 1031: codestr= 1198; break; 
				
				case 1108: codestr=1257; break; 
				case 1028: codestr=1256; break; 
		   }
			   str=str+String.fromCharCode(codestr);
		} 
		
		oelement.value=str;	   	   
	 
	} 
	else 
		if (otoutf=='utftowin') { 
			   for (i = 0; i < strlen;  i++) { 
					var codestr = sourceareastr.charCodeAt(i);
					switch(codestr) {
						case 1025: codestr=168;break; 
						case 1105: codestr=184;break; 
							
						case 1198: codestr=175; break; 
						case 1199: codestr=191; break; 
						
						case 1256: codestr=170; break; 
						case 1257: codestr=186; break; 
						
						case 415: codestr=170; break; 
						case 629: codestr=186; break; 
					}
					if (1280>codestr && codestr>1023) 
							codestr=codestr-848; 
					str=str+String.fromCharCode(codestr);
		   		}
	   			
				oelement.value=str;
	
	   		
        }
		
}

var editorMY=[];

function checkFormConvert(oCheckformId)
{
	var formError=0;
	var Checkform=document.getElementById(oCheckformId);
	var oldElemen;
	if(Checkform)
	{
		inputInd=0;		
		while(Checkform.getElementsByTagName('input')[inputInd])
		{
			
			var testinput=Checkform.getElementsByTagName('input')[inputInd];
			if(testinput.type!='file'){
				toconvert('wintoutf',testinput);
			}	
				
				if (testinput.className.indexOf("im_extvalidEmail")!=-1 ) {
					if(!validateEmail(testinput.id)){
						formError++;
					}
				}
				else
					if (testinput.className.indexOf("im_extvalidREEmail")!=-1 || testinput.className.indexOf("im_extvalidREpass")!=-1 ) {
						if(oldElemen && oldElemen.value!=testinput.value || testinput.value==''){
							if (testinput.className.indexOf("im_extvalidREEmail")!=-1)
								validateInputRE(testinput.id,"im_extvalidREEmail");
							else
								validateInputRE(testinput.id,"im_extvalidREpass");
							formError++;
						}
					}
					else
						if (testinput.className.indexOf("im_extvalid")!=-1 ) {
							if(!validateInput(testinput.id)){
								formError++;						
							}
						}
				
				oldElemen=testinput;
			
			inputInd++;
		}
		
		textareaInd=0;
		while(Checkform.getElementsByTagName('textarea')[textareaInd])
		{			
			var testarea=Checkform.getElementsByTagName('textarea')[textareaInd];						
			toconvert('wintoutf',testarea);	
			
			if (testarea.className.indexOf("im_extvalid")!=-1 ) {
				if(!validateInput(testarea.id)){
					formError++;						
				}
			}
			if(editorMY && editorMY[testarea.id])
				editorMY[testarea.id].loadContentFromField();
			textareaInd++;
		}		
		
		
			selectInd=0;
			while(Checkform.getElementsByTagName('select')[selectInd])
			{			
				var testselect=Checkform.getElementsByTagName('select')[selectInd];						
				
				if (testselect.className.indexOf("im_extvalid")!=-1 ) {
					if(!validateInput(testselect.id)){
						formError++;						
					}
				}
				
				selectInd++;
			}
	}
	//alert(formError);
	if(formError==0)
		return true;
	else	
		return false;
}



	function removescript(oelement){
		
		var fcontainer=document.getElementById(oelement);
		jsind=0;
		var mainbody=document.getElementsByTagName('body')[0];
		while(fcontainer.getElementsByTagName('script')[jsind]){
			var oldscript=fcontainer.getElementsByTagName('script')[jsind];
			if(document.getElementById(oelement+'_'+jsind)){
				var removejs=document.getElementById(oelement+'_'+jsind)
				mainbody.removeChild(removejs);
			}
			jsind++;
		}
		
	}

	function loadscript(oelement){
		
		var fcontainer=document.getElementById(oelement);
		jsind=0;
		var mainbody=document.getElementsByTagName('body')[0];
		while(fcontainer.getElementsByTagName('script')[jsind]){
			var oldscript=fcontainer.getElementsByTagName('script')[jsind];
			
			var newscript=document.createElement('scr'+'ipt');
			newscript.text=oldscript.text;
			newscript.id=oelement+'_'+jsind;
			newscript.type="text/javascript";
			if(oldscript.src)
				newscript.src=oldscript.src;
			
			mainbody.appendChild(newscript);
			jsind++;
		}
	}


	var winW = 800, winH = 600, winOrgW=800, WinOrgH=600, sizeload='no';
	
	function winodowsize(){		
		if (parseInt(navigator.appVersion)>3) 
		{
			 if (navigator.appName=="Netscape") 
			 {
				  winW = window.innerWidth;					 
				  winH = window.innerHeight;
			 }
			else
			 if (navigator.appName.indexOf("Microsoft")!=-1 ) 
			 {
				  winW = document.body.offsetWidth;					  
				  winH = document.body.offsetHeight;
			 }
			else
			 if(window.XMLHttpRequest)
			 {
				if(document.body.offsetHeight)
				 winH = document.body.offsetHeight;
				if(window.innerWidth)
				 winW = window.innerWidth;
			 }
			 
			 if(sizeload=='no'){
				 sizeload='yes';
				 winOrgW=winW;
				 winOrgH=winH;
  			     
				 if(document.getElementById('filebodyTDmainIndex') && winW<1120  && document.getElementById('myLangTD')){
					document.getElementById('filebodyTDmainIndex').style.width='1100px';
				 }
				 else{
					 mDw=winW-20; 
					 if(document.getElementById('filebodyTDmainIndex') && document.getElementById('myLangTD'))
					 document.getElementById('filebodyTDmainIndex').style.width=mDw+'px';
				 }
			 }
		
			
			 if(document.getElementById('sotester2')){
				document.getElementById('sotester2').setAttribute("width",winW);
				document.getElementById('sotester2').setAttribute("height",winH);
			 }
		}
	}

	function getCookie(c_name)
	{
		if (document.cookie.length>0)
		  {
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
			{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			}
		  }
		return "";
	}
	
	function setCookie(c_name,value,expiredays)
	{
		if(vsubpath2=='')
			path='/';
		else
			path=vsubpath2;
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+
		";path="+path;
	}
	
	var oldsel=[];	
	var lenchcolor1=[];
	var lenchcolor2=[];
	var lenchcolor3=[];
	
	
	lenchcolor1['mmenumain_']='mmenu_itemon';
	lenchcolor2['mmenumain_']='mmenu_itemoff';
	lenchcolor3['mmenumain_']='mmenu_itemon';
	oldsel['mmenumain_']=getCookie('mmenumain_');
	//oldsel['mmenumain_']='';
	oldsel['mmenumain_id']='MenuMainMedia';
	
	lenchcolor1['mmenumain2_']='mmenu_itemon2';
	lenchcolor2['mmenumain2_']='mmenu_itemoff2';
	lenchcolor3['mmenumain2_']='mmenu_itemon2';
	oldsel['mmenumain2_']=getCookie('mmenumain2_');

	oldsel['mmenumain2_id']='MenuMainMedia2';
	

	lenchcolor1['mmenumain3_']='mmenu_itemon3';
	lenchcolor2['mmenumain3_']='mmenu_itemoff3';
	lenchcolor3['mmenumain3_']='mmenu_itemon3';
	oldsel['mmenumain3_']=getCookie('mmenumain3_');
	
	oldsel['mmenumain3_id']='MenuMainMedia3';
	
	lenchcolor1['pbot_']='pb_itemon';
	lenchcolor2['pbot_']='pb_itemoff';
	lenchcolor3['pbot_']='pb_itemon';
	oldsel['pbot_']=getCookie('pbot_');
	oldsel['pbot_id']='';

	lenchcolor1['htab_']='dn_tabTopBarItem';
	lenchcolor2['htab_']='dn_tabTopBarItem2';
	lenchcolor3['htab_']='dn_tabTopBarItem';
	oldsel['htab_']=getCookie('htab_');
	oldsel['htab_id']='';
	
	lenchcolor1['htab2_']='dn_tabTopBarItem';
	lenchcolor2['htab2_']='dn_tabTopBarItem2';
	lenchcolor3['htab2_']='dn_tabTopBarItem';
	oldsel['htab2_']=getCookie('htab2_');
	oldsel['htab2_id']='';
	
	lenchcolor1['hscroll_']='dn_scrollItem';
	lenchcolor2['hscroll_']='dn_scrollItem2';
	lenchcolor3['hscroll_']='dn_scrollItem';
	oldsel['hscroll_']=getCookie('hscroll_');
	oldsel['hscroll_id']='';
	
	function reqLenFunc(otype,oele,oid,ocode){
		
		if(!oele.id){
			oele=document.getElementById(oele);
		}
		
		var jsTRid;
		jsTRid=ocode+oldsel[ocode];
		fspea=oid*1;
		nspea=oid*1+1;
		
		cur_fspea=oldsel[ocode]*1;
		cur_nspea=oldsel[ocode]*1+1;
		
		
		if(otype=='over' && oele.id!=jsTRid){			
			oele.className=lenchcolor1[ocode];
			
			if(document.getElementById(ocode+'spea_'+fspea)){
				document.getElementById(ocode+'spea_'+fspea).className=ocode+'spea0_sel';
			}
			if(document.getElementById(ocode+'spea_'+nspea)){
				document.getElementById(ocode+'spea_'+nspea).className=ocode+'spea0_sel';
			}
		}
		
		if(otype=='out' && oele.id!=jsTRid){
			oele.className=lenchcolor2[ocode];
			if(document.getElementById(ocode+'spea_'+fspea) &&  cur_fspea!=fspea && cur_nspea!=fspea){
				document.getElementById(ocode+'spea_'+fspea).className=ocode+'spea0';
			}
			if(document.getElementById(ocode+'spea_'+nspea) &&  cur_nspea!=nspea && cur_fspea!=nspea){
				document.getElementById(ocode+'spea_'+nspea).className=ocode+'spea0';
			}
			
		}
		
		if(otype=='click'){
			
			var jsCHECKid;
			jsCHECKid='vlensel'+oldsel[ocode];
			if(oldsel[ocode]!=0){
				
				if(document.getElementById(jsTRid))
					document.getElementById(jsTRid).className=lenchcolor2[ocode];
				if(document.getElementById(jsCHECKid))
					document.getElementById(jsCHECKid).checked='';
			}
			
			if(document.getElementById(ocode+'spea_'+fspea)){
				document.getElementById(ocode+'spea_'+fspea).className=ocode+'spea0_sel';
			}
			if(document.getElementById(ocode+'spea_'+nspea)){
				document.getElementById(ocode+'spea_'+nspea).className=ocode+'spea0_sel';
			}
			
			var jsCHECKid2;
			
			jsCHECKid2='vlensel'+oid;
			oldsel[ocode]=oid;
			if('mmenumain3_'==ocode || 'mmenumain2_'==ocode){
				setCookie('mmenumain3_','',0);
				setCookie('mmenumain2_','',0);
			}
			
			setCookie(ocode,oid,1);
			setCookie(ocode,oid,1);
			
			oele.className=lenchcolor3[ocode];
			if(document.getElementById(jsCHECKid2))
				document.getElementById(jsCHECKid2).checked='checked';
		}
		
	}
	
	var oldTopMenuSel=0;
	function leftNewsMenuClick(oclick){
		
		if(document.getElementById('MenuHLeftMedia_li_'+oldTopMenuSel+'_sub')){
			document.getElementById('MenuHLeftMedia_li_'+oldTopMenuSel+'_sub').className='my_MenuHLeftMedia_item1_sub1';
		}
		
		if(document.getElementById('MenuHLeftMedia_li_'+oclick+'_sub')){
			document.getElementById('MenuHLeftMedia_li_'+oclick+'_sub').className='my_MenuHLeftMedia_item1_sub1-sel';
		}
		oldTopMenuSel=oclick;
	}
	
	
	function ajaxpage(url, containerid)
	{
	
		var loadDivId='';
		if(document.getElementById(containerid+'_load'))
			loadDivId=containerid+'_load';
		else
			loadDivId=containerid;
		var loadHTML="<table width='16' height='16'><tr><td align='center'><img src='"+vsubpath+"/isimage/spinner.gif' border='0' width='16' height='16' align=absmiddle></td></tr></table>";	
		url=url+"&isajax=true"
		osendP=url.split('?');
		
		var isendf=[];
		expo1=osendP[1].split('&');
		for (k=0;k<expo1.length;k++) 
		{
			expo2=expo1[k].split('=');
			isendf[expo2[0]]=expo2[1];
		} 

		AjaxRequest.post(
		  {
			 'parameters':isendf 
			,'url':osendP[0]
			,'onLoading':function(req){ document.getElementById(loadDivId).innerHTML = loadHTML; }
			,'onLoaded':function(req){ document.getElementById(loadDivId).innerHTML = loadHTML;  }
			,'onInteractive':function(req){ 
				document.getElementById(loadDivId).innerHTML = loadHTML; 				
				//loadpage(req, containerid);			
			}
			,'onSuccess':function(req){ 
				
					loadpage(req, containerid);
			}
			,'onError':function(req){ 
				//alert(url+' Error!\nStatusText='+req.statusText+'\nContents='+req.responseText+'<br>');
				}
		  });
	}
	
	function loadpage(page_request, containerid) {
	
			document.getElementById(containerid).innerHTML = page_request.responseText;
			removescript(containerid);
			loadscript(containerid);
			
	}
	
	
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	function ltrim(stringToTrim) {
		return stringToTrim.replace(/^\s+/,"");
	}
	function rtrim(stringToTrim) {
		return stringToTrim.replace(/\s+$/,"");
	}


	function validateEmail(email) {
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   //var address = document.forms[form_id].elements[email].value;
	   var address = document.getElementById(email);
	    var address2 = trim(document.getElementById(email).value);
		
		
	   if(reg.test(address2) == false) {
		  //alert('Invalid Email Address');		  
		  address.className='im_extvalidEmail im_errorValid';
		  return false;
	   }
	   else{
		   address.className='im_extvalidEmail';
		   document.getElementById(email).value=address2;
	   	   return true;
	   }
	}
	
	function validateInputRE(oid,oclass){
		var address = document.getElementById(oid);
		address.className=oclass+' im_errorValid';
	}
	
	function validateEmailImg(email,email2){
		if(validateEmail(email))
			document.getElementById(email2).innerHTML="<img src='"+vsubpath+"/isimage/Tick.png' border=0 width=16 height=16 />"; 
		else 
			document.getElementById(email2).innerHTML="<img src='"+vsubpath+"/isimage/Delete.png' border=0 width=16 height=16 />";	
	}
	
	function validateEmailImg2(email,email2,email1){
		
		if(validateEmail(email1)){
		
			if(document.getElementById(email1).value==document.getElementById(email).value)
				document.getElementById(email2).innerHTML="<img src='"+vsubpath+"/isimage/Tick.png' border=0 width=16 height=16 />"; 
			else
				document.getElementById(email2).innerHTML="<img src='"+vsubpath+"/isimage/Delete.png' border=0 width=16 height=16 />";
		}
		else 
			document.getElementById(email2).innerHTML="<img src='"+vsubpath+"/isimage/Delete.png' border=0 width=16 height=16 />";	
	}
	
	function validateInput(email) {
	   
	   var address = document.getElementById(email);
	   
	   if(address.value=='') {
		  address.className='im_extvalid im_errorValid'; 
		  return false;
	   }
	   else{
		 address.className='im_extvalid'; 
	   	  return true;
	   }
	}
	
	 function overBannerLink(id) {
		for (var i = 1; i <= 5 ; i++) {
		  if(document.getElementById("bannerLinkA" + i)){			
			  if (i == id) {
				document.getElementById("bannerLinkA" + i).className = "selected";
				document.getElementById("banner" + i).className = "";
			  } else {
				document.getElementById("bannerLinkA" + i).className = "";
				document.getElementById("banner" + i).className = "hide";
			  }
		  }
		}
	  }
	  
	  
	  function PrintpageWin(theURL) {
		
		window.open(theURL, '', 'scrollbars=yes,toolbar=No,location=No,directories=No,menubar=yes,status=No,titlebar=No,resizable=no,width=1000,height=800');
	}


     var hb2slideE='';
	 
	 function hn2main(oid){
		 if(hb2slideE!='' && document.getElementById(hb2slideE) && hb2slideE!=oid){
		 	document.getElementById(hb2slideE).style.display='none';
		
		 if(hb2slideE!='' && document.getElementById(oid))
		 	document.getElementById(oid).style.display='block';
		hb2slideE=oid;
		 }
	 }
	 
	  var hb2slideE2='';
	 
	 function hn2main2(oid){
		 if(hb2slideE2!='' && document.getElementById(hb2slideE2)  && hb2slideE2!=oid){
		 	document.getElementById(hb2slideE2).style.display='none';
		
		 if(hb2slideE2!='' && document.getElementById(oid))
		 	document.getElementById(oid).style.display='block';
		hb2slideE2=oid;
		 }
	 }
	 
	
	var inetMpVpCurPage = [];
	var inetMpVpLock = [];

	var MpVpNum=[];
	var MpVpWidth=[];
	var MpVpimg=[];

	var showpageN='';
	
	function inetMpVpBlur( lnk ) {
		try {
			lnk.blur();
		} catch(e) {};
	}
	
	function inetMpVpNext( lnk , code) {
		inetMpVpBlur( lnk );
		if((inetMpVpCurPage[code] < MpVpNum[code])&&(!inetMpVpLock[code])) {
			inetMpVpSlideLeft(code);
		}
		else{
			if((inetMpVpCurPage[code] == MpVpNum[code])&&(!inetMpVpLock[code])) {
				inetMpVpPage(1,document.getElementById('inetMpVid'+code+'ADot1'),code);
			}
		}
	}
	
	function inetMpVpPrev( lnk , code) {
		inetMpVpBlur( lnk );
		if((inetMpVpCurPage[code] > 1)&&(!inetMpVpLock[code])) {
			inetMpVpSlideRight(code);
		}
	}

function inetMpVpPage( intPage, lnk , code) {
	
	inetMpVpBlur( lnk );

	if((inetMpVpCurPage[code] != intPage)&&(!inetMpVpLock[code])) {
		
		
		if(inetMpVpCurPage[code] < intPage) {
			if((intPage - inetMpVpCurPage[code]) > 1) {
				inetMpVpSlideSelect(intPage,code,'left');
			}
			else {
				inetMpVpSlideLeft(code);
			}
		}
		else {
			if((inetMpVpCurPage[code] - intPage) > 1) {
				//cnnMpVpSlideDoubleRight();
				inetMpVpSlideSelect(intPage,code,'right')
			}
			else {
				inetMpVpSlideRight(code);
			}
		}
	}
}

function inetLockMpVp( intDur,code ) {
	
	var inetLockDur = 200;
	inetMpVpLock[code] = true;
	if(document.getElementById('dn_pageLoad'+code+'DIV'))
		document.getElementById('dn_pageLoad'+code+'DIV').innerHTML='<img src="'+vsubpath+'/isimage/blackLoading.gif" />';
	setTimeout(function() { inetMpVpLock[code] = false; if(document.getElementById('dn_pageLoad'+code+'DIV'))
		document.getElementById('dn_pageLoad'+code+'DIV').innerHTML=''; 
		if(document.getElementById('inetMpVid'+code+'NUM1'))
			document.getElementById('inetMpVid'+code+'NUM1').innerHTML=inetMpVpCurPage[code]+'/'+MpVpNum[code];
		if(document.getElementById('inetMpVid'+code+'NUM2'))
			document.getElementById('inetMpVid'+code+'NUM2').innerHTML=inetMpVpCurPage[code]+'/'+MpVpNum[code];	
		},inetLockDur);
}
function inetMpVpSlideLeft(code) {
	inetLockMpVp(MpVpimg[code],code);
	//curPage=inetMpVpCurPage[code]+1;
	mPAge=inetMpVpCurPage[code];
	mPage2=inetMpVpCurPage[code]-1;
	saveSW1=0;
	saveSW2=0;
	for(j=0;j<MpVpNum[code];j++){
		setmpW=MpVpWidth[code]*(-1);	
		
		if(mPAge==j || mPage2==j){
				
			if(mPAge==j){
				saveSW1=setmpW;
			}
			else
				saveSW2=setmpW;
		}
		else{
			if(document.getElementById('in_box'+code+'DIV'+j)){
				moveintV=document.getElementById('in_box'+code+'DIV'+j).style.left.split('px')[0]*1+setmpW;	
				document.getElementById('in_box'+code+'DIV'+j).style.left=moveintV+'px';
			}
		}
	}
	
	if(saveSW2!=0){
		new Effect.MoveBy( 'in_box'+code+'DIV'+mPage2, 0, saveSW2 , {duration: 0.3} );
	}
	if(saveSW1!=0){
		new Effect.MoveBy( 'in_box'+code+'DIV'+mPAge, 0, saveSW1 , {duration: 0.3} );
	}
	inetMpVpCurPage[code]++;
	inetMpVpMoveDot(code);
	inetMpVpUpdateBtns(code);
}

function inetMpVpSlideRight(code) {
	inetLockMpVp(MpVpimg[code],code);
	//curPage=inetMpVpCurPage[code]-1;
	mPAge=inetMpVpCurPage[code]-2;
	mPage2=inetMpVpCurPage[code]-1;
	saveSW1=0;
	saveSW2=0;
	for(j=0;j<MpVpNum[code];j++){
		setmpW=MpVpWidth[code]*(-1);
		if(mPAge==j || mPage2==j){
			
			if(mPAge==j){
				saveSW1=MpVpWidth[code];
			}
			else
				saveSW2=MpVpWidth[code];
		}
		else{
			if(document.getElementById('in_box'+code+'DIV'+j)){
				moveintV=document.getElementById('in_box'+code+'DIV'+j).style.left.split('px')[0]*1+MpVpWidth[code];	
				document.getElementById('in_box'+code+'DIV'+j).style.left=moveintV+'px';
			}
		}
	}
	if(saveSW2!=0){
		new Effect.MoveBy( 'in_box'+code+'DIV'+mPage2, 0, saveSW2 , {duration: 0.3} );
	}
	if(saveSW1!=0){
		new Effect.MoveBy( 'in_box'+code+'DIV'+mPAge, 0, saveSW1 , {duration: 0.3} );
	}
	
	inetMpVpCurPage[code]--;
	inetMpVpMoveDot(code);
	inetMpVpUpdateBtns(code);
}

function inetMpVpSlideSelect(intPage,code,type) {
			
	if(type=='left'){
		indexT=-1;
		moveint=intPage - inetMpVpCurPage[code];
		moveint2=intPage - 1 - inetMpVpCurPage[code];
	}
	else{
		indexT=1;
		moveint=inetMpVpCurPage[code] - intPage;
		moveint2=inetMpVpCurPage[code] - intPage-1;
	}
	
	lockint=MpVpimg[code]*moveint;
	
	inetLockMpVp(MpVpimg[code],code);
	widthint=MpVpimg[code]*moveint;
	durint=0.3*moveint;
	mPAge=intPage-1;
	mPage2=inetMpVpCurPage[code]-1;
	saveSW1=0;
	saveSW2=0;
	for(j=0;j<MpVpNum[code];j++){
		setmpW=MpVpWidth[code]*indexT*moveint;
		
		if(mPAge==j || mPage2==j){

			if(mPAge==j){
				
		
				saveSW1=MpVpWidth[code]*indexT*moveint2;
				if(document.getElementById('in_box'+code+'DIV'+j)){
				moveintV=document.getElementById('in_box'+code+'DIV'+j).style.left.split('px')[0]*1+saveSW1;
				document.getElementById('in_box'+code+'DIV'+j).style.left=moveintV+'px';
				}
				saveSW1=MpVpWidth[code]*indexT;
			}
			else{
		
				saveSW2=setmpW;
			}
			
		}
		else{
			if(document.getElementById('in_box'+code+'DIV'+j)){
				moveintV=document.getElementById('in_box'+code+'DIV'+j).style.left.split('px')[0]*1+setmpW;	
				document.getElementById('in_box'+code+'DIV'+j).style.left=moveintV+'px';
			}
		}
	}
	
	if(saveSW2!=0){
		new Effect.MoveBy( 'in_box'+code+'DIV'+mPage2, 0, saveSW2 , {duration: 0.3} );
	}
	if(saveSW1!=0){
		new Effect.MoveBy( 'in_box'+code+'DIV'+mPAge, 0, saveSW1 , {duration: 0.3} );
	}
	
	
		
	if(type=='left'){
		inetMpVpCurPage[code]=inetMpVpCurPage[code]+moveint;
	}
	else{
		inetMpVpCurPage[code]=inetMpVpCurPage[code]-moveint;
	}
	inetMpVpMoveDot(code);
	inetMpVpUpdateBtns(code);
}


function inetMpDotMouseOver( id ) {
	$(id).src = vsubpath+'/isimage/main/status1.jpg';
}


function inetMpVpMoveDot(code) {
	setCookie(code,inetMpVpCurPage[code],1);
	mydivindsho=inetMpVpCurPage[code]-1;
	if(document.getElementById('in_box'+code+'DIV'+mydivindsho)){
		inetImgind=0;
		
		var searchdivs=document.getElementById('in_box'+code+'DIV'+mydivindsho);
		while(searchdivs.getElementsByTagName('img')[inetImgind]){
			if(searchdivs.getElementsByTagName('img')[inetImgind].src.indexOf(vsubpath+"/isimage/s.gif#")!= -1){
				//alert(1);
				searchdivs.getElementsByTagName('img')[inetImgind].src=searchdivs.getElementsByTagName('img')[inetImgind].src.split(vsubpath+"/isimage/s.gif#")[1];
				
			}
			inetImgind++;
		}
	}

	forint=MpVpNum[code]+1;
	for(i=1;i<forint;i++) {
		if($('inetMpVid'+code+'Dot'+i)){
			$('inetMpVid'+code+'Dot'+i).src = vsubpath+'/isimage/main/'+code+'status0.jpg';
			$('inetMpVid'+code+'Dot'+i).onmouseover = function() {this.src = vsubpath+'/isimage/main/'+code+'status1.jpg';}
			$('inetMpVid'+code+'Dot'+i).onmouseout = function() {this.src = vsubpath+'/isimage/main/'+code+'status0.jpg';}
		}
		else{
			if($('inetMpVid'+code+'2Dot'+i)){
				$('inetMpVid'+code+'2Dot'+i).style.borderWidth = 0;
				
			}
			else
				if($('inetMpVid'+code+'3Dot'+i)){		
					$('inetMpVid'+code+'3Dot'+i).className = 'in2_boxgalleryPage';			
				}
		}
	}
	if($('inetMpVid'+code+'Dot'+inetMpVpCurPage[code])){
		$('inetMpVid'+code+'Dot'+inetMpVpCurPage[code]).src = vsubpath+'/isimage/main/'+code+'status1.jpg';
		$('inetMpVid'+code+'Dot'+inetMpVpCurPage[code]).onmouseover = function() {}
		$('inetMpVid'+code+'Dot'+inetMpVpCurPage[code]).onmouseout = function() {}
	}
	else{
		if($('inetMpVid'+code+'2Dot'+inetMpVpCurPage[code])){		
			$('inetMpVid'+code+'2Dot'+inetMpVpCurPage[code]).style.borderWidth = 1;			
		}
		else
			if($('inetMpVid'+code+'3Dot'+inetMpVpCurPage[code])){		
				$('inetMpVid'+code+'3Dot'+inetMpVpCurPage[code]).className = 'in2_boxgalleryPage2';			
			}
	}
}
function inetMpVpUpdateBtns(code) {
	if($('inetMpVid'+code+'BtnL')){
		if(inetMpVpCurPage[code] > 1) {
			$('inetMpVid'+code+'BtnL').style.cursor ='auto';
			$('inetMpVid'+code+'BtnL').src = vsubpath+'/isimage/main/'+code+'leftbtn3.jpg';
			$('inetMpVid'+code+'BtnL').onmouseover = function() { this.src=vsubpath+'/isimage/main/'+code+'leftbtn2.jpg'; }
			$('inetMpVid'+code+'BtnL').onmouseout = function() { this.src=vsubpath+'/isimage/main/'+code+'leftbtn3.jpg'; }
		}
		else {
			$('inetMpVid'+code+'BtnL').style.cursor ='default';
			$('inetMpVid'+code+'BtnL').src = vsubpath+'/isimage/main/'+code+'leftbtn1.jpg';
			$('inetMpVid'+code+'BtnL').onmouseover = function() {}
			$('inetMpVid'+code+'BtnL').onmouseout = function() {}
		}
	
		if(inetMpVpCurPage[code] < MpVpNum[code]) {
			$('inetMpVid'+code+'BtnR').style.cursor ='auto';
			$('inetMpVid'+code+'BtnR').src = vsubpath+'/isimage/main/'+code+'rightbtn3.jpg';
			$('inetMpVid'+code+'BtnR').onmouseover = function() {this.src = vsubpath+'/isimage/main/'+code+'rightbtn2.jpg';}
			$('inetMpVid'+code+'BtnR').onmouseout = function() {this.src = vsubpath+'/isimage/main/'+code+'rightbtn3.jpg';}
		}
		else {
			$('inetMpVid'+code+'BtnR').style.cursor ='default';
			$('inetMpVid'+code+'BtnR').src = vsubpath+'/isimage/main/'+code+'rightbtn1.jpg';
			$('inetMpVid'+code+'BtnR').onmouseover = function() {}
			$('inetMpVid'+code+'BtnR').onmouseout = function() {}
		}
	}
	
}


	function jsReplaceDate(odate,odate2,otime,rcode){
		var now = new Date();
		
		var month = now.getMonth() + 1;
		if(month<10)
			month='0'+month;
		var day=now.getDate();
		if(day<10)
			day='0'+day;
		nowDate=now.getFullYear()+'-'+month +'-'+day;
		nowTime=now.getHours()+':'+now.getMinutes() +':00';
		var retval='';
		if(nowDate==odate || nowDate==odate2){
			
			
			var fdateH=0;
			//if(nowDate==odate){
				dateM=odate.split('-')[1]*1-1;
				var inodate = new Date(odate.split('-')[0],dateM,odate.split('-')[2],otime.split(':')[0],otime.split(':')[1],otime.split(':')[2]);
				
				var fmktime2=inodate.getTime();
				
			/*}
			else{
				dateM=odate2.split('-')[1]*1-1;
				var inodate2 = new Date(odate2.split('-')[0],dateM,odate2.split('-')[2],otime.split(':')[0],otime.split(':')[1]+','+otime.split(':')[2]);
				var fmktime2=inodate2.getTime()-60*60*1000*24*2;
			}
			*/
			var fmktime3=now.getTime();
			//-60*60*1000*8
			var fmktime4=fmktime3-fmktime2;
			var one_day=1000*60*60*24;
			
			if(fmktime4<one_day){
				fdateH=parseInt(fmktime4/(1000*60*60));
				fdateH4=fmktime4-fdateH*1000*60*60;
				fdateI=parseInt(fdateH4/(1000*60));
				if(fdateH>0)	
					retval='<span class="inc_infodate2" >'+fdateH+' цаг '+fdateI+' минутийн өмнө</span>';
				else
					retval='<span class="inc_infodate2" >'+fdateI+' минутын өмнө</span>';
			}
			else
				retval=odate+' '+otime;	
		}
		else			
			retval=odate+' '+otime;
		//document.write(retval);
		var elname=odate.replace(/-/gi,'')+'_'+otime.replace(/:/gi,'')+'_'+rcode;
		//document.getElementById('mmenumain3_1755').innerHTML=elname+' '+nowDate+' '+nowTime;
		if(document.getElementById(elname))
			document.getElementById(elname).innerHTML=retval;
	}
	
	function weatherDate(odate,code,ele){
		var now = new Date();
		
		var month = now.getMonth() + 1;
		if(month<10)
			month='0'+month;
		var day=now.getDate();
		if(day<10)
			day='0'+day;	
		nowDate=now.getFullYear()+'-'+month +'-'+day;
		
		if(nowDate!=odate){
			ajaxpage(vsubpath+'/dchange.php?bc='+code, ele);
		}
	}
	
	
	/******* Alert MSG START 2009-05-19 ***********/
	
	function alertshow(otit,otext){	
		window.scrollTo(0,0);
		if (parseInt(navigator.appVersion)>3) 
		{
			 if (navigator.appName=="Netscape") 
			 {
				  winW = window.innerWidth;					 
				  winH = window.innerHeight;
			 }
			else
			 if (navigator.appName.indexOf("Microsoft")!=-1 ) 
			 {
				  winW = document.body.offsetWidth;					  
				  winH = document.body.offsetHeight;
			 }
			else
			 if(window.XMLHttpRequest)
			 {
				if(document.body.offsetHeight)
				 winH = document.body.offsetHeight;
				if(window.innerWidth)
				 winW = window.innerWidth;
			 }
			 			 			 
		}
	
		newPosX=(winW-600)/2;
		newPosY=100;
		if(document.getElementById('ext-comp-MSG1002')){
			
			if(document.getElementById('ext-genMSG57') && otit!=''){
				document.getElementById('ext-genMSG57').innerHTML=otit;
			}
			if(document.getElementById('ext-genMSG68') && otext!=''){
				document.getElementById('ext-genMSG68').innerHTML=otext;
			}
			if(document.getElementById('ext-genMSG56')){
				document.getElementById('ext-genMSG56').setAttribute("width",winW);
				document.getElementById('ext-genMSG56').setAttribute("height",winH);	
				document.getElementById('ext-genMSG56').style.display='block';
			}
			
			
			document.getElementById('ext-comp-MSG1002').style.top=newPosY+'px';
			document.getElementById('ext-comp-MSG1002').style.left=newPosX+'px';
			document.getElementById('ext-comp-MSG1002').style.visibility='visible';
			
		}
	}
	
	function alertclose(){
		if(document.getElementById('ext-comp-MSG1002')){			
			document.getElementById('ext-comp-MSG1002').style.top='-1000px';
			document.getElementById('ext-comp-MSG1002').style.left='-1000px';
			document.getElementById('ext-comp-MSG1002').style.visibility='hidden';
			document.getElementById('ext-genMSG56').style.display='none';
		}	
	}
	
	
	function alertchange(otype){
		
		if(otype=='alert'){
			if(document.getElementById('ext-genMSGOK21')){		
				document.getElementById('ext-genMSGOK21').className='x-panel-btn-td';
				document.getElementById('ext-genMSGCANCEL45').className='x-panel-btn-td x-hide-offsets';
				document.getElementById('ext-genMSGlogo').className='ext-mb-fix-cursor';
			}	
		}
		else
			if(otype=='window'){
				if(document.getElementById('ext-genMSGOK21')){		
					document.getElementById('ext-genMSGOK21').className='x-panel-btn-td x-hide-offsets';
					document.getElementById('ext-genMSGCANCEL45').className='x-panel-btn-td';
					document.getElementById('ext-genMSGlogo').className='';
				}
			}
			else
				if(otype=='form'){
					if(document.getElementById('ext-genMSGOK21')){		
						document.getElementById('ext-genMSGOK21').className='x-panel-btn-td x-hide-offsets';
						document.getElementById('ext-genMSGCANCEL45').className='x-panel-btn-td x-hide-offsets';
						document.getElementById('ext-genMSGlogo').className='';
					}
				}
	}


	/******* Alert MSG END ***********/	
		 