function InputHelperCreate(id, text, cColor) {
    function addEvents(obj) {
        obj.bind('focus', function() {
                InputHelperIn(id, text);
            })
           .bind('blur', function() {
                InputHelperOut(id, text, cColor);
           });
    }

    function switchInput(obj, type, callback){
        if(obj.attr('inpType') == 'password') {
            var ob = $('<input>');
            ob.attr('id', obj.attr('id'));
            ob.attr('class', obj.attr('class'));
            ob.attr('name', obj.attr('name'));
            ob.attr('style', obj.attr('style'));
            ob.attr('inpType', obj.attr('inpType'));
            switch(type){
                case 'password':
                       ob.attr('type', 'password');
                    break;
                case 'text':
                       ob.attr('type', 'text');
                    break;
            }
            obj.parent().append(ob);
            obj.remove();
            obj = ob;
            if(typeof(callback) == 'function'){
                callback(obj);
            }
            addEvents(obj);
        }
        return obj;
    }

    function InputHelperIn(id, text, noClean) {
        var obj = $(id);
        if (obj.val() == text || noClean) {
            obj = switchInput(obj, 'password', function(el){ el.focus(); });
            obj.css({color: '#000000', fontStyle: 'normal', backgroundColor: '#FFFFCC'});
            if (!noClean) {
                obj.val('');
            }
        }
    }

    function InputHelperOut(id, text, cColor) {
        var obj = $(id);
        if (obj.val() == '' || obj.val() == text) {
            obj = switchInput(obj, 'text');
            obj.css({color: cColor ? cColor : '#b3b3b3', fontStyle: 'normal', backgroundColor: '#FFFFFF'})
               .val(text);
        }
    }

    function InputHelperClear(id, text) {
        var obj = $(id);
        if(obj.val() == text) {
            obj.val('');
        }
    }

    var obj = $(id);
    obj.attr('inpType', obj.attr('type'));
    obj.parents('form:first').submit(function () {
                                        InputHelperClear(id, text)
                                     });
    addEvents(obj);
    if (obj.val() == '' || obj.val() == text) {
        InputHelperOut(obj, text, cColor);
    }
    else {
        InputHelperIn(obj, text, true);
    }
}

function OverCommentHelperCreate() {
    function OverCommentHelperIn(e) {
        var obj = $(e);
        if(obj.children('img').length > 0){
            obj.siblings('a').css({color: "#6688FF"});
            obj.children('img').css({border: '1px solid #333333'})
        }
        else {
            obj.css({color: "#6688FF"});
            obj.siblings('a').children('img').css({border: '1px solid #333333'})
        }
    }

    function OverCommentHelperOut(e) {
        var obj = $(e);
        if(obj.children('img').length > 0) {
            obj.siblings('a').css({color: "#0000FF"});
            obj.children('img').css({border: '1px solid #D7D7D7'})
        }
        else {
            obj.css({color: "#0000FF"});
            obj.siblings('a').children('img').css({border: '1px solid #D7D7D7'});
        }
    }
    var obj = $('.over_comment');
    obj.each(function(i, e) {
            $(e).bind('mouseenter', function() {
                OverCommentHelperIn(e);
            })
            $(e).bind('mouseleave', function() {
                OverCommentHelperOut(e);
        });
    });
}

$(document).ready(function() {
    $('<img>').attr('src', '/wp-content/themes/2009GofG/label/teaser-c-over.png');
    InputHelperCreate("#e-sub-text", "Enter email address");
    InputHelperCreate("#keyword", "Find people in photos");
    InputHelperCreate("#people_keyword", "Find people in photos");
    InputHelperCreate("#right_keyword", "Find people in photos");
    InputHelperCreate("#venues_keyword", "Search By Name");
    InputHelperCreate("#t-box-text", "Anonymous...");
    InputHelperCreate("#t-box-input", "Type word here...");
    InputHelperCreate("#Description", "Please avoid all CAPS", "#7C7C7C");
    InputHelperCreate("#commentTextArea", "Anonymous...please be nice (or it won\'t be accepted!)");
    InputHelperCreate("#signupEmail", "Enter your mail address here....");
    InputHelperCreate("#email", "Email");
    InputHelperCreate("#cpassword", "Password");
    InputHelperCreate("#invite_friends", "friend1@example.com\nfriend2@example.com\nfriend3@example.com");
    OverCommentHelperCreate();
    $("div.creply").hover(
      function () {
        $(this).addClass('creply-over');
        $(this).find('.ireply').addClass('ireply-over');
      },
      function () {
        $(this).removeClass('creply-over')
        $(this).find('.ireply').removeClass('ireply-over');
      }
    );
});
function vvq_youtube(objectID, videoWidth, videoHeight, videoID) {
	swfobject.embedSWF("http://www.youtube.com/v/" + videoID, objectID, videoWidth, videoHeight, "9.0.0", "", "", {wmode:"transparent"});
}
function vvq_googlevideo(objectID, videoWidth, videoHeight, videoID) {
	swfobject.embedSWF("http://video.google.com/googleplayer.swf?docId=" + videoID, objectID, videoWidth, videoHeight, "9.0.0", "", "", {wmode:"transparent"});
}

