function CheckForDefaultValue(elElement) {
    if (elElement) {
        var strDefault = elElement.getAttribute('default');
        if ((strDefault == null) || (strDefault == undefined) || (strDefault == '')) {
            strDefault = elElement.getAttribute('value');
            elElement.setAttribute('default', strDefault);
        }
        if (elElement.value == strDefault) elElement.value = '';
    }
}


function PopupMedium(strUrl, strWindowName) {
	strWindowName = (strWindowName || '');
	var x = window.open(strUrl, strWindowName, 'location=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=no,height=500px,width=600px,' + GetCenteredWindow(500, 600));
}

function PopupSmall(strUrl, strWindowName) {
	strWindowName = (strWindowName || '');
	var x = window.open(strUrl, strWindowName, 'location=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=no,height=230px,width=300px,' + GetCenteredWindow(230, 300));
}


function GetXMLHttp() {
    var objHttp;
	if(window.XMLHttpRequest) {
		try {
			objHttp = new XMLHttpRequest();
		} catch(e) {}
	// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			objHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				objHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {}
		}
	}
	return objHttp;
}

function GetTextFromURL(strURL) {
	var bolLoaded = false, strResult = '', objHttp;
	objHttp = GetXMLHttp();
	// branch for native XMLHttpRequest object
	if (objHttp) {
		objHttp.open("GET", strURL, false);
		objHttp.send(null);
		strResult = objHttp.responseText;
	} else {
		alert('error');
	}
	return strResult;
}
function GetXMLFromURL(strURL) {
	var objResult, objHttp;
	objHttp = GetXMLHttp();
	// branch for native XMLHttpRequest object
	if (objHttp) {
		objHttp.open("GET", strURL, false);
		objHttp.send(null);
		objResult = objHttp.responseXML;
	} else {
		alert('error');
	}
	return objResult;
}

function Track(iEvent_id, strEvent_data, strUser_id) {
    if (iEvent_id) {
        strEvent_data = strEvent_data || '';
        strUser_id = strUser_id || window.current_user_id || '0';
        GetTextFromURL('/Utilities/Track/?User_id=' + strUser_id + '&id=' + iEvent_id + '&data=' + escape(strEvent_data));
    }
}

function BecomeFan(iCeleb_id, iUserProfile_id, bolDelete, strElementID, bolShowMessage) {
	var bolResult = false;
	
    if ((iUserProfile_id == null) || (iUserProfile_id == undefined)) iUserProfile_id = window.current_user_profile_id;
	iUserProfile_id = (iUserProfile_id || 0);
	if (iUserProfile_id > 0) {
	    if (bolDelete == undefined) bolDelete = false;
	    if (bolShowMessage) MsgBox('Please wait...');
	    var strURL = '/client/cast/XMLGeneration.asp?UserProfile_id=' + iUserProfile_id + '&session_id=' + (window.current_session_id || '') + '&id=' + iCeleb_id + '&command=';
	    if (bolDelete) {
		    strURL += 'DeleteFan';
	    } else {
		    strURL += 'BecomeFan';
	    }
	    var strResult = GetTextFromURL(strURL);
	    if ((strResult == 'OK') || (strResult == 'OK_OLD')) {
		    if (strElementID != undefined) {
			    var elElement = document.getElementById(strElementID);
			    if (elElement != undefined) elElement.style.display = 'none';
		    }
		    if (bolShowMessage) {
		        if (bolDelete) {
	                MsgBox('You have been removed as a fan.');
		        } else {
		            if (strResult == 'OK') {
		                MsgBox('You have been added as a fan.');
		            } else if (strResult == 'OK_OLD') {
		                MsgBox('You are already a fan.');
		            }
		        }
		    }
		    bolResult = true;
	    } else if (bolShowMessage) {
            MsgBox('Sorry, there was an error.');
	    }
	} else {
	    NotLoggedInMsg(910001);
	}
	//return bolResult;
}

