function GoToHome() {
	//if (window.opener) {
	//	window.opener.location='../Member/home.aspx';
	//	self.close();
	//	window.opener.focus();
	//} else {
		document.location='../Member/home.aspx';
	//}
}

var linkWin;
function OpenLinkWin(url) {
	if((!linkWin) || (linkWin.closed == true)) {
		linkWin = window.open(url);
	} else {	
		linkWin.location = url;
		linkWin.focus();	
	}
}

// member/profile/uc_adult_update.ascx
//should be used in new look if pos
function OpenHelp(pageNm, section, appPath) {
	var url = appPath+ "/help/member/" + pageNm;
	if (section != "") {		
		url = appPath+ "/help/member/" + pageNm + "#" + section;
	}
	window.open(url, 'help','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=500'); 
	
	return false;
}

// mainMenu.ascx
var chatWin;
function OpenChat(url) {	
	if (chatWin && (! chatWin.closed)) {
		chatWin.focus();
	} else {
		chatWin = window.open(url,'chat','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=530'); 	
	}
}

// used by help controls all in /help/
function PopUpEnquiry() {
	var width = 550;
	var height = 300;
	var win = window.open('../../../help/enquiry/MakeEnquiryPopup.aspx?closewin=true&category=0','EnquiryForm','menubar=no,toolbar=no,status=no,width='+width+',height='+height+',resizable=yes,scrollbars=yes');
	win.focus();
}

function PopUpCancel() {
	var width = 550;
	var height = 400;
	var win = window.open('CancelLovers2Rebill.aspx?closewin=true&category=0','CancelForm','menubar=no,toolbar=no,status=no,width='+width+',height='+height+',resizable=yes,scrollbars=yes');
	win.focus();
}

//uc_galleryexternal
function mediaOpen(appPath, mediaId, passportId, showDeleted) {
	
	if (showDeleted == null)
		showDeleted = 0;
		
	if((!mediaWin) || (mediaWin.closed == true)) {
		var mediaWin=window.open(appPath + "/member/media/display/MediaItem.aspx?selectedMediaId=" + mediaId + "&selectedPId=" + passportId + "&showDeleted=" + showDeleted,"media","toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=490");
		mediaWin.focus();
	} else {
		mediaWin.location.href = url;
		mediaWin.focus();
	}
}

//uc_galleryexternal
function mediaOpenExternal(appPath, mediaId, passportId) {
	if((!OpenWindow) || (OpenWindow.closed == true)) {
		var OpenWindow=window.open(appPath + "/member/media/display/MediaItemExt.aspx?selectedMediaId=" + mediaId + "&selectedPId=" + passportId,"media","toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=490");
		OpenWindow.focus();
	} else {
		OpenWindow.location.href = url;
		OpenWindow.focus();
	}
}

//member\mail\MemberMailBox.ascx			originally this function was called profileOpen, but was 
//											renamed to avoid a name collision with the function above
function profileOpenMailBox(id,memberType) {
    if((!OpenWindow) || (OpenWindow.closed == true)) {
        var OpenWindow=window.open("../webmaster/ViewProfile.aspx?id=" + id + "&memberType=" + memberType,"profile","toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=630,height=490");
        OpenWindow.focus();
    } else {
        OpenWindow.location.href = url;
        OpenWindow.focus();
    }
}

var openWinHndl;
function OpenWin(url, name, features) {
	if((!openWinHndl) || (openWinHndl.closed == true)) {
		openWinHndl = window.open(url, name, features);
	} else {	
		openWinHndl.location = url;
		openWinHndl.focus();	
	}
}

var commonFeatures = "toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=680,height=530";
function profileOpen(id,appPath) {
	var url = appPath + "/Member/Profile/ViewProfile.aspx?id=" + id;
	OpenWin(url, "profile", commonFeatures);
}

// member/profile/uc_adult_update.ascx
var winCCbill;
function OpenCancelCCBill() {
	var url = 'https://support.ccbill.com/?client_accnum=927070&client_subacc=0000';
	OpenWin(url, "Cancel", commonFeatures);
}	

//member\publish\Blogs.ascx
function messageOpen(appPath, id, passId, fileName, returnPage) {
	var url = appPath + '/member/blog/ViewComments.aspx?id=' + id + '&parentId=' + passId + '&fileName=' + fileName + '&returnPage=' + returnPage;
	OpenWin(url, "Calendar", commonFeatures);
}
 
//member\webmaster\uc_full_header.ascx
function Logout(appPath) {
	if (top.location != self.location) {
		top.location.href = appPath + '/login.aspx?logout=true';
	} else {
		window.location.href = appPath + '/login.aspx?logout=true';
	} 
}


