



var myShowForm=false;
var myContentForm = false;
var form_element_prefix = "ctl00_Main_";
var GB_ROOT_DIR = "http://"+greyboxPath(document.location.href)+"/admin/code/JavaScript/greybox/";
/********************************************************************************************************/
var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=["Pub/design/1.jpg", "", ""] //plain image syntax
fadeimages[1]=["Pub/design/2.jpg", "", ""] //image with link syntax
fadeimages[2]=["Pub/design/3.jpg", "", ""] //image with link and target syntax
fadeimages[3]=["Pub/design/4.jpg", "", ""]
fadeimages[4]=["Pub/design/5.jpg", "", ""]
fadeimages[5]=["Pub/design/6.jpg", "", ""]
fadeimages[6]=["Pub/design/7.jpg", "", ""]
fadeimages[7]=["Pub/design/8.jpg", "", ""]
fadeimages[8]=["Pub/design/9.jpg", "", ""]
fadeimages[9]=["Pub/design/10.jpg", "", ""]
fadeimages[10]=["Pub/design/11.jpg", "", ""]
fadeimages[11]=["Pub/design/12.jpg", "", ""]
fadeimages[12]=["Pub/design/13.jpg", "", ""]
fadeimages[13]=["Pub/design/14.jpg", "", ""]
fadeimages[14]=["Pub/design/15.jpg", "", ""]
fadeimages[15]=["Pub/design/16.jpg", "", ""]
fadeimages[16]=["Pub/design/17.jpg", "", ""]
fadeimages[17]=["Pub/design/18.jpg", "", ""]


var fadebgcolor="blue"
 
var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages2[0]=["Pub/design/1.jpg", "", ""] //plain image syntax
fadeimages2[1]=["Pub/design/2.jpg", "", ""] //image with link syntax
fadeimages2[2]=["Pub/design/3.jpg", "", ""]
fadeimages2[3]=["Pub/design/4.jpg", "", ""]
fadeimages2[4]=["Pub/design/5.jpg", "", ""]
fadeimages2[5]=["Pub/design/6.jpg", "", ""]
fadeimages2[6]=["Pub/design/7.jpg", "", ""]
fadeimages2[7]=["Pub/design/8.jpg", "", ""]
fadeimages2[8]=["Pub/design/9.jpg", "", ""]
fadeimages2[9]=["Pub/design/10.jpg", "", ""]
fadeimages2[10]=["Pub/design/11.jpg", "", ""]
fadeimages2[11]=["Pub/design/12.jpg", "", ""]
fadeimages2[12]=["Pub/design/13.jpg", "", ""] //image with link and target syntax
fadeimages2[13]=["Pub/design/14.jpg", "", ""]
fadeimages2[14]=["Pub/design/15.jpg", "", ""]
 
var fadebgcolor="blue"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck=pause
this.mouseovercheck=0
this.delay=delay
this.degree=10 //initial opacity degree (10%)
this.curimageindex=0
this.nextimageindex=1
fadearray[fadearray.length]=this
this.slideshowid=fadearray.length-1
this.canvasbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
 
var fadewidth=fadewidth+this.imageborder*2
var fadeheight=fadeheight+this.imageborder*2
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;background-color:'+fadebgcolor+'"></div></div>')
else
document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}

function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if (obj.tempobj.filters&&obj.tempobj.filters[0]){
if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
obj.tempobj.filters[0].opacity=obj.degree
else //else if IE5.5-
obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
}
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
if (this.pausecheck==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseovercheck==1)
setTimeout(function(){cacheobj.rotateimage()}, 100)
else if (iebrowser&&dom||dom){
this.resetit()
var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
crossobj.style.zIndex++
fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
}
else{
var ns4imgobj=document.images['defaultslide'+this.slideshowid]
ns4imgobj.src=this.postimages[this.curimageindex].src
}
this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if (crossobj.filters&&crossobj.filters[0]){
if (typeof crossobj.filters[0].opacity=="number") //if IE6+
crossobj.filters(0).opacity=this.degree
else //else if IE5.5-
crossobj.style.filter="alpha(opacity="+this.degree+")"
}
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=obj.degree/100
}
 
 
fadeshow.prototype.startit=function(){
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
this.populateslide(crossobj, this.curimageindex)
if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
}
this.rotateimage()
}
/******************************************************************* END OF IMAGE FADING *****************/