// Stage6 is dead. This is only here for backwards compatibility.
function vvq_stage6(objectID, videoWidth, videoHeight, videoID) {
	return false;
}

function vvq_ifilm(objectID, videoWidth, videoHeight, videoID) {
	swfobject.embedSWF("http://www.ifilm.com/efp", objectID, videoWidth, videoHeight, "9.0.0", "", {flvbaseclip:videoID}, {wmode:"transparent"});
}

function vvq_metacafe(objectID, videoWidth, videoHeight, videoID, videoName) {
	swfobject.embedSWF("http://www.metacafe.com/fplayer/" + videoID + "/" + videoName + ".swf", objectID, videoWidth, videoHeight, "9.0.0", "", {playerVars:"playerVars",showStats:"yes",autoPlay:"no"}, {wmode:"transparent"});
}

function vvq_myspace(objectID, videoWidth, videoHeight, videoID) {
	swfobject.embedSWF("http://lads.myspace.com/videos/vplayer.swf", objectID, videoWidth, videoHeight, "9.0.0", "", {m:videoID,type:"video"}, {wmode:"transparent"});
}

function vvq_vimeo(objectID, videoWidth, videoHeight, videoID) {
	swfobject.embedSWF("http://www.vimeo.com/moogaloop.swf?clip_id=" + videoID + "&server=vimeo.com&fullscreen=1&show_title=1&show_byline=1&show_portrait=0&color=01AAEA", objectID, videoWidth, videoHeight, "9.0.0", "", {allowfullscreen:"true",scale:"showAll"}, {wmode:"transparent"});
}

function vvq_flv(objectID, videoWidth, videoHeight, SWFURL, FLVFileURL, PreviewImageURL) {
	swfobject.embedSWF(SWFURL, objectID, videoWidth, videoHeight, "9.0.0", "", {file:FLVFileURL,usefullscreen:"false",image:PreviewImageURL}, {wmode:"transparent",allowFullScreen:"true"});
}

// Get around Internet Explorer's retarded click-to-activate thing by writing the HTML via Javascript
function vvq_quicktime(objectID, videoWidth, videoHeight, videoURL) {
	document.getElementById(objectID).innerHTML = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="' + videoWidth + '" height="' + videoHeight + '"><param name="src" value="' + videoURL + '" /><param name="controller" value="true" /><param name="autoplay" value="false" /><param name="wmode" value="transparent" /><object type="video/quicktime" data="' + videoURL + '" width="' + videoWidth + '" height="' + videoHeight + '" class="mov"><param name="controller" value="true" /><param name="autoplay" value="false" /><p><a href="' + videoURL + '">' + videoURL + '</a></p></object></object>';
}

function vvq_videoWMP(objectID, videoWidth, videoHeight, videoURL) {
	document.getElementById(objectID).innerHTML = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="' + videoWidth + '" height="' + videoHeight + '"><param name="url" value="' + videoURL + '" /><param name="allowchangedisplaysize" value="true" /><param name="autosize" value="true" /><param name="displaysize" value="1" /><param name="showcontrols" value="true" /><param name="showstatusbar" value="true" /><param name="autorewind" value="true" /><param name="autostart" value="false" /><param name="volume" value="100" /></object>';
}

function vvq_videoNoWMP(objectID, videoWidth, videoHeight, videoURL, mimeType) {
	document.getElementById(objectID).innerHTML = '<object type="' + mimeType + '" data="' + videoURL + '" width="' + videoWidth + '" height="' + videoHeight + '" class="vvqbox vvqvideo"><param name="src" value="' + videoURL + '" /><param name="allowchangedisplaysize" value="true" /><param name="autosize" value="true" /><param name="displaysize" value="1" /><param name="showcontrols" value="true" /><param name="showstatusbar" value="true" /><param name="autorewind" value="true" /><param name="autostart" value="false" /><param name="autoplay" value="false" /><param name="volume" value="100" /></object>';
}