function AddToFavorites(iUserProfile_id, strURL, strTitle, strThumbnail, strType, strExtraData) {
    if ((iUserProfile_id == null) || (iUserProfile_id == undefined)) iUserProfile_id = window.current_user_profile_id;
	if ((iUserProfile_id != undefined) && (parseInt(iUserProfile_id) > 0)) {
		var strParams = '';
		if (strURL == undefined) strURL = location.href;
		if (strThumbnail == undefined) strThumbnail = GetMetaContents('instantcast.thumbnail');
		if (strType == undefined) strType = GetMetaContents('instantcast.type');
		if (strExtraData == undefined) strExtraData = GetMetaContents('instantcast.extradata');
		if (strTitle == undefined) strTitle = GetMetaContents('instantcast.title');
		if ((strTitle == '') && (strType.toLowerCase() != 'photo')) strTitle = document.title;
		
		var strAPIResult = CallAPI([["method", "AddFavorite"], ["UserProfile_id", parseInt(iUserProfile_id)], ["theurl", strURL], ["title", strTitle], ["thumbnail", strThumbnail], ["type", strType], ["extradata", strExtraData]]);
		if (strAPIResult == 'OK') {
			//PopupSmall('/client/cast/help_favorites.htm');
			Track(13100, strURL, (window.current_user_id || iUserProfile_id));
			MsgBox('This has been added to your favorites');
		} else {
			MsgBox('Sorry, there was an error');
		}
	} else {
		NotLoggedInMsg(910002);
	}
}

function SendFanmail(iRecipient_id, iSender_id) {
    iRecipient_id = (iRecipient_id || 0);
    if ((iSender_id == null) || (iSender_id == undefined)) iSender_id = window.current_user_profile_id;
	if ((iSender_id != undefined) && (parseInt(iSender_id) > 0) && (parseInt(iRecipient_id) > 0)) {
		Popup('/client/cast/main.asp?command=SendCommentForm&session_id=' + (window.current_session_id || '') + '&UserProfile_id=' + iRecipient_id + '&header=NO', 600, 500);
	} else {
		NotLoggedInMsg(910003);
	}
}

function CastVote(iRecipient_id, iContest_id) {
    iRecipient_id = (iRecipient_id || 0);
    iContest_id = (iContest_id || 0);
	Popup('/Utilities/Vote/?UserProfile_id=' + iRecipient_id + '&Contest_id=' + iContest_id, 350, 600, 'InstantCastVote');
}

function Nominate(iRecipient_id, iContest_id) {
    iRecipient_id = (iRecipient_id || 0);
    iContest_id = (iContest_id || 0);
	Popup('/Utilities/Vote/?nominate=true&UserProfile_id=' + iRecipient_id + '&Contest_id=' + iContest_id, 350, 600, 'InstantCastVote');
}

function GetMetaContents(strName) {
	var strResult = '';
	var m = document.getElementsByTagName('meta');
	for (var i in m) {
		var strCurName = m[i].name;
		if (strCurName == undefined) strCurName = '';
		if (strCurName.toLowerCase() == strName.toLowerCase()) {
			strResult = m[i].content;
			break;
		}
	}
	return strResult;
}

function MsgBox(strText, iHeight, iWidth) {
    if (!iHeight) iHeight = 150;
    if (!iWidth) iWidth = 200;
	var x = window.open('', 'MsgBox', 'location=no,directories=no,menubar=no,resizable=yes,scrollbars=no,status=no,titlebar=yes,toolbar=no,height=' + iHeight + 'px,width=' + iWidth + 'px,' + GetCenteredWindow(iHeight, iWidth));
	x.focus();
	var objDoc = x.document;
    var elTemp = objDoc.getElementById('MainText');
	if (elTemp) {
	    elTemp.innerHTML = strText;
	} else {
    	objDoc.write('<html><head><meta http-equiv="pragma" content="no-cache"\/><meta http-equiv="cache-control" content="no-cache"\/><meta http-equiv="expires" content="-1"\/><link rel="stylesheet" href="\/themes\/default\/css\/global.css" type="text\/css"><\/head><body id="body" class="Profile-Tab-Main" style="border:0px"><table cellpadding="0" cellspacing="0" height="' + (iHeight - 10) + 'px" width="100%"><tr style="height:' + (iHeight - 35) + 'px;"><td align="center" valign="middle" class="Highlight" id="MainText">' + strText + '</td></tr><tr style="height:25px;"><td class="FinePrintText" align="center"><a href="javascript:window.close();">Close Window</a></td></tr></table><span style="display:none;">' + Date().valueOf() + '<\/span><\/body><\/html>');
    }
}

