


var greybox_title = "";
var myShowForm=false;
var myContentForm = false;
var form_element_prefix = "ctl00_Main_";
var GB_ROOT_DIR = "http"+(("https:" == document.location.protocol) ? "s" : "")+"://"+greyboxPath(document.location.href)+"/admin/code/JavaScript/greybox/";

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 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( greybox_title,'/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( greybox_title, prefixPath+FileName+'?A='+Action+Args,700,900);

}


function ShowPopUp(FileName,useGreyBox,width,height){
	var formName = 'formName'+FileName.replace(/[^a-zA-Z]/gi,"");
	var prefixPath = "/admin/code/PopUp/";

	if (useGreyBox){
		//alert(width);
		GB_showCenter( greybox_title,prefixPath+FileName,height ? height : 700 ,width ? width : 900);
	}else{
		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(/https*:\/\/[\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 CommentChange(textarea,counter) {
	var len = document.getElementById(textarea).value
	if (1000 - len.length <= 0){
		document.getElementById(texarea).value = len.substring(0, 1000);
		alert('You have entered the max characters!');
	}
	else
	{
	document.getElementById(counter).value = 1000 - len.length;
	}
	
}

function PostChange(textarea,counter,maxLength) {
	var len = document.getElementById(textarea).value
	if (maxLength - len.length <= 0){
		document.getElementById(textarea).value = len.substring(0, maxLength);
		alert('You have entered the max characters!');
	}
	else
	{
	document.getElementById(counter).value = maxLength - len.length;
	}
	
}


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


function theRotator(id) {
	//Set the opacity of all images to 0
	$('div#'+id+' ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#'+id+' ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate(\''+id+'\')',3000);
	
}

function rotate(id) {	
	//Get the first image
	var current = ($('div#'+id+' ul li.show')?  $('div#'+id+' ul li.show') : $('div#'+id+' ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#'+id+' ul li:first') :current.next()) : $('div#'+id+' ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
}



function startPlayer(obj){
	$f(obj).show();
	$f(obj).play();
	if(document.all){$f(obj).play();}
}

var tabdropdown={
	disappeardelay: 200, //set delay in miliseconds before menu disappears onmouseout
	disablemenuclick: false, //when user clicks on a menu item with a drop down menu, disable menu item's link?
	enableiframeshim: 0, //1 or 0, for true or false

	//No need to edit beyond here////////////////////////
	dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, previousmenuitem:null,
	currentpageurl: window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, ""), //get current page url (minus hostname, ie: http://www.dynamicdrive.com/)

	getposOffset:function(what, offsettype){
		var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
		var parentEl=what.offsetParent;
			while (parentEl!=null){
				totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
				parentEl=parentEl.offsetParent;
			}
		return totaloffset;
	},

	showhide:function(obj, e, obj2){ //obj refers to drop down menu, obj2 refers to tab menu item mouse is currently over
		if (this.ie || this.firefox)
			this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
		if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
			if (obj2.parentNode.className.indexOf("default")==-1) //if tab isn't a default selected one
				obj2.parentNode.className="selected"  ///"selected"
				obj.visibility="visible"
			}
		else if (e.type=="click")
			obj.visibility="hidden"
	},

	iecompattest:function(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	},

	clearbrowseredge:function(obj, whichedge){
		var edgeoffset=0
		if (whichedge=="rightedge"){
			var windowedge=this.ie && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
			this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
		if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
			edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
		}
		else{
			var topedge=this.ie && !window.opera? this.standardbody.scrollTop : window.pageYOffset
			var windowedge=this.ie && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
			this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
			if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
				edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
				if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
					edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
			}
			this.dropmenuobj.firstlink.style.borderTopWidth=(edgeoffset==0)? 0 : "1px" //Add 1px top border to menu if dropping up
		}
		return edgeoffset
	},

	dropit:function(obj, e, dropmenuID){
		if (this.dropmenuobj!=null){ //hide previous menu
			this.dropmenuobj.style.visibility="hidden" //hide menu
			if (this.previousmenuitem!=null && this.previousmenuitem!=obj){
				if (this.previousmenuitem.parentNode.className.indexOf("default")==-1) //If the tab isn't a default selected one
					this.previousmenuitem.parentNode.className=""
			}
		}
		this.clearhidemenu()
		if (this.ie||this.firefox){
			obj.onmouseout=function(){tabdropdown.delayhidemenu(obj)}
			obj.onclick=function(){return !tabdropdown.disablemenuclick} //disable main menu item link onclick?
			this.dropmenuobj=document.getElementById(dropmenuID)
			this.dropmenuobj.onmouseover=function(){tabdropdown.clearhidemenu()}
			this.dropmenuobj.onmouseout=function(e){tabdropdown.dynamichide(e, obj)}
			this.dropmenuobj.onclick=function(){tabdropdown.delayhidemenu(obj)}
			this.showhide(this.dropmenuobj.style, e, obj)
			this.dropmenuobj.x=this.getposOffset(obj, "left")
			this.dropmenuobj.y=this.getposOffset(obj, "top")
			this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
			this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
			this.previousmenuitem=obj //remember main menu item mouse moved out from (and into current menu item)
			this.positionshim() //call iframe shim function
		}
	},

	contains_firefox:function(a, b) {
		while (b.parentNode)
		if ((b = b.parentNode) == a)
			return true;
		return false;
	},

	dynamichide:function(e, obj2){ //obj2 refers to tab menu item mouse is currently over
		var evtobj=window.event? window.event : e
		if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
			this.delayhidemenu(obj2)
		else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
			this.delayhidemenu(obj2)
	},

	delayhidemenu:function(obj2){
		this.delayhide=setTimeout(function(){tabdropdown.dropmenuobj.style.visibility='hidden'; if (obj2.parentNode.className.indexOf('default')==-1) obj2.parentNode.className=''},this.disappeardelay) //hide menu
	},

	clearhidemenu:function(){
		if (this.delayhide!="undefined")
			clearTimeout(this.delayhide)
	},

	positionshim:function(){ //display iframe shim function
		if (this.enableiframeshim && typeof this.shimobject!="undefined"){
			if (this.dropmenuobj.style.visibility=="visible"){
				this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
				this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
				this.shimobject.style.left=this.dropmenuobj.style.left
				this.shimobject.style.top=this.dropmenuobj.style.top
			}
		this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
		}
	},

	hideshim:function(){
		if (this.enableiframeshim && typeof this.shimobject!="undefined")
			this.shimobject.style.display='none'
	},

isSelected:function(menuurl){
	var menuurl=menuurl.replace("http://"+menuurl.hostname, "").replace(/^\//, "")
	return (tabdropdown.currentpageurl==menuurl)
},

	init:function(menuid, dselected){
		this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
		var menuitems=document.getElementById(menuid).getElementsByTagName("a")
		for (var i=0; i<menuitems.length; i++){
			if (menuitems[i].getAttribute("rel")){
				var relvalue=menuitems[i].getAttribute("rel")
				document.getElementById(relvalue).firstlink=document.getElementById(relvalue).getElementsByTagName("a")[0]
				menuitems[i].onmouseover=function(e){
					var event=typeof e!="undefined"? e : window.event
					tabdropdown.dropit(this, event, this.getAttribute("rel"))
				}
			}
			if (dselected=="auto" && typeof setalready=="undefined" && this.isSelected(menuitems[i].href)){
				menuitems[i].parentNode.className+=" selected default"
				var setalready=true
			}
			else if (parseInt(dselected)==i)
				menuitems[i].parentNode.className+=" selected default"
		}
	}

}


function foo(on,id){
	if(on){
		document.getElementById('main_nav_'+id).style.backgroundColor='#000';
	}else{
		document.getElementById('main_nav_'+id).style.backgroundColor='';
	}
}

function showItem(id,speed){
     $('#'+id).fadeIn(speed ? speed : 400);
}
function hideItem(id,speed){
     $('#'+id).fadeOut(speed ? speed : 400);
}
function showmore(id){
     $('#'+id).toggle(400);
}

function getID(obj){
	var x = obj.id;
	if(!x) return false;
	
	if(x.indexOf('_')>-1){
		return x.substring(0,x.lastIndexOf('_')+1);
	}else{
		return x
	}
}





function setBilling(obj){
	
	var f = Array();
	f["FirstNameBilling"] = "FirstName";	
	f["LastNameBilling"] = "LastName";
	f["Address1Billing"] = "Address1";	
	f["CityBilling"] = "City";
	f["ZipCodeBilling"] = "ZipCode";
	f["StateBilling"] = "State";
	

	var prefix = getID(obj);
	var a , b;
	
	for(var i in f){
		a = document.getElementById(prefix+f[i]);
		b = document.getElementById(prefix+i);
		if(a&&b){
			b.value = a.value;
		}
	}
	
}


function ShowAdInfo() {

if(document.getElementById('ctl00_Main_UserControl_Registration_1_ProfileAdvertisement').checked)

{ document.getElementById('adInfo').style.display='block'; }

if(document.getElementById('ctl00_Main_UserControl_Registration_1_ProfileAdvertisement').checked == false)

{ document.getElementById('adInfo').style.display='none'; }


}


function setFieldError(id,prefix){
	
	// get ref
	var f = document.getElementById(id) ? document.getElementById(id) : document.getElementById(prefix+id);
	if(!f) return false;
	
	//f.style.backgroundColor = 'green';
	///f.style.color = 'white';
	f.focus();	
		
}


function getprefix(){
	var a = document.getElementsByTagName('input');
	for(j=0;j<a.length;j++){
		var i = a[j];
		if(i.id.indexOf('ctl00_')>-1){
			var p = i.id.substring(0,i.id.lastIndexOf('_')+1); 
			return p;
		}
	}
		
}
function slidePhotos(id,dir){
	var limargin = 12; // li margin
	var offsetItem = (488 + 12); // li width + li margin
	var cols = 1; // number of li displayed at 1 time
	var offset = (offsetItem * cols); // li width x cols + li margin x cols
	var max_images = $('#image_total').val();
	var moveIt = dir == 'left' ? '-=' : '+=';

	
	$('#'+id).animate({
			left:  moveIt+''+offset
		},800,function(){
			var currentLeft = $('#'+id).css('left').replace('px','');
			// set the nav
			$('#less-photos').css('display',parseInt(currentLeft) < 0 ? 'block' : 'none');				
			$('#more-photos').css('display',Math.abs(parseInt(currentLeft)) < (offsetItem * ((max_images-1)/cols)) ? 'block' : 'none');
		});
	
	return false;
}

function showPhoto(path,name){
	
	$('#photo-item-inner').html('<img src="'+path+'" alt="'+name+'" />')
	showItem('photo-item');	
	
}



function getShareLinks(){
	
	var url = document.location.href;
	document.writeln('<div id="share-it">');
	document.writeln('<ul>');
	document.writeln('<li class="t">');
	document.writeln('<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>');
	document.writeln('</li>');
	document.writeln('<li class="l">');
	document.writeln('<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-url="'+url+'" data-counter="right"></script>');
	document.writeln('</li>');
	document.writeln('<li class="f">');
	document.writeln('<iframe src="http://www.facebook.com/plugins/like.php?href='+URLEncode(fixURL(url))+'&amp;layout=button_count&amp;show_faces=true&amp;width=150&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>');
	document.writeln('</li>');
	document.writeln('</ul>');
	document.writeln('</div>');
	
}

function writeFBShare(){
	var url = document.location.href;

	document.writeln('<iframe src="http://www.facebook.com/plugins/like.php?href='+URLEncode(fixURL(url))+'&amp;layout=button_count&amp;show_faces=true&amp;width=150&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:21px;" allowTransparency="true"></iframe>');
}
	
function fixURL(url){
	url = url.indexOf('?') > -1 ? url.substring(0,url.indexOf('?')-1) : url;
	return url;
}


function toggleItems(istrue){
	

	// hide/show the id's
	for(j=1;j<arguments.length;j++){
		if(istrue){
			showItem(arguments[j]);
		}else{
			hideItem(arguments[j]);
		}		
	}
}

function contactMember(uid,x){
	if(x){
		ShowPopUp('PopUp_ContactMember.aspx?UID='+uid,true,500,600);
		return true;
	}else{
		document.location.href='/admin/?ref='+document.location.href;	
		return false;
	}
}


function getAddThis(thisType){
	document.writeln('<div class="addthis_toolbox addthis_default_style addthis_16x16_style">');
	document.writeln('<a class="addthis_button_facebook"></a>');
	document.writeln('<a class="addthis_button_twitter"></a>');
	document.writeln('<a class="addthis_button_linkedin"></a>');
	document.writeln('<a class="addthis_button_email"></a>');
	
	
	if(thisType=='event'){
		document.writeln('<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>');		
	}else if(thisType=='gallery'){
		document.writeln('<a class="addthis_button_compact"></a>');		
	}else if(thisType!='small'){
		document.writeln('<a class="addthis_button_compact"></a>');
		document.writeln('<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>');
	}
		
	document.writeln('</div>');
	document.writeln('<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script>');
	document.writeln('<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d88ec56049f8326"></script>');
	

	
}

function getLikeButton(t){
	document.writeln('<div id="facebook-like">');
	document.writeln('<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>');
	document.writeln('<fb:like href="'+document.location.href+'" send="true" width="450" layout="'+(t?t:'standard')+'" show_faces="true" font=""></fb:like>')
	document.writeln('</div>');
}


function setAdSizes(obj){
	
	var p = obj.id.indexOf('AdImagesText') > -1 ? 'TextSize' : 'ImageSize';
	var name = obj.id.replace(/_/gi,'$').replace('$BuyAds$1','_BuyAds_1');

	var opt = document.getElementsByName(name);
	var size = null;
	// got opts?
	if(opt){
		for(j=0;j<opt.length;j++){
			if(opt[j].checked){
				size = opt[j].value;
			}
		}
	}


	// got size
	if(!size) return false;
	
	
	var prefix = document.getElementById('prefix-id')
	prefix = prefix ? prefix.value : 'ctl00_Main_UserControl_BuyAds_1_'
	
	// set size
	document.getElementById(prefix+'ASize').value = size;
	
	// set size
	
	try{
		var i = document.getElementById('ImageSize'+size).value.split(',');
	}catch(e){
		return;
	}
	
	
	if(i.length ==2){
		
		if (p=='TextSize'){
			var html = setTextAd(size,i[0],i[1]);
			document.getElementById('textAdDiv').innerHTML = '<div id="text-ad-holder">'+html+'</div>';
			changeTextAd();
		}else{	
			document.getElementById(prefix+'img_ImagePath').width = i[0];
			document.getElementById(prefix+'img_ImagePath').height = i[1];
			document.getElementById('textAdDiv').innerHTML = '';
		}

		var rp = prefix; ///'ctl00_Main_UserControl_BuyAds_1_';
		document.getElementById(rp+'item_width').value = i[0];
		document.getElementById(rp+'item_height').value = i[1];
		
		document.getElementById('recommend-size').innerHTML = 'recommended size ' + i[0] + ' by '+i[1]+' pixel (width/height)';

	}
}

function killList(name){
	
	var e = document.getElementsByName(name);
	for(j=0;j<e.length;j++){
		e[j].checked=false;	
	}
	document.getElementById('textAdDiv').innerHTML = '';
}


function checkImage(){

	var p = document.getElementById('prefix-id')
	p = p ? p.value : 'ctl00_Main_UserControl_BuyAds_1_'	

	var path1 = document.getElementById(p+'ImagePath');
	var path2 = document.getElementById('ImagePath2');
	var src = document.getElementById(p+'img_ImagePath');

	if(path1.value!=path2.value){
		src.src = path1.value;
		path2.value = path1.value;
		
		if($('#AdTextType').attr('checked')==true){
			changeTextAd();	
		}
		
	}
	
	setTimeout('checkImage()',500);
	
}

function encodeHTML(x){
	var z = x.replace(/</gi,'&lt;');
	z = z.replace(/>/gi,'&gt;');
	return z
}

function changeTextAd(){
	
	var p = document.getElementById('prefix-id')
	p = p ? p.value : 'ctl00_Main_UserControl_BuyAds_1_'	
	
	var size = document.getElementById(p+'ASize').value;
	var rp = p; //'ctl00_Main_UserControl_BuyAds_1_';	
	var width = document.getElementById(rp+'item_height').value;
	var height = document.getElementById(rp+'item_width').value;
	var header = encodeHTML(document.getElementById(rp+'AdHeader').value);
	var subheader = encodeHTML(document.getElementById(rp+'AdSubHeader').value);
	var content = encodeHTML(document.getElementById(rp+'AdText').value);
	var imagepath = document.getElementById(rp+'img_ImagePath').src;
	
	document.getElementById('textAdDiv').innerHTML =	setTextAd(size,width,height,header,subheader,content,imagepath);
	

}

function setTextAd(size,width,height,header,subheader,content,imagepath){
	var retVal = '';
	
	var p = document.getElementById('prefix-id')
	p = p ? p.value : 'ctl00_Main_UserControl_BuyAds_1_';	
	

	
	if(size=="2"){

		// show the subheader
		$('#AdSubHeader').css('display','block');
		
		document.getElementById(p+'img_ImagePath').width = 148;
		document.getElementById(p+'img_ImagePath').height = 148;


		retVal += '<div class="text-ad-1">';
		retVal += '<h2>'+ (header ? header : 'Enter Header') + '</h2>';
		retVal += '<h3>'+ (subheader ? subheader : 'Sub Header') + '</h3>';
		retVal += '	<div class="text-ad-1-body">';
		retVal += '		<div class="text-ad-1-body-left">';
		retVal += '			<img src="' + (imagepath ? imagepath : '/pub/defaultImage/noimage.gif') + '" alt="" width="148" height="148" />';
		retVal += '		</div>';
		retVal += '		<div class="text-ad-1-body-right">';
		retVal += '			<p>' + (content ? content.replace(/\n/gi,'<br />') : 'enter content') + '</p>';
		retVal += '		</div>';
		retVal += '		<div class="clear"></div>';
		retVal += '	</div>';
		retVal += '</div>';
		
	}else if(size=="3"){
		
		// hide the sub header field and clear it
		$('#AdSubHeader').css('display','none');
		
		document.getElementById(p+'img_ImagePath').width = 170;
		document.getElementById(p+'img_ImagePath').height = 115;
		
		retVal += '<div class="text-ad-2">';
		retVal += '	<h2>' + (header ? header : 'Enter Header') + '</h2>';
		retVal += '	<div class="text-ad-2-body">';
		retVal += '		<img src="'+ (imagepath ? imagepath : '/pub/defaultImage/noimage.gif') + '" alt="" width="170" height="115" />';
		retVal += '	</div>';
		retVal += '	<div class="text-ad-2-text">';
		retVal += ' <p>' + (content ? content.replace(/\n/gi,'<br />') : 'enter content') + '</p>';
		retVal += '	</div>';
		retVal += '</div>';
	}
	
	return retVal;
}


function writeEventLink(g,nonPayPal){
	
	if(nonPayPal){
		g = g.substring(0,4) == 'http' ? g : 'http://'+g;
		document.writeln('<a href="'+g+'" target="_blank" class="event-g">Register for Event</a>')		
	}else{
		document.writeln('<a href="/EventRegistration.htm?s='+g+'&url='+document.location.href+'"  class="event-g">Register for Event</a>')
	}
}

function setAttendee(obj){
	var p = getprefix(obj.id);
	var fname = document.getElementById(p+'bFName');
	var lname = document.getElementById(p+'bLName');
	var a = document.getElementById(p+'Attendees');
	
	if(fname.value==''||lname.value==''){
		return false;
	}else if(a.value==''){
		a.value = fname.value + ' ' + lname.value;
	}
}

function showAdWindow(link,x,text){
	

	var y = "";
	var z = new Array(x,b,c,'C',e,f,g,h);
	var y = "{" + z.join("|") + "}{}";
	go('/admin/code/javascript/ads/?a='+escape(y));
	
	if(link.indexOf('http://')==-1 && link.indexOf('https://')==-1){
		return false;
	}
	
	if(text){	
		var w = window.open(link,'ad1','width=1024px,height=1000,scrollbars=yes,menubar=yes,location=yes,resizable=yes');
		if(w){
			w.focus();
		}else{
			alert('PopUp Blocker');	
		}
	}

	return false;
}


function swapImg(img,src){
	img.src = src;
}

function showEvents(increment){
	var size = 130;
	var current = parseInt(document.getElementById('start').value);
	var count = parseInt(document.getElementById('count').value);
	// set next move
	current = parseInt(current) + increment;
	var topWhat = parseInt($('#eventsPlaceHolder ul').css('top').replace('px',''));	

	topWhat = topWhat - parseInt(size * increment);

	$('#eventsPlaceHolder ul').animate({
		top :  topWhat + 'px'
	},800,function(){
		// show upArrow
		$('#upEvents').css('visibility',current > 0 ? 'visible' : 'hidden');
		// show down arrow
		$('#downEvents').css('visibility',current < (count-1) ? 'visible' : 'hidden');	
	});
	
	document.getElementById('start').value = current;

}


function setAdWxH(){
	
	var p = document.getElementById('prefix-id')	
	p = p ? p.value : 'ctl00_Main_UserControl_BuyAds_1_';
	
	var i = document.getElementById(p+'img_ImagePath');
	if(i){
		var width = document.getElementById(p+'item_width') ? document.getElementById(p+'item_width').value  : 185;
		var height = document.getElementById(p+'item_height') ? document.getElementById(p+'item_height').value : 200;

		$('#'+i.id).attr('width',width);
		$('#'+i.id).attr('height',height);
	}
}	

function adplacement(sel){

	var elms = document.getElementsByName('AdPageAndSize');
	var isDisabled = sel.value == '0';
	var unChecked = isDisabled ? true : false;
	var thisName = '';

	for(j=0;j<elms.length;j++){
		thisName = elms[j].id.toLowerCase();
		if(thisName.indexOf('13_')>-1 || elms[j].id.indexOf('9_') > -1 || elms[j].id.indexOf('10_') > -1 || elms[j].id.indexOf('11_') > -1 || elms[j].id.indexOf('12_') > -1 ) {
			elms[j].disabled = isDisabled;
			elms[j].checked = unChecked ? false : elms[j].checked;
		}		
	}
	// last one local myfemcity
	$('#5_LocalFemCity').attr('checked',unChecked ? false : $('#5_LocalFemCity').attr('checked'));

}



				
function hideButton(obj){
	obj.style.visibility='hidden';
}


function resizeSearchResults(minWidth,minHeight,maxWidth,maxHeight,once){

	$(document).ready(function(){
		$('img.profile-image').each(function(index){
			src = $(this).attr('src');
			if(src.indexOf('IMAGE-TO-COME')==-1){
				if($(this).height()<minHeight){
					newW = parseInt(($(this).width() * minHeight) / $(this).height());
//		  		    $(this).removeAttr('width')
//					$(this).removeAttr('height');	
//					$(this).removeAttr('src');
//					$(this).css('width','');
//					$(this).css('height','');
//					$(this).css('width',newW+'px');
//					$(this).css('height',minHeight+'px');
					$(this).width(newW);
					$(this).height(minHeight);
//					$(this).attr('src',src);
					if(newW>maxWidth){
						moveLeft = parseFloat((newW - maxWidth)/2);
						$(this).css('margin-left',(-1 * moveLeft) + 'px');
					}
					
				}else if($(this).height()>(minHeight*1.5)){
					newH = parseFloat(($(this).height() - minHeight)/4);
					$(this).css('margin-top',(-1 * newH)+'px');		
				}else if(once && $(this).width() > (maxWidth * 1.5)){		
					$(this).width(maxWidth);
					$(this).height(maxHeight);
					$(this).css('margin-left','');
				}else{
					$(this).attr('title',$(this).width() + ' = ' + $(this).height());	
				}
			}
		});
		
		if(!once){
			setTimeout("resizeSearchResults("+minWidth+","+minHeight+","+maxWidth+","+maxHeight+",true)",1000);
		}
		
	});
}




function showFacebook(u){
	var ref = URLEncode(document.location.href);
	document.location.href='/Facebook/?ref='+ref+'&s='+u;
	return false;
}





function scrollVertical(container,maxheight,nextid,previd){

		container = container.substring(1,1) == '#' ? container : '#'+container;
		nextid = nextid.substring(1,1) == '#' ? nextid : '#'+nextid;
		previd = previd.substring(1,1) === '#' ? previd : '#'+previd;

		
		var commentListPos = 0;
		var commentHeight = $(container).height();
		if (commentHeight <= maxheight) $(nextid).addClass("disabled") ;
		$(nextid).click(function() {
			if (-commentListPos <= commentHeight-maxheight){
				  $(container).animate({
					top: '-='+ maxheight
				  }, 1000, function() {
					commentListPos -= maxheight;
				  });
				  $(previd).removeClass("disabled");
			}


			if (-commentListPos >= commentHeight-(maxheight * 2))	 {
				$(nextid).addClass("disabled") ;
			} else  $(nextid).removeClass("disabled") ;
			return false;
		});
		
		$(previd).click(function() {
			if (commentListPos < 0){
				  $(container).animate({
					top: '+='+maxheight
				  }, 1000, function() {
					commentListPos += maxheight;
				  });
				  $(nextid).removeClass("disabled");
		  }
			if (commentListPos >= 0)	 {
				$(previd).addClass("disabled") ;
			} else  $(previd).removeClass("disabled") ;
			return false;
		});

	
}