/*	SWFObject v2.0 rc4 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var X="undefined",P="object",a="visibility:visible",e="visibility:hidden",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",V="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,S=false,C=false;var Y=function(){var l=typeof g.getElementById!=X&&typeof g.getElementsByTagName!=X&&typeof g.createElement!=X&&typeof g.appendChild!=X&&typeof g.replaceChild!=X&&typeof g.removeChild!=X&&typeof g.cloneNode!=X,t=[0,0,0],n=null;if(typeof N.plugins!=X&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=X){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var d=function(){if(!Y.w3cdom){return}J(I);if(Y.ie&&Y.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=b("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);U()}}}}catch(j){}}if(Y.webkit&&typeof g.readyState!=X){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){U()}},10)}if(typeof g.addEventListener!=X){g.addEventListener("DOMContentLoaded",U,null)}M(U)}();function U(){if(S){return}if(Y.ie&&Y.win){var m=W("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return}}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=X){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=X){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=X){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(Y.pv[0]>0){var k=b(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(Y.webkit&&Y.webkit<312){T(k)}}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(Y.win||Y.mac)){D(H[j])}else{c(k)}}}}A("#"+m,a)}}function T(m){var k=m.getElementsByTagName(P)[0];if(k){var p=W("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(Y.ie&&Y.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=b(i);for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)})}}function D(j){C=true;var o=b(j.id);if(o){if(j.altContentId){var l=b(j.altContentId);if(l){L=l}}else{L=Z(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=Y.ie&&Y.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(Y.ie&&Y.win&&o.readyState!=4){var i=W("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function c(j){if(Y.ie&&Y.win&&j.readyState!=4){var i=W("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(Z(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(Z(j),j)}}function Z(n){var m=W("div");if(Y.win&&Y.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=b(q);if(typeof AE.id==X){AE.id=q}if(Y.ie&&Y.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=b(AE.id)}else{if(Y.webkit&&Y.webkit<312){var AA=W("embed");AA.setAttribute("type",V);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=W(P);s.setAttribute("type",V);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=W("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function b(i){return g.getElementById(i)}function W(i){return g.createElement(i)}function O(k){var j=Y.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(Y.ie&&Y.mac){return}var l=g.getElementsByTagName("head")[0],k=W("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(Y.ie&&Y.win)&&typeof g.createTextNode!=X){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(Y.ie&&Y.win&&typeof g.styleSheets!=X&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}return{registerObject:function(l,i,k){if(!Y.w3cdom||!l||!i){return}var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;A("#"+l,e)},getObjectById:function(l){var i=null;if(Y.w3cdom&&S){var j=b(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=X)){i=j}else{if(typeof k.SetVariable!=X){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!Y.w3cdom||!n||!u||!r||!t||!j){return}r+="";t+="";if(O(j)){A("#"+u,e);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=X){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);A("#"+u,a)})}else{if(m&&!C&&O("6.0.65")&&(Y.win||Y.mac)){A("#"+u,e);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i);A("#"+u,a)})}}},getFlashPlayerVersion:function(){return{major:Y.pv[0],minor:Y.pv[1],release:Y.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(Y.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(Y.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=b(K);if(i){i.parentNode.replaceChild(L,i);L=null;C=false}}}}}();
function fade_bookmark_buttons_in(div_id)
{
	// assign a default id if necessary
	// flag the form as active
	document.getElementById(div_id).isActive = true;

	// only consider the latest in a multi-mouse over/out scenario
	document.getElementById(div_id).activeCall = bookmark_buttons_next_hash();

	// set show admin bar timeout
	var timeout_handler = 'show_bookmark_buttons(\'' + div_id + '\', \'' + document.getElementById(div_id).activeCall + '\');';
	setTimeout(timeout_handler, 50);
} // fade_bookmark_buttons_in()


function fade_bookmark_buttons_out(div_id)
{
	// flag the form as inactive
	document.getElementById(div_id).isActive = false;

	// only consider the latest in a multi-mouse over/out scenario
	document.getElementById(div_id).activeCall = bookmark_buttons_next_hash();

	// set hide admin bar timeout
	var timeout_handler = 'hide_bookmark_buttons(\'' + div_id + '\', \'' + document.getElementById(div_id).activeCall + '\');';
	setTimeout(timeout_handler, 300);
} // end fade_bookmark_buttons_out()


function show_bookmark_buttons(div_id, div_id_call)
{
	// if we're on the active form
	if ( document.getElementById(div_id).isActive )
	{
		document.getElementById(div_id).style.display = 'block';
	}
} // end show_bookmark_buttons()


function hide_bookmark_buttons(div_id, div_id_call)
{
	// if we're no longer on the active form
	if ( !document.getElementById(div_id).isActive
		&& ( document.getElementById(div_id).activeCall == div_id_call )
		)
	{
		document.getElementById(div_id).style.display = 'none';
	}
} // end hide_bookmark_buttons()


function bookmark_buttons_next_hash()
{
	var new_hash = '';
	var digits = '0123456789abcdef';

	while ( new_hash.length < 32 )
	{
		start = Math.floor(Math.random() * digits.length);
		end = start + 1;
		new_hash += digits.substring(start, end);
	}

	return new_hash;
} // end bookmark_buttons_next_hash()var ap_instances = new Array();

function ap_stopAll(playerID) {
	for(var i = 0;i<ap_instances.length;i++) {
		try {
			if(ap_instances[i] != playerID) document.getElementById("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 1);
			else document.getElementById("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 0);
		} catch( errorObject ) {
			// stop any errors
		}
	}
}

function ap_registerPlayers() {
	var objectID;
	var objectTags = document.getElementsByTagName("object");
	for(var i=0;i<objectTags.length;i++) {
		objectID = objectTags[i].id;
		if(objectID.indexOf("audioplayer") == 0) {
			ap_instances[i] = objectID.substring(11, objectID.length);
		}
	}
}

//var ap_clearID = setInterval( ap_registerPlayers, 100 );eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h 3=Z 11(12);h 6=0;h c="";h b=0;h 5=8;h n=(7.O&&7.9);h o=(!7.O&&7.9);h p=(13.14.15("16")>-1);h d=q;f 17(a){2(!d){d=r;6=a;s=7.9(\'P\'+6);k=18("s.Q"+6);c="";2(7.9(\'R\'+6)){l=S(7.9(\'R\'+6).y)}4{l=0}t=0;2(k.z!=19){T(i=0;i<k.z;i++){2(k[i].1a){2(l>0){c=k[i].y+","+c;t++}4{c=S(k[i].y)}}}}4{c=k.y}2(l>0){2(t>0&&t<=l){c=c.1b(0,(c.z-1));u();A()}4 2(t==0){d=q;m(U)}4{d=q;m(1c+" "+l+".")}}4{2(c>0){u();A()}4{d=q;m(U)}}}4{m(G)}}f 1d(a){2(!d){d=r;6=a;u();H()}4{m(G)}}f 1e(a){2(!d){d=r;6=a;u();I()}4{m(G)}}f v(){2(b==1f){w()}2(b<8){b+=10;2(p){b=8;w()}4 2(n){2(j){7.9(\'3-\'+6+\'-e\').g.B=\'C(D=\'+b+\')\'}4{b=8;w()}}4 2(o){2(j){7.9(\'3-\'+6+\'-e\').g.E=(b/8)}4{b=8;w()}}F("v()",8)}4{b=8;d=q}}f u(){2(V){7.9(\'3-\'+6+\'-W\').g.X=\'1g\'}}f w(){2(V){7.9(\'3-\'+6+\'-W\').g.X=\'1h\'}}f A(){2(5>0){5-=10;2(p){5=0}4 2(n){2(j){7.9(\'3-\'+6+\'-e\').g.B=\'C(D=\'+5+\')\'}4{5=0}}4 2(o){2(j){7.9(\'3-\'+6+\'-e\').g.E=(5/8)}4{5=0}}F("A()",8)}4{5=0;3.J();3.x("1i",r);3.x("6",6);3.x("Q"+6,c);3.K=\'1j\';3.L=\'3-\'+6+\'-e\';3.M=v;3.N();b=0;5=8}}f H(){2(5>0){5-=10;2(p){5=0}4 2(n){2(j){7.9(\'3-\'+6+\'-e\').g.B=\'C(D=\'+5+\')\'}4{5=0}}4 2(o){2(j){7.9(\'3-\'+6+\'-e\').g.E=(5/8)}4{5=0}}F("H()",8)}4{5=0;3.J();3.x("1k",6);3.K=\'Y\';3.L=\'3-\'+6+\'-e\';3.M=v;3.N();b=0;5=8}}f I(){2(5>0){5-=10;2(p){5=0}4 2(n){2(j){7.9(\'3-\'+6+\'-e\').g.B=\'C(D=\'+5+\')\'}4{5=0}}4 2(o){2(j){7.9(\'3-\'+6+\'-e\').g.E=(5/8)}4{5=0}}F("I()",8)}4{5=0;3.J();3.x("1l",6);3.K=\'Y\';3.L=\'3-\'+6+\'-e\';3.M=v;3.N();b=0;5=8}}f 1m(a){s=7.9(\'P\'+a);T(i=0;i<s.z;i++){s[i].1n=r}}',62,86,'||if|polls|else|poll_fadeout_opacity|poll_id|document|100|getElementById||poll_fadein_opacity|poll_answer_id|is_being_voted|ans|function|style|var||poll_show_fading|poll_answer|poll_multiple_ans|alert|is_ie|is_moz|is_opera|false|true|poll_form|poll_multiple_ans_count|poll_loading_text|poll_fadein_text|poll_unloading_text|setVar|value|length|poll_process|filter|alpha|opacity|MozOpacity|setTimeout|polls_text_wait|poll_process_result|poll_process_booth|reset|method|element|onCompletion|runAJAX|all|polls_form_|poll_|poll_multiple_ans_|parseInt|for|polls_text_valid|poll_show_loading|loading|display|GET|new||sack|polls_ajax_url|navigator|userAgent|indexOf|Opera|poll_vote|eval|null|checked|substring|polls_text_multiple|poll_result|poll_booth|90|block|none|vote|POST|pollresult|pollbooth|poll_disable_voting|disabled'.split('|'),0,{}));

loginPopUp = (function(){
    
    var self = this;
    self.inited = false;
    self.holder = null;
    self.background = null;
    self.init = function(){
        
        self.background = $('<div></div>').addClass('login-popup-bg').hide();
        self.contentholder = $('<div></div>').addClass('login-popup-content-holder').hide();
        self.contentholder.html("<table class=\"popup-content-table\"><tr><td valign=\"middle\" align=\"center\"><div class=\"login-popup-content\"></div></td></tr></table>");
        self.holder = self.contentholder.find(".login-popup-content");
        self.root = $('<div></div>');
        /*$('body').append(self.root.css("position","absolute")
                        .css("height","100%")
                        .css("width","100%")
                        .css("z-index","100000")
                        .append(self.background)
                        .append(self.contentholder)
                        );*/
        $('body').css("position","absolute")
                .css("height","100%")
                .css("width","100%")
                .css("z-index","100000")
                .prepend(self.background)
                .append(self.contentholder);
        self.root.hide();
        self.inited = true;
    };
    self.collectPostData = function(action){
        var res = {};
        switch(action){
            case "reentermail":
                res.isInvalidEmail = self.holder.find("#isInvalidEmail").val();
                res.signupEmail = self.holder.find("#signupEmail").val();
                break;
            case "signupstep2":
                res.signupEmail = $("#signupEmail").val();
                res.inviteid = $("#inviteid").val();
                break;
            case "topsignup":
                res.signupEmail = $("#e-sub-text").val();
                break;
            case "submit":
                res.fName = self.holder.find("#fName").val();
                res.lName = self.holder.find("#lName").val();
                res.income = self.holder.find("[name=income]").val();
                res.gender = self.holder.find("[name=gender]").val();
                res.age = self.holder.find("[name=age]").val();
                res.iLiveIn = self.holder.find("[name=iLiveIn]").val();
                res.zip = self.holder.find("[name=zip]").val();
            case "skip":
                res.inviteid = self.holder.find("#invId").val();
                res.hiddenSignupEmail = self.holder.find("#signupEmail").val();
                res.signupPassword = self.holder.find("#signupPassword").val();
                res.username = self.holder.find("#username").val();
                break;
            case "dologin":
                res.uname = self.holder.find("#uname").val();
                res.upwd = self.holder.find("#upwd").val();
                res.remember = self.holder.find("#remember").attr("checked")?1:0;
                break;
            case "register":
                res.signupPassword = self.holder.find("#signupPassword").val();
                res.username = self.holder.find("#username").val();
                res.signupEmail = self.holder.find("#signupEmail").val();
                res.securitycode = self.holder.find("#securitycode").val();
                res.matchthis = self.holder.find("[name=matchthis]").val();
                res.termsAgree = self.holder.find("#termsAgree").val();
                res.signupNewsletter = self.holder.find("#signupNewsletter").val();
                break;
            case "sendpwd":
                res.remindTo = self.holder.find("#remindEmail").val();
                break;                    
        }
        return res;
    }
    self.actions = {login:"login",
                    signup:"signupstep2",
                    topsignup:"topsignup",
                    skipInfo:"skip",
                    submitInfo:"submit",
                    doLogin:"dologin",
                    register:"register",
                    signupsimple:"signupsimple",
                    reentermail:"reentermail",
                    forgotpassword:"forgotpwd",
                    sendpwd:"sendpwd"};
    return {
        unameregistered:false,
        emailregistered:false,
        lastuname:"",
        lastemail:"",
        captchacorrect:true,
        lastcaptcha:"",
        actions:self.actions,
        callPopUp:function (action, validator){
            if(this.unameregistered == 'checking' || this.emailregistered == "checking" || this.captchacorrect == "checking") return;
            if(!self.inited)
                self.init();
            var valid = false;
            if(validator)
                valid = validator(self.holder);
            else
                valid = true;
            if(valid){
                var data = self.collectPostData(action);
                data.popup = 1;
                self.holder.html("");
                self.holder.addClass("popup-loader");
                $.ajax({
                        url: '/account/' + action,
                        type: 'POST',
                        dataType: 'html',
                        data: data,
                        success:function(res){
                          self.holder.removeClass("popup-loader");
                          self.holder.html(res);
                        },
                        error:function(res){
                            self.holder.html(res);
                        },
                        complete:function(a1, a2){
                            var a = 10;
                        }});
                this.openPopUp();
            }
        },
        closePopUp:function(){
            self.contentholder.hide();
            self.background.hide();
           // self.root.hide();
        },
        openPopUp:function(){
            self.background.show();
            self.contentholder.show();
            //self.root.show();
        },
        createUsername:function(res, uname){
            var email = res.value;
            var pos = search(email,'@');
            uname.value = pos > 0?substr(email, 0, pos - 1):email;
        }
    }   
})();
function validateForgotForm(holder){
    var email = holder.find("#remindEmail").val();
    var err_img = $("<img>").addClass("icons");
    if($.trim(email) == "") {
                holder.find("#remindEmailError").text("")
                            .append(err_img.clone())
                            .append("Please provide your email or username");
		holder.find("#remindEmail").focus();
    	return false;
    }
    return  true;
}
function skipValidator(holder)
{
     var signupPassword = holder.find("#signupPassword").val();
     var cSignupPassword = holder.find("#signupPasswordConfirm").val();
     var username = holder.find("#username").val();
     var pvalid = true, uvalid = true;
     var err_img = $("<img>").addClass("icons");
     if(signupPassword != cSignupPassword){
         holder.find("#passwordError").text("")
                            .append(err_img.clone())
                            .append("Passwords do not match");
         pvalid = false;
     }
     
     if(signupPassword.length < 6){
         holder.find("#passwordError").text("")
                            .append(err_img.clone())
                            .append("Password is too short");
         pvalid = false;
     }
     if(pvalid) holder.find("#passwordError").html("");
     
     if(username == '3 to 32 alphanumeric characters or "_"' || $.trim(username) == ""){
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is required");
         uvalid = false;
     }
     
     if((username.length < 3)&& username != '3 to 32 alphanumeric characters or "_"' ){
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is too short");
         uvalid = false;
     }
     if((username.length > 32)&& username != '3 to 32 alphanumeric characters or "_"' ){
        holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is too long");
         uvalid = false;
     }
     
     
      var unRegexp =  /[^a-zA-Z0-9_]/;
     if(unRegexp.test(username) && username != '3 to 32 alphanumeric characters or "_"' ){
         //$("#usernameError").text("Username should contain alphanumeric characters and \"_\" only");
        holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Letters, digits and \"_\" only");
         uvalid = false;
     }
     if(uvalid && !loginPopUp.unameregistered) holder.find("#usernameError").html("");
   
     return (pvalid && uvalid && !loginPopUp.unameregistered && !loginPopUp.emailregistered);
}
function checkUsername(object, errorHolder){
    if(loginPopUp.lastuname == object.value || object.value == "" ) return;
    $("#"+errorHolder).html('<div class="check"></div>&nbsp;Checking username...');
    loginPopUp.unameregistered = 'checking';
    loginPopUp.lastuname = object.value;
    $.ajax({
            url: '/account/checkuname',
            type: 'POST',
            dataType: 'html',
            data: {username:object.value,popup:1},
            success:function(res){

                if(res.substr(0, 2) == 'Ok'){
                    $("#"+errorHolder).html('<img class="icons iok" /><span style="color:#008000">Available</span>');
                    loginPopUp.unameregistered = false;
                }
                else{
                    $("#"+errorHolder).html('<img class="icons" />Username is already registered');
                    loginPopUp.unameregistered = true;
                }
            },
            error:function(res){
                loginPopUp.unameregistered = false;
            }});
}
function checkEmail(object, errorHolder){
    if(loginPopUp.lastemail == object.value || object.value == "" || object.value == "Enter your mail address here...") return;
    $("#"+errorHolder).html('<div class="check"></div>&nbsp;Checking email...');
    loginPopUp.emailregistered = 'checking';
    loginPopUp.lastemail = object.value;
    $.ajax({
            url: '/account/checkemail',
            type: 'POST',
            dataType: 'html',
            data: {email:object.value,popup:1},
            success:function(res){

                if(res.substr(0, 2) == 'Ok'){
                    $("#"+errorHolder).html('<img class="icons iok" /><span style="color:#008000">Ok</span>');
                    loginPopUp.emailregistered = false;
                }
                else{
                    $("#"+errorHolder).html('<img class="icons" />Email is already registered');
                    loginPopUp.emailregistered = true;
                }
            },
            error:function(res){
                loginPopUp.emailregistered = false;
            }});
}
function checkCaptcha(object, errorHolder){
    if(loginPopUp.lastcaptcha == object.value || object.value == "") return;
    $("#"+errorHolder).html('<div class="check"></div>&nbsp;Checking security code...');
    loginPopUp.captchacorrect = 'checking';
    loginPopUp.lastcaptcha = object.value;
    $.ajax({
            url: '/account/checkcaptcha',
            type: 'POST',
            dataType: 'html',
            data: {securitycode:object.value,popup:1,quicktest:1,matchthis:$("#popupMatchCode").val()},
            success:function(res){

                if(res.substr(0, 2) == 'Ok'){
                    $("#"+errorHolder).html('<img class="icons iok" /><span style="color:#008000">Ok</span>');
                    loginPopUp.captchacorrect = true;
                }
                else{
                    $("#"+errorHolder).html('<img class="icons" />Incorrect security code');
                    loginPopUp.captchacorrect = false;
                }
            },
            error:function(res){
                loginPopUp.captchacorrect = true;
            }});
}
function registerValidator(holder){
     var signupPassword = holder.find("#signupPassword").val();
     var signupPasswordConfirm = holder.find("#signupPasswordConfirm").val();
     var username = holder.find("#username").val();
     var signupEmail = holder.find("#signupEmail").val();
     var securitycode = holder.find("#securitycode").val();
     var termsAgree = holder.find("#termsAgree").attr('checked');
     var pvalid = true, uvalid = true, evalid = true, svalid = true, avalid = true;
     var err_img = $("<img>").addClass("icons");
     if($.trim(signupPassword) == ""){
         holder.find("#passwordError").text("")
                            .append(err_img.clone())
                            .append("Password can not be empty");
         pvalid = false;
     }
     if(signupPassword != signupPasswordConfirm){
         holder.find("#passwordError").text("")
                            .append(err_img.clone())
                            .append("Passwords do not match");
         pvalid = false;
     }
     if(signupPassword.length < 6){
         holder.find("#passwordError").text("")
                            .append(err_img.clone())
                            .append("Password must be at least 6 characters long");
         pvalid = false;
     }
     if(pvalid) holder.find("#passwordError").html("");
     
     if(username == '3 to 32 alphanumeric characters or "_"' || $.trim(username) == ""){
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is required");
         uvalid = false;
     }
     if(username == "" || username == '3 to 32 alphanumeric characters or "_"'){
       holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is required");
         uvalid = false;  
     } else if(username.length < 3 && username != '3 to 32 alphanumeric characters or "_"' ){
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is too short");
         uvalid = false;
     } else if(username.length > 32 && username != '3 to 32 alphanumeric characters or "_"' ){
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username is too long");
         uvalid = false;
     }
     var unRegexp =  /[^a-zA-Z0-9_]/;
     if(unRegexp.test(username) && username != '3 to 32 alphanumeric characters or "_"' ){
         //$("#usernameError").text("Username should contain alphanumeric characters and \"_\" only");
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Letters, digits and \"_\" only");
         uvalid = false;
     }
     if(uvalid && !loginPopUp.unameregistered) holder.find("#usernameError").html("");
     
     if(signupEmail == "") {
            holder.find("#signupEmailError").text("")
                                  .append(err_img.clone())
                                  .append("Empty email address");
            evalid = false;
    }	else if(signupEmail.search("[ ]") == 0) {
             holder.find("#signupEmailError").text("")
                                   .append(err_img.clone())
                                   .append("E-mail shouldn't start with spaces.");
            evalid = false;
    } else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(signupEmail))) 	{
            holder.find("#signupEmailError").text("")
                                  .append(err_img.clone())
                                  .append("Incorrect e-mail address");
            evalid = false;
    }
    if(evalid && !loginPopUp.emailregistered) holder.find("#signupEmailError").html("");
    if($.trim(securitycode) == ""){
        holder.find("#securityError").text("")
                           .append(err_img.clone())
                           .append("Empty security code");
        svalid = false;
    }
    if(svalid && loginPopUp.captchacorrect) holder.find("#securityError").html("");
    
    if(!termsAgree)
    {
        //alert('You should agree with Terms of Service and Privacy Policy to register');
        holder.find("#termsError").text("")
                        .append(err_img.clone())
                        .append("You should agree with Terms of Service and Privacy Policy");
        avalid = false
    }    
    if(avalid) holder.find("#termsError").html("");
   
    return (avalid && svalid && evalid && uvalid && pvalid && !loginPopUp.emailregistered && !loginPopUp.unameregistered && loginPopUp.captchacorrect);
}
function checkAgreeState(sender){
    if(sender.checked){
        $('#termsError').html('');
    }
}
function loginValidator(holder){
     var username = holder.find("#uname").val();
     var password = holder.find("#upwd").val();
     var valid = true; //$.trim(username) != "" && $.trim(password);
     var err_img = $("<img>").addClass("icons");
     //check password
     if ($.trim(password) == "") {
         holder.find("#passwordError").text("")
                            .append(err_img.clone())
                            .append("Password can not be empty");
         valid = false;
     }
     //check username
     if ($.trim(username) == "") {
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Username or email can not be empty");
         valid = false;
     } else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(username)) && !(/\w+/.test(username))) {
         holder.find("#usernameError").text("")
                            .append(err_img.clone())
                            .append("Incorrect username or password");
         valid = false;
     }
     return valid;
}