//member\webmaster\SiteNews.ascx
function siteOpen(appPath, id){
    if ((!OpenWindow) || (OpenWindow.closed == true)) {
        var OpenWindow = window.open(appPath + "/member/webmaster/SiteNewsItem.aspx?Id=" + id,"SiteNews","toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=630,height=490");
        OpenWindow.focus();
    } else {
        OpenWindow.location.href = url;
        OpenWindow.focus();
    }
}
 
//member\mail\uc_sendmessage.ascx
function insertEmoticon(strEmoticon, clientID){
	var emotTag = "("+strEmoticon+")";
	if(clientID == ''){
		insertAtCaret(document.getElementById('message'), emotTag);
		document.getElementById('message').focus();
		storeCaret(document.getElementById('message'))
	}else{
		insertAtCaret(document.getElementById(clientID+'_message'), emotTag);
		document.getElementById(clientID+'_message').focus();
		storeCaret(document.getElementById(clientID+'_message'))
	}
	
}

//member\mail\uc_sendmessage.ascx
//store cursor position of text box
function storeCaret (textArea){
	if(document.selection){
		if (textArea.createTextRange)
			textArea.caretPos = document.selection.createRange().duplicate();
	}
}

//member\mail\uc_sendmessage.ascx
//insert text in text area at cursor position
function insertAtCaret (textArea, text){
	if (textArea.createTextRange && textArea.caretPos){
		var caretPos = textArea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	} else {
		textArea.value += text;
	}
}    

//member\lookingFor\uc_update.ascx
function criteriaOpen(mtype,mtypetext) {
	var OpenWindow = 
		window.open("options/RefineCriteria.aspx?memberType=" + mtype + "&memberTypeText=" + mtypetext ,"ah_criteria","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=350");
	OpenWindow.focus();
}