function greyboxPath(url_)
{
	url_ = (url_.indexOf('http://') > -1) ? url_.substring(7,url_.length) : url_.substring(8,url_.length);
	url_ = url_.substring(0,url_.indexOf('/'))
	return url_;
}

function MyNav(elementID,Show){
	if(document.getElementById('Menu'+elementID)){
		document.getElementById('Menu'+elementID).style.display = Show ? 'block' : 'none';
	}
}

function ManageContent(Action,thisIDname,thisIDvalue,PartNumber,FileName,K_){
			
	if (myContentForm){
		myContentForm.close();
	}
	
	if(Action=="D"){
		if(document.getElementById('current_content_container')){
			document.getElementById('current_content_container').value="|"+thisIDname+","+thisIDvalue+","+PartNumber+","+K_+"|";
			return false;
		}else{
			return false;
		}
	}
	
	K_ = K_ ? K_ : 0;

//	myContentForm = window.open('/admin/code/Content/ContentForm/ContentForm_'+FileName+'_'+PartNumber+'.aspx?A='+Action+'&B='+thisIDname+'&C='+thisIDvalue+'&D='+PartNumber+'&E='+K_,'ContentManage','toolbars=no,scrollbars=yes,status=yes,location=no,width=600,height=575,resizable=yes,left=10,top=10,postionx=10,positiony=10');
	GB_showCenter('Manage Content','/admin/code/Content/ContentForm/ContentForm_'+FileName+'_'+PartNumber+'.aspx?A='+Action+'&B='+thisIDname+'&C='+thisIDvalue+'&D='+PartNumber+'&E='+K_,700,900);


}


function ShowAddUpdate(FileName,Action,Args,PopUp){

	var isMac = navigator.userAgent.indexOf('Mac') != -1 
		
	if (isMac){
		if (Args){
			if(Args.substring(1,1) != "&"){
				Args = '&'+Args
			}
		}else{
			Args = ''
		}	
	}else{
		if ((Args != undefined) && (Args != '')){
			if(Args.substring(1,1) != "&"){
			Args = '&'+Args
			}
		}else{
			Args = ''
		}
	}
	
	var formName = 'formName'

	var xtraArgs = document.location.href;
	if(xtraArgs.indexOf('?')>0){
		xtraArgs = xtraArgs.substring(xtraArgs.indexOf('?')+1,xtraArgs.length);
		if(Action=="U" || Action=="S" &&Args.indexOf('PK=')>-1){
			xtraArgs=xtraArgs.replace(/PK=[\S]*?&/gi,"");
		}
	}else{
		xtraArgs = "";
	}

	if(Args!=""&&xtraArgs!=""){xtraArgs='&'+xtraArgs;}
	Args += xtraArgs; 
	if(Args!=""&&Args.substring(0,1)!='&'){
		Args='&'+Args;
	}
	if(myShowForm){
		myShowForm.close();
	}
	


	var prefixPath = "/admin/code/AddUpdatePages/";	
	if(PopUp){
		prefixPath = "/admin/code/PopUp/";
	}

//	myShowForm = window.open(prefixPath+FileName+'?A='+Action+Args,formName,'toolbars=no,scrollbars=yes,status=yes,location=no,width=600,height=575,resizable=yes,left=10,top=10,postionx=10,positiony=10');
//	myShowForm.focus();
	
	GB_showCenter('Manage Form', prefixPath+FileName+'?A='+Action+Args,700,900);

}


function ShowPopUp(FileName){
	var formName = 'formName'+FileName.replace(/[^a-zA-Z]/gi,"");
	var prefixPath = "/admin/code/PopUp/";

	var myPopUpForm = window.open(prefixPath+FileName,formName,'toolbars=no,scrollbars=yes,status=yes,location=no,width=900,height=625,resizable=yes,left=10,top=10,postionx=10,positiony=10');
	myPopUpForm.focus();
}


function closeForm(){
	try{
		parent.parent.GB_hide();
	} catch(err){
		opener.document.location.href=opener.document.location.href;
		window.close();
	}
}