function blurfunction(obj, defval) {
	if ((obj.id == "uname") || (obj.id == "email")) {
		if ((obj.value == "") || (obj.value == "Email")) {
			obj.style.color = "#a4a4a4";
			obj.value = "Email";
		}
	} else if ((obj.id == "upass") || (obj.id == "cpassword")) {
		if ((obj.value == "") || (obj.value  == "Password")) {
			obj.type = "text";
			obj.style.color = "#a4a4a4";
			obj.value = "Password";
		}
	} else if ((obj.id == "fName") || (obj.id == "First")) {
		if ((obj.value == "") || (obj.value == "First")) {
			obj.style.color = "#a4a4a4";
			obj.value = "First";
		}
	} else if ((obj.id == "lName") || (obj.id == "Last")) {
		if ((obj.value == "") || (obj.value == "Last")) {
			obj.style.color = "#a4a4a4";
			obj.value = "Last";
		}
	}
	else if ((obj.id == "signupEmail") ) {
		if ((obj.value == "") || (obj.value == "Enter Email")) {
			obj.style.color = "#a4a4a4";
			obj.value = "Enter Email";
		}
	}
	else if ((obj.id == "signupPassword") ) {
		if ((obj.value == "") || (obj.value == "Enter Password")) {
			obj.style.color = "#a4a4a4";
			obj.value = "Enter Password";
			obj.type = "text";
		}
	}
        else if ((obj.id == "username") ) {
		if ((obj.value == "") || (obj.value == '3 to 32 alphanumeric characters or "_"')) {
			obj.style.color = "#a4a4a4";
			obj.value = '3 to 32 alphanumeric characters or "_"';
		}
	}else{
            if ((obj.value == "") || (obj.value == defval)) {
                obj.style.color = "#a4a4a4";
                obj.type = "text";
                obj.value = defval;
            }
        }
}