//member/webmaster/PopupMessage.ascx
function GetDate(CtrlName, mainId) {
        if ((!OpenWindow) || (OpenWindow.closed == true)) {
            var OpenWindow = window.open('../publish/Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + mainId + ":" + CtrlName, "Calendar", "width=400,height=400,top=400,left=400,toolbars=yes,scrollbars=yes,status=yes,resizable=yes");
            OpenWindow.focus();
        } else {
            OpenWindow.location.href = url;
            OpenWindow.focus();
        }
}

//tools/admin/webmaster/checkWebmasters.aspx
function urlOpen(url){	
	urlOpen = new String(url);
	if (urlOpen.substr(0, 7) !=  "http://"){
		window.open("http://" + url,"Site");		
	} else {
		window.open(url,"Site");		
	}
}

//tools/admin/webmaster/signUpWebmaster.aspx
function openPreview(height) {
	colour1 = document.forms[0].color1.value;
	colour2 = document.forms[0].color2.value;
	logoFile = document.forms[0].fileNameSpecify.value;
	if (colour1.indexOf("#") > -1) {
		colour1 = colour1.substring(1);
	}
	if (colour2.indexOf("#") > -1) {
		colour2 = colour2.substring(1);
	}
	window.open("../../../webmaster/SignUp/preview.aspx?color1=" + colour1 + "&color2=" + colour2 + "&aWebmaster=0&logoFile=" + logoFile,"Preview","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=" + height);
}

//tools/admin/webmaster/signUpWebmaster.aspx
function openUploadFile() {
	window.open("../../../webmaster/SignUp/UploadWebLogo.aspx?FormName=frmMain&CtrlName=fileNameSpecify","Preview","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=180");
}

//tools/admin/webmaster/signUpWebmaster.aspx
function openDrawLogo() {
	colour1 = document.forms[0].color1.value;
	colour2 = document.forms[0].color2.value;
	if (colour1.indexOf("#") > -1) {
		colour1 = colour1.substring(1);
	}
	if (colour2.indexOf("#") > -1) {
		colour2 = colour2.substring(1);
	}

    if (colour2.length > 0) {
		window.open("../../../webmaster/SignUp/DrawWebLogo.aspx?FormName=frmMain&CtrlName=fileNameSpecify&color1=" + colour1 + "&color2=" + colour2,"Preview","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=270");
	} else {
	    alert("Enter a second Colour");
	}
}

// tools/admin/webmaster/WebmasterConfig.aspx
function urlOpener(url){
    window.open(url,"Site");
}

// tools/admin/webmaster/WebmasterConfig.aspx
function openPreviewer(webmasterId, height) {
	colour1 = document.forms[0].color1.value;
	colour2 = document.forms[0].color2.value;
	logoFile = document.forms[0].fileNameSpecify.value;
	if (colour1.indexOf("#") > -1) {
		colour1 = colour1.substring(1);
	}
	if (colour2.indexOf("#") > -1) {
		colour2 = colour2.substring(1);
	}
	window.open("../../../webmaster/SignUp/preview.aspx?color1=" + colour1 + "&color2=" + colour2 + "&aWebmaster=1&logoFile=" + logoFile + "&webmasterId=" + webmasterId,"Preview","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=" + height);
}

// tools/admin/webmaster/WebmasterConfig.aspx
function openUploadFilePage(webmasterId) {
	window.open("../../../webmaster/SignUp/UploadWebLogo.aspx?FormName=frmMain&CtrlName=fileNameSpecify","Preview","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=200");
}

// tools/admin/webmaster/WebmasterConfig.aspx
function openDrawLogoFile(webmasterId) {
	colour1 = document.forms[0].color1.value;
	colour2 = document.forms[0].color2.value;
	if (colour1.indexOf("#") > -1) {
		colour1 = colour1.substring(1);
	}
	if (colour2.indexOf("#") > -1) {
		colour2 = colour2.substring(1);
	}

    if (colour1.length > 0){
		window.open("../../../webmaster/SignUp/DrawWebLogo.aspx?FormName=frmMain&CtrlName=fileNameSpecify&color1=" + colour1 + "&color2=" + colour2,"Preview","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=300");
	} else {
		alert("Enter a second colour");
	}
}

function ShowColor(inputColor, displayColorLabel) {
	if (inputColor.length < 6 | inputColor.length > 7) {
		alert('Colour must be a 7 digit Hexadecimal number, ie. #000000');
	} else if (inputColor.indexOf("#") > -1 & inputColor.length <= 6) {			
		alert('Colour must be a 7 digit Hexadecimal number, ie. #000000');
	} else if (inputColor.indexOf("#") > -1 & inputColor.length == 7){
		document.getElementById(displayColorLabel).style.backgroundColor = inputColor;						
//		displayColorTextBox.style.backgroundColor = inputColor;						
	} else if (inputColor.indexOf("#") == -1 & inputColor.length == 7){
		alert('Colour must be a 7 digit Hexadecimal number, ie. #000000');
	} else if (inputColor.indexOf("#") == -1 & inputColor.length == 6){
		document.getElementById(displayColorLabel).style.backgroundColor = "#" + inputColor;
		//displayColorTextBox.style.backgroundColor = "#" + inputColor;
	} else {
	}
}
//media
function confirm_delete(){		
		if (confirm("Are you sure you want to delete this media item?") == true){									
			return true;
		} else {
			return false;
		}
	}

function confirmChange(){
var accept = confirm("Your 'Am I hot?' or not picture rating will be lost if you change your primary picture. Do you want to continue?");
if (accept)
	return frmMain.submit() ;
else
	return false ;
}
//used in signup1 to check for javascript
function hideJSMessage(){
			var message = document.getElementById('noJS');
			if(message){
				noJS.style.display='none';
			}
		}

function setCookie(name, value, expire) {
	document.cookie = name + "=" + escape(value)
	+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}


var dialerCookie = 'theadulthubDialer';

function ExpireDialerCookie () {

	var today = new Date();
	var expireMill = today.getTime() - (70*365*12*60*60*1000); 
	var expires = new Date(expireMill);		

	SetCookie( dialerCookie, dialerCookie, expires );
}


function SetDialerCookie () {

	var today = new Date();
	var expMinutes = 15;
	var expireMill = today.getTime() + (expMinutes*60*1000);  //minutes = (60 seconds * 1000 milliseconds)
	var expires = new Date(expireMill);

	SetCookie( dialerCookie, dialerCookie, expires );
	//alert( 'setting dialer cookie' );
}

function SetCookie (name, value) {

	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

// for popup window with indicator of new mail received
function loadMailPopup(path) {
  var req = window.XMLHttpRequest? 
    new XMLHttpRequest() : 
    new ActiveXObject("Microsoft.XMLHTTP");
  req.onreadystatechange = function() {
    if (req.readyState == 4) 
    {
      //alert('Loaded:\n'+req.responseText);
      //document.getElementById("newMailDiv").innerHTML=req.responseText;
      try
      {
		eval(req.responseText);
	  }
	  catch (ex)
	  {
	  }
    }
  }
  req.open("GET",path + "/Refresh.aspx" , true);
  req.send(null);
}