function NotLoggedInMsg(iKeyword_id) {
    iKeyword_id = (iKeyword_id || '');
    MsgBox('You must be logged in to use this feature.<br /><br /><a href="javascript:window.opener.location.href=\'/Membership/Login.aspx\'; window.close();">Login Here</a><br /><a href="javascript:window.opener.location.href=\'/Membership/Roadblock.aspx?keyword_id=' + iKeyword_id + '\'; window.close();">Signup Now</a>');
}

function Popup(strUrl, iHeight, iWidth, strWindowName, bolStaticWindow) {
	if (iHeight == undefined) iHeight = .9 * window.screen.height;
	if (iWidth == undefined) iWidth = .9 * window.screen.width;
	strWindowName = (strWindowName || '');
	if (bolStaticWindow) {
	    var x = window.open(strUrl, strWindowName, 'location=no,directories=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,dialog=yes,height=' + iHeight + 'px,width=' + iWidth + 'px,' + GetCenteredWindow(iHeight, iWidth));
	} else {
	    var x = window.open(strUrl, strWindowName, 'location=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=no,height=' + iHeight + 'px,width=' + iWidth + 'px,' + GetCenteredWindow(iHeight, iWidth));
	}
}

function GetCenteredWindow(iHeight, iWidth) {
    if (!iHeight) iHeight = 0;
    if (!iWidth) iWidth = 0;
    var x = 0, y = 0;
    if (screen) {
        y = (screen.height / 2) - (iHeight / 2);
        x = (screen.width / 2) - (iWidth / 2);
    }
    return 'screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y;
}

function CallAPI(arrParams) {
    var strKey = GetMetaContents('instantcast.__k');
    var strSig = '', strParams = '';
    arrParams.sort(function(a, b) {
        var s1 = a[0].toLowerCase(), s2 = b[0].toLowerCase();
        if (s1 > s2) return 1;
        if (s1 < s2) return -1;
        return 0;
    });
    for (i = 0; i < arrParams.length; i++) {
        if (i > 0) strParams += '&';
        strParams += arrParams[i][0] + '=' + encodeURIComponent(arrParams[i][1]);
        strSig += arrParams[i][0].toLowerCase() + arrParams[i][1];
    }
    strSig = MD5(strKey + strSig);
    if (strParams == '') {
        strParams = '?';
    } else {
        strParams = '?' + strParams + '&';
    }
    strParams += 'sig=' + encodeURIComponent(strSig);
    return GetTextFromURL('/api/' + strParams);
}




