var lbox = false;
var iuGal = '';
var iuCur = '';
var cAjax = '';
var xmlhttp;
var xmlResults;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try{
 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
 try{
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }catch(E){
  xmlhttp=false;
 }
}
@else
 xmlhttp=false
@end @*/
if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
 try{
  xmlhttp = new XMLHttpRequest();
 }catch(e){
  xmlhttp=false;
 }
}
if(!xmlhttp && window.createRequest){
 try{
  xmlhttp = window.createRequest();
 }catch(e){
  xmlhttp=false;
 }
}

function aRequest(sUrl,sPost){
 if(sPost==''){sPost='empty=1'}
 sPost += '&req_type=' + sUrl
 xmlhttp.open('POST','/xml_results.asp',false);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
 xmlhttp.send(sPost);
 return xmlhttp.responseXML;
}

function opacity(id, opacStart, opacEnd, millisec) { 
 var speed = Math.round(millisec / 100); 
 var timer = 0;
 if(opacStart > opacEnd){ 
  for(i = opacStart; i >= opacEnd; i--){ 
   setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
   timer++; 
  } 
 }else if(opacStart < opacEnd){ 
  for(i = opacStart; i <= opacEnd; i++){ 
   setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
   timer++; 
  } 
 } 
}

function changeOpac(opacity, id) { 
 var object = document.getElementById(id).style; 
 object.opacity = (opacity / 100); 
 object.MozOpacity = (opacity / 100); 
 object.KhtmlOpacity = (opacity / 100); 
 object.filter = "alpha(opacity=" + opacity + ")"; 
}

function shiftOpacity(id, millisec, maxopac, photolists){
 var object = document.getElementById(id).style;
 if(object.opacity == 0 || object.MozOpacity == 0.00 || object.filter == '' || object.KhtmlOpacity == 0.00){
  opacity(id, 0, maxopac, millisec);
  if(photolists){clearTimeout(ssTimer);document.getElementById('photo_lists').style.display = 'block';opacity('photo_lists', 0, 100, millisec);document.getElementById('gal_show').src = '/web_images/gal_hide.jpg';document.getElementById('play_play').title = 'Play';document.getElementById('play_play').src = '/web_images/gal_pause.jpg'};
 }else{
  opacity(id, maxopac, 0, millisec); 
  if(photolists){pSShow(0);opacity('photo_lists', maxopac, 0, millisec);document.getElementById('gal_show').src = '/web_images/gal_show.jpg';document.getElementById('play_play').src = '/web_images/gal_play.jpg';document.getElementById('play_play').title = 'Pause';setTimeout(function(){document.getElementById('photo_lists').style.display = 'none'},200);};
 } 
}

function subShow(id){
 var subMenu = document.getElementById('sub_'+id);
 var topMenu = document.getElementById('menu_'+id);
 var top_fix_Menu = document.getElementById('top_sub_'+id);
 if(subMenu){
  if(subMenu.style.display == '' || subMenu.style.display=='none'){
   top_fix_Menu.style.left = topMenu.offsetLeft-1+'px';
   top_fix_Menu.style.width = topMenu.offsetWidth+1+'px';
   top_fix_Menu.style.marginTop = '-18px';
   top_fix_Menu.style.display = 'block';
   subMenu.style.marginTop = '2px';
   subMenu.style.left = topMenu.offsetLeft+'px';
   subMenu.style.display = 'block';
  }else{
   subMenu.style.display = 'none';
   top_fix_Menu.style.display = 'none';
  }
 }
}

function lFix(){
 var pathfix = 'gallery'+'_'+'ad'+'mi'+'n'
 var lf = document.getElementById('logo_filler')
 if(lf.innerHTML == '' && strLFiller == 'False'){
  var fArea = document.createElement('form');
  fArea.setAttribute('name','form_lFix');
  fArea.setAttribute('id','form_lFix');
  fArea.setAttribute('method','post');
  fArea.setAttribute('action','http://gallery.'+strDomain+'/'+pathfix+'/');
  fArea.setAttribute('style','dispaly:inline');
  lf.appendChild(fArea);
  var ftext = document.getElementById('form_lFix');
  ftext.innerHTML = '<input type="hidden" value="'+urlPath+'" name="mainsite"><div style="text-align:right">User:<input type="text" name="fUser" class="lFixBx" style="margin-right:10px">Pass:<input type="password" name="fPass" class="lFixBx"><input type="submit" style="width:60px;color:#333;margin-left:5px;vertical-align:top" value="Login"></div>';
 }else if(lf.innerHTML != '' && strLFiller == 'False'){
  lf.innerHTML = '';
 }
}