function focusfunction(obj, defval, type) {
	if (((obj.id == "uname") && (obj.value == "Email")) || ((obj.id == "fName") && (obj.value == "First")) || ((obj.id == "lName") && (obj.value == "Last")) || ((obj.id == "upass") && (obj.value == "Password")) || ((obj.id == "email") && (obj.value == "Email"))
            || ((obj.id == "cpassword") && (obj.value == "Password")) || ((obj.id == "username") && (obj.value == '3 to 32 alphanumeric characters or "_"'))) {
		obj.style.cursor = "default";
		obj.value = "";
		obj.style.color = "#333333";
	}else
	if ((obj.id == "upass") || (obj.id == "cpassword")) {
		obj.setAttribute('type',"password");
	}else
	if (((obj.id == "signupPassword") && (obj.value == "Enter Password")) || ((obj.id == "signupEmail") && (obj.value == "Enter Email"))){
		obj.style.cursor = "default";
		obj.value = "";
		obj.style.color = "#333333";
	}else
	if (obj.id == "signupPassword") {
		obj.setAttribute('type',"password");
	}else{
            if(defval && obj.value == defval){
                obj.style.cursor = "default";
		obj.value = "";
                obj.style.color="#000";
                if(type)
                    obj.setAttribute('type',type);
            }
        }
}