/* MD5 Message-Digest Algorithm - JavaScript
' MODIFICATION HISTORY:
' 1.0    16-Feb-2001 - Phil Fresle (sales@frez.co.uk) - Initial Version (VB/ASP code)
' 1.0    21-Feb-2001 - Enrico Mosanghini (erik504@yahoo.com) - JavaScript porting
*/
function MD5(sMessage) {
 function RotateLeft(lValue, iShiftBits) { return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits)); }
 function AddUnsigned(lX,lY) {
	var lX4,lY4,lX8,lY8,lResult;
	lX8 = (lX & 0x80000000);
	lY8 = (lY & 0x80000000);
	lX4 = (lX & 0x40000000);
	lY4 = (lY & 0x40000000);
	lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
	if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
	if (lX4 | lY4) {
		if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
		else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
	} else return (lResult ^ lX8 ^ lY8);
 }
 function F(x,y,z) { return (x & y) | ((~x) & z); }
 function G(x,y,z) { return (x & z) | (y & (~z)); }
 function H(x,y,z) { return (x ^ y ^ z); }
 function I(x,y,z) { return (y ^ (x | (~z))); }
 function FF(a,b,c,d,x,s,ac) {
	a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
	return AddUnsigned(RotateLeft(a, s), b);
 }
 function GG(a,b,c,d,x,s,ac) {
	a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
	return AddUnsigned(RotateLeft(a, s), b);
 }
 function HH(a,b,c,d,x,s,ac) {
	a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
	return AddUnsigned(RotateLeft(a, s), b);
 }
 function II(a,b,c,d,x,s,ac) {
	a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
	return AddUnsigned(RotateLeft(a, s), b);
 }
 function ConvertToWordArray(sMessage) {
	var lWordCount;
	var lMessageLength = sMessage.length;
	var lNumberOfWords_temp1=lMessageLength + 8;
	var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
	var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
	var lWordArray=Array(lNumberOfWords-1);
	var lBytePosition = 0;
	var lByteCount = 0;
	while ( lByteCount < lMessageLength ) {
		lWordCount = (lByteCount-(lByteCount % 4))/4;
		lBytePosition = (lByteCount % 4)*8;
		lWordArray[lWordCount] = (lWordArray[lWordCount] | (sMessage.charCodeAt(lByteCount)<<lBytePosition));
		lByteCount++;
	}
	lWordCount = (lByteCount-(lByteCount % 4))/4;
	lBytePosition = (lByteCount % 4)*8;
	lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
	lWordArray[lNumberOfWords-2] = lMessageLength<<3;
	lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
	return lWordArray;
 }
 function WordToHex(lValue) {
	var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
	for (lCount = 0;lCount<=3;lCount++) {
		lByte = (lValue>>>(lCount*8)) & 255;
		WordToHexValue_temp = "0" + lByte.toString(16);
		WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
	}
	return WordToHexValue;
 }
	var x=Array();
	var k,AA,BB,CC,DD,a,b,c,d
	var S11=7, S12=12, S13=17, S14=22;
	var S21=5, S22=9 , S23=14, S24=20;
	var S31=4, S32=11, S33=16, S34=23;
	var S41=6, S42=10, S43=15, S44=21;
	// Steps 1 and 2.  Append padding bits and length and convert to words
	x = ConvertToWordArray(sMessage);
	// Step 3.  Initialise
	a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
	// Step 4.  Process the message in 16-word blocks
	for (k=0;k<x.length;k+=16) {
		AA=a; BB=b; CC=c; DD=d;
		a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
		d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
		c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
		b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
		a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
		d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
		c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
		b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
		a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
		d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
		c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
		b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
		a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
		d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
		c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
		b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
		a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
		d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
		c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
		b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
		a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
		d=GG(d,a,b,c,x[k+10],S22,0x2441453);
		c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
		b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
		a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
		d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
		c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
		b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
		a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
		d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
		c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
		b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
		a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
		d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
		c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
		b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
		a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
		d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
		c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
		b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
		a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
		d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
		c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
		b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
		a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
		d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
		c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
		b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
		a=II(a,b,c,d,x[k+0], S41,0xF4292244);
		d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
		c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
		b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
		a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
		d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
		c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
		b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
		a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
		d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
		c=II(c,d,a,b,x[k+6], S43,0xA3014314);
		b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
		a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
		d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
		c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
		b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
		a=AddUnsigned(a,AA); b=AddUnsigned(b,BB); c=AddUnsigned(c,CC); d=AddUnsigned(d,DD);
	}
	// Step 5.  Output the 128 bit digest
	var temp= WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
	return temp.toLowerCase();
}

function ShowHideDiv(divName, strDisplay, strInnerHTML)
{
    try
    {
            //alert("objFrame is not an obect");
        var objDiv = document.getElementById(divName);
        if (objDiv != null)
        {
            objDiv.style.display = strDisplay;
            if (strInnerHTML != null && strInnerHTML != "")
            {
                objDiv.innerHTML = strInnerHTML
            }
        }
    }
    catch(e)
    {
        //HandleError("Error in function ShowHideDiv():: " + e.description);
    }
}

function Bookmark(url, title, iEvent_id, strEvent_data, strUser_id) {
	if (window.sidebar) {
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	} else if (window.external) {
		// IE Favorite
		window.external.AddFavorite(url, title);
	}
	Track(iEvent_id, strEvent_data, strUser_id);
}