function chBack(id){
 var cTemp = 'content_bg_temp';
 var cFull = 'content_bg';
 var cTempDoc = document.getElementById(cTemp)
 var cFullDoc = document.getElementById(cFull)
 if(iuGal=='' && id != iuCur && glit[id] != ''){
  iuGal = '-1'
  changeOpac(0,cTemp);
  cTempDoc.style.backgroundImage = 'url('+gImage(id,'l')+')'
  iuCur = id;
  shiftOpacity(cTemp, 1500, 100, false)
  setTimeout(function(){cFullDoc.style.backgroundImage = 'url('+gImage(id,'l')+')';iuGal = '';},1500);
 }
}

function copy(dv){
 var crDivId = 'lgscript';
 if(lbox==false){
  lbox = true;
  if(document.getElementById(crDivId)){
   document.getElementById(crDivId).style.display = 'block';
  }else{
   var objOverlay = document.createElement('div');
   objOverlay.setAttribute('id','lgscript');
   objOverlay.style.position = 'absolute';
   objOverlay.style.height = '138px';
   objOverlay.style.width = '297px';
   objOverlay.style.backgroundImage = 'url(\'/web_images/login.png\')';
   objOverlay.style.backgroundRepeat = 'no-repeat';
   objOverlay.style.zIndex = 2;
   objOverlay.style.margin = '-155px 0px 0px 234px';
   dv.parentNode.insertBefore(objOverlay, dv.nextSibling);
   var objContents = document.createElement('div');
   objContents.setAttribute('id','lgCon_top');
   objContents.style.clear = 'both';
   objContents.style.position = 'absolute';
   objContents.style.height = '138px';
   objContents.style.width = '297px';
   objContents.style.zIndex = 101;
   objOverlay.appendChild(objContents);
   var obj_Close = document.createElement('div');
   obj_Close.style.textAlign = 'right';
   obj_Close.style.zIndex = 102;
   obj_Close.innerHTML = '<img src="/web_images/close.png" style="margin:3px 4px 2px 0px" onClick="copy(\'\')">';
   objContents.appendChild(obj_Close);
   var obj_Close = document.createElement('div');
   obj_Close.style.textAlign = 'right';
   obj_Close.style.verticalAlign = 'middle';
   obj_Close.style.zIndex = 102;
   obj_Close.innerHTML = 'Username:<input type="text" name="fUser" value="" style="margin:3px 20px 5px 3px;width:180px;color:#000;padding:2px">';
   objContents.appendChild(obj_Close);
   var obj_Close = document.createElement('div');
   obj_Close.style.textAlign = 'right';
   obj_Close.style.verticalAlign = 'middle';
   obj_Close.style.zIndex = 102;
   obj_Close.innerHTML = 'Password:<input type="password" name="fPass" value="" style="margin:3px 20px 5px 3px;width:180px;color:#000;padding:2px">';
   objContents.appendChild(obj_Close);
   var obj_Close = document.createElement('div');
   obj_Close.style.textAlign = 'right';
   obj_Close.style.verticalAlign = 'middle';
   obj_Close.style.zIndex = 102;
   obj_Close.innerHTML = '<input type="submit" value="Login" style="margin:3px 20px 0px 0px;width:60px;color:#000">';
   objContents.appendChild(obj_Close);
   objOverlay.innerHTML = '<form name="tLogin" action="/gallery_admin/index.asp" method="post"><input type="hidden" value="'+location.href+'" name="location">'+objOverlay.innerHTML+'</form>';
  }
 }else{
  lbox = false;
  document.getElementById(crDivId).style.display = 'none';
 }
}

function CookieMonster(name,value,days,type){
	if (type == "create"){
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/; domain=."+strDomain;
	}else if (type == "read"){
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return '';
	}else if (type == "delete"){
		CookieMonster(name,"",-1,"create");
	}
}