function RunOrderByColumnName(ColumnName){

	if(document.getElementById('ctl00_Main_OrderByColumnName')){
		var currOrderByColumnName = document.getElementById('ctl00_Main_OrderByColumnName')
		if(currOrderByColumnName.value==ColumnName+' ASC'){
			currOrderByColumnName.value=ColumnName+' DESC';
		}else{
			currOrderByColumnName.value=ColumnName+' ASC';
		}
			
	}
	document.forms[0].submit();
}



function showPrint(PrintKey){
	var myPrint = window.open('/admin/code/Print/ManagePrint.aspx?A='+PrintKey,PrintKey,'toolbars=yes,scrollbars=yes,status=yes,location=no,width=650,height=575,resizable=yes,left=10,top=10,postionx=10,positiony=10');
	myPrint.focus();

}

function showPrintPage(Page){
	var URL = "/Admin/Code/PopUp/PopUp_Print.aspx?page="+Page;
	GB_showCenter('Print Page',URL,null,778);

}




function ChangePage(Action,To,Step){
	var regRetVal = new RegExp(/retVal=[\S|\s]*/gi);
	var regURL = new RegExp(/http:\/\/[\S]*?\.[\S]*?\//i);
	var retVal = regRetVal.exec(document.location.href); 
	retVal = retVal ? retVal[0] : "";

	var baseURL = regURL.exec(document.location.href);
	baseURL = baseURL[0];
	var currPage = document.location.href;
	currPage = currPage.substring(baseURL.length-1,currPage.length);
	Step = Step ? Step : 0;


	if(Action=="BACK"){
		var itemName="";itemValue="";itemArray = new Array();
		retVal = retVal.replace(/\%3a/gi,":");
		retVal = retVal.replace(/\%7C/gi,"|");
		if(retVal.substring(0,7)=='retVal='){
			retVal = retVal.substring(7,retVal.length);
		}
		var retHistory = retVal.split(/\|/gi);
		for(k=0;k<retHistory.length;k++){
			itemName = retHistory[k].substring(0,retHistory[k].indexOf(':'))
			itemValue = retHistory[k].substring(retHistory[k].indexOf(':')+1,retHistory[k].length);
			itemArray[itemName] = URLDecode(itemValue);
		}
		

		if(itemArray.length>=Step){
			if(itemArray[Step].indexOf('&retVal=')>0){
				retVal = itemArray[Step];
				retVal = retVal.substring(retVal.indexOf('&retVal=')+8,retVal.length)
				itemArray[Step] = itemArray[Step].substring(0,itemArray[Step].indexOf('&retVal=')+7)+"="+URLEncode(retVal)+'|';
			} 
			document.location.href = itemArray[Step];
		}else{
			alert('Could not find Step in the retVal of the previous querystring');
			return false;
		}
	
	}else if(Action=="NEXT"){
		// append to retVal if applicable		
		if(retVal){
			currPage = (currPage.substring(currPage.length-1,currPage.length)!='|') ? currPage+'|' : currPage;
			retVal+=Step+":"+URLEncode(currPage)
			if (To.indexOf("?")==-1){
				To+='?'+retVal;
			}else{
				To+="&"+retVal;
			}
			document.location.href = To;
		}else{
			retVal = "&retVal="+Step+":"+URLEncode(currPage)+'|'
			To+=retVal;
			document.location.href = To;
		}	
		
	}else{
		alert('No Action Specified: BACK OR NEXT');
		return false;
	}

}



function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function Set_Cookie( name, value, expires, path, domain, secure ){
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/

if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function Delete_Cookie(name,path,domain) { 
   if (Get_Cookie(name)) document.cookie = name + "=" + 
      ( (path) ? ";path=" + path : "") + 
      ( (domain) ? ";domain=" + domain : "") + 
      ";expires=Thu, 01-Jan-70 00:00:01 GMT"; 
} 





function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}




//Drop-Down Menu Start

var DDSPEED = 2;
var DDTIMER = 2;

// main function to handle the mouse events //
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.display = 'block';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

// collapse the menu //
function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  }else{
    dist = (Math.round(currh / DDSPEED));
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
}

//Drop-Down Menu Stop