function BookmarkExternal(strType, iEvent_id, strEvent_data, strUser_id) {
    strType = strType.toLowerCase();
    var strURL = '', strThisURL = (window.current_full_page_url || location.href || '');
    switch (strType) {
        case 'aol':
            strURL = 'http://favorites.my.aol.com/ffclient/webroot/0.3.1/src/html/addBookmarkDialog.html?url=' + escape(strThisURL) + '&title=' + document.title + '&favelet=true';
            break;
        case 'delicious':
            strURL = 'http://del.icio.us/post?url=' + escape(strThisURL) + '&title=' + document.title;
            break;
        case 'digg':
            strURL = 'http://digg.com/submit?phase=2&url=' + escape(strThisURL) + '&title=' + document.title + '&bodytext=InstantCast&topic=celebrity';
            break;
        case 'facebook':
            strURL = 'http://www.facebook.com/share.php?u=' + escape(strThisURL);
            break;
        case 'google':
            strURL = 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + escape(strThisURL) + '&title=' + document.title;
            break;
        case 'myspace':
            strURL = 'http://www.myspace.com/Modules/PostTo/Pages/?t=' + encodeURIComponent(document.title) + '&c=' + encodeURIComponent(GetMetaContents('description')) + '&u=' + encodeURIComponent(strThisURL) + '&l=2';
            break;
        case 'stumbleupon':
            strURL = 'http://www.stumbleupon.com/submit?url=' + escape(strThisURL) + '&title=' + document.title;
            break;
        case 'yahoo':
            strURL = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + escape(strThisURL) + '&t=' + document.title;
            break;
    }
    if ((strURL != '') && (strThisURL != '')) {
        window.open(strURL);
        Track(iEvent_id, strEvent_data, strUser_id);
    }
}

function ChangeImage(strImageID, strNewSrc) {
    if (strImageID && strNewSrc && (strImageID != '') && (strNewSrc != '')) {
        var elImage = document.getElementById(strImageID);
        if (elImage) elImage.src = strNewSrc;
    }
}