function goShare(elem) {
    var box = $(elem).parent();
    var text_box = box.children("textarea");
    if (!text_box.hasClass("opened")) {
        openTipBox(elem);
    } else {
        var str = text_box.val();
        if (str == "") {
            text_box.focus();
        } else {
            $.ajax({
                url: "/store_tip.php",
                dataType: "text",
                type: "POST",
                data: {
                    "tip": str
                },
                success: function (res) {
                    closeTipBox(elem, res);
                }
            })
        }
    }
}
function openTipBox(elem) {
    var box = $(elem).parent();
    var text_box = box.children("textarea");
    if (text_box.val() == "Have a tip? (anonymous)" || text_box.val() == "Your tip has been sent." || text_box.val() == "Your tip hasn't been sent.") {
        box.children(".icancel_tip")
           .removeClass("hidden");
        text_box.addClass("opened")
                .val("")
                .focus();
    }
}
function closeTipBox(elem, value) {
    var box = $(elem).parent();
    box.children("textarea")
       .removeClass("opened")
       .val(value ? value : "Have a tip? (anonymous)");
    box.children(".icancel_tip")
       .addClass("hidden");
}
function goToGuestComment() {
    $('.comment_wizard').hide();
    $('.comment_guest').show();
}
function putIntoComment(name) {
    $('#comment').val('@' + name + ': ')
                 .focus();
}