function GetSelectBoxValue(selectBoxName)
{
	try
	{
	    var returnValue = new String("-1");
	    var objSelectBox = document.getElementById(selectBoxName);
	    if (objSelectBox != null)
	        returnValue = objSelectBox.options[objSelectBox.selectedIndex].value;
	    return returnValue;
	        
	}
	catch(e)
	{
	}
}
function ButtonQuickSearchMemberProfile_OnClick()
{
//    var QuickSearchMemberProfileName = document.getElementById("QuickSearchMemberProfileName");
//    var QuickSearchMemberProfileAge = document.getElementById("QuickSearchMemberProfileAge");
//    var QuickSearchMemberProfileGender = document.getElementById("QuickSearchMemberProfileGender");
    var QuickSearchMemberProfilePleaseWait = document.getElementById("QuickSearchMemberProfilePleaseWait");
    
//    if (QuickSearchMemberProfileName != null && QuickSearchMemberProfileAge != null && QuickSearchMemberProfileGender != null && QuickSearchMemberProfilePleaseWait != null)
    if (QuickSearchMemberProfilePleaseWait != null)
    {
        // show please waiting
        QuickSearchMemberProfilePleaseWait.style.display = '';

        // generate querystring
//        var strSubmitURL = new String();
//        strSubmitURL += "&Name=" + QuickSearchMemberProfileName.value;
//        var strGenderSelected = GetSelectBoxValue("QuickSearchMemberProfileGender");
//        if (strGenderSelected != "1100")
//            strSubmitURL += "&Gender=" + strGenderSelected;
//        var strAgeSelected = GetSelectBoxValue("QuickSearchMemberProfileAge");
//        if (strAgeSelected != "|")
//        {
//            strSubmitURL += "&AgeRange=" + strAgeSelected;
//        }
//        strSubmitURL = "/MemberProfiles/SearchMembers/?IsAdvanced=False" + strSubmitURL;
        
        // redirect to search page
//        document.location.href = strSubmitURL;
    }
}
function GetQueryStringVariable(ji)
{
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++)
    {
        ft = gy[i].split("=");
        if (ft[0] == ji)
        {
            return ft[1];
        }
    }
}
function ButtonQuickSearchParts_OnClick()
{
    var QuickSearchPartsPleaseWait = document.getElementById("QuickSearchPartsPleaseWait");
    
    if (QuickSearchPartsPleaseWait != null)
    {
        // show please waiting
        QuickSearchPartsPleaseWait.style.display = '';
    }
}
function ButtonUploadVideo_OnClick()
{
    var UploadVideoMessage = document.getElementById("UploadVideoMessage");
    if (UploadVideoMessage != null)
    {
            ShowHideDiv('UploadVideoMessage', '');    
    }
}
function ChangeProfileInnerText(objDiv, strText)
{
    try
    {
        objDiv.innerText = strText;
    }
    catch (e)
    {
    }
}
function getUserAgent()
{
    
	try
	{
        // create user agent object
        var UA = new Object();
        
        // create properties for user agent object
        UA.os;
        UA.browser;
        UA.browserVersion;

        var UAString = navigator.userAgent.toLowerCase();

        // initialize os property
        if (UAString.indexOf("windows nt 5.1") != -1) UA.os = "XP";
        if (UAString.indexOf("windows nt 5.0") != -1) UA.os = "Windows2000";
        if (UAString.indexOf("windows nt 4.0") != -1) UA.os = "WindowsNT";
        if (UAString.indexOf("win 9x 4.90") != -1) UA.os = "WindowsME";
        if (UAString.indexOf("windows 98") != -1) UA.os = "Windows98";
        if (UAString.indexOf("mac") != -1) UA.os = "Macintosh";

        // initialize browser property
        if (UAString.indexOf("msie") != -1) UA.browser = "IE";
        if (UAString.indexOf("aol") != -1) UA.browser = "AOL";
        if (UAString.indexOf("netscape") != -1) UA.browser = "Netscape";
        if (UAString.indexOf("firefox") != -1) UA.browser = "Firefox";
        if (UAString.indexOf("safari") != -1) UA.browser = "Safari";

        // initialize browser version property
        if (UA.browser == "IE"){
            var tempArray = UAString.split(";");
            for (var i=0; i < tempArray.length; i++){
               if (tempArray[i].indexOf("msie") != -1){
                    UA.browserVersion = tempArray[i].substring(5, tempArray[i].length);
               }
            }
            delete tempArray;
        }
        if (UA.browser == "AOL"){
            var tempArray = UAString.split(" ");
            for (var i=0; i < tempArray.length; i++){
               if (tempArray[i].indexOf("netscape") != -1){
                    UA.browserVersion = tempArray[i].substring(4, tempArray[i].length);
               }
            }
            delete tempArray;
        }
        if (UA.browser == "Firefox"){
            var tempArray = UAString.split(" ");
            for (var i=0; i < tempArray.length; i++){
               if (tempArray[i].indexOf("firefox") != -1){
                    UA.browserVersion = tempArray[i].substring(8, tempArray[i].length);
               }
            }
            delete tempArray;
        }
        if (UA.browser == "Safari"){
            var tempArray = UAString.split(" ");
            for (var i=0; i < tempArray.length; i++){
               if (tempArray[i].indexOf("safari") != -1){
                    UA.browserVersion = tempArray[i].substring(7, tempArray[i].length);
               }
            }
            delete tempArray;
        }
        if (UA.browser == "Netscape"){
            var tempArray = UAString.split(" ");
            for (var i=0; i < tempArray.length; i++){
               if (tempArray[i].indexOf("netscape") != -1){
                    UA.browserVersion = tempArray[i].substring(9, tempArray[i].length);
               }
            }
            delete tempArray;
        }

        // return user agent object
        return UA;
    }
    catch(e)
    {
        //HandleError("Error in function getUserAgent():: " + e.description);
    }
}
function CheckboxSubscribeBackstage_OnClick(strStream_id)
{
    //alert("User_id=" + strUser_id + " :: Stream_id=" + strStream_id);
        //var strURL = new String("/Utilities/WebService/Subscription.aspx?cmd=insert&userid=" + escape(strUser_id) + "&streamid=" + escape(strStream_id));
        var strURL = new String("/Utilities/WebService/Subscription.aspx?streamid=" + strStream_id);
        //alert(strURL);
        //alert(strURL2);
        GetTextFromURL(strURL);
    var spanSubscribeBackstage = document.getElementById("spanSubscribeBackstage");
    if (spanSubscribeBackstage != null)
    {
        spanSubscribeBackstage.innerHTML = "<span style=\"color: #A72CB9;\">Thank you for subscribing to the Backstage newsletter.</span>";

    }

    
}

function add_tooltip(strOrigin, strTarget) {
	$(strOrigin).bind('mouseenter', function() {
		$(strTarget).show();
	});
	$(strOrigin).bind('mouseleave', function() {
		$(strTarget).hide();
	});
	$(strOrigin).bind('mousemove', function(e) {
		var t = $(strTarget);
		var b = $('html, body');
		t.css('position', 'absolute');
		t.css('left', (b.scrollLeft() + e.clientX + 5) + 'px');
		t.css('top', (b.scrollTop() + e.clientY + 5) + 'px');
	});
}