/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){
	if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";
	this.addParam("quality",q);
	this.addParam("wmode", "transparent");
	this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;

var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

/* moved from cdeprofile/js/bookmark.js */
/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

/* moved from cdeprofile/js/ajax.js */

var http = createRequestObject();

// Perhaps a stregety pattern should be used so we can just have all code submit to one formCheck() that udpates based on a passed "page" value.
// Then we could place all of your formCheck code in a single document and reduce complexity.
// Keith Brings.





function ajax_checkIinvite()
{



// <<EXTEND>>
// This code should use variable flags to inform check_form methods of it's results. 
// I will look into this later.
// <<//EXTEND>>

    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
			//alert(response);
            var response_code = response.split(',')[0]; // primitive. I suspect some sort of JSON approach could be used but this will suffice for now.
			var response_id   = response.split(',')[1];
			var response_user_id   = response.split(',')[2];
			ajax_checkIinvite_response[response_id] = response_code; 
			// Stores results with out our resorting to querying the test string and breaking our formcheck everytime the output text is changed.


			// response_code
			//
			// 0 = who knows. no response. Should be fine to invite.
			// 1 = user exists (may or may not be invited)
			// 2 = user already invited
			// 3 = empty email field.
			// 4 = invalid email
			///////////////////

			//
			// <<EXTEND>> Some Enumeration would be nice 
			//
			//////////
 
			


			switch(response_code)
			{ 
				
			case 0:    // 0 = who knows. no response. Should be fine to invite.
	            document.getElementById('check_friend' + response_id).style.color = 'green';
              document.getElementById('check_friend' + response_id).innerHTML = '';
			break;
			case 1:    // 1 = user exists (may or may not be invited)
	            document.getElementById('check_friend' + response_id).style.color = 'red';
              document.getElementById('check_friend' + response_id).innerHTML = 'That User is Already Registered. <a href="friendrequest.html?friend_id=' + response_user_id + '">Add to friends</a>.';
			break;
			case 2:   // 2 = user already invited
	          document.getElementById('check_friend' + response_id).style.color = 'red';
              document.getElementById('check_friend' + response_id).innerHTML = 'You Have Already Invited that Person!';
		    break;
			case 3: // 3 = empty email field.
	            document.getElementById('check_friend' + response_id).style.color = 'green';
              document.getElementById('check_friend' + response_id).innerHTML = '';		
			break; 	
			case 4:  // 4 = invalid email
	            document.getElementById('check_friend' + response_id).style.color = 'red';
              document.getElementById('check_friend' + response_id).innerHTML = 'That is not a Valid Email Address!';
			break;


			default:
			//document.getElementById('check_friend' + response_id).innerHTML = 'Invalid Response From Query';			
			// alert( "Invalid response recieved by ajax_checkIinvite  " , email );		
			};
        }
    }
    catch(e){}
    finally{}
}





//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<<EXTEND>>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// 
//   I am going to modify my ajax so that the source of origin nickname is included. 
//    I will then store return variables in that source file. In this manor our pages can all
//   access their specific result data. I will also begin passing the name of the target to update 
//   (for instance "isKosher_fs" this will alleviate the need for _shorthandfilename convention
//     I have used here to distinguish the ajax_isKosher_fs and ajax_isKosher functions.
//
// !!!!!!!!!!!!!!!<<EXTEND>>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
//    This is a priority going onwards. These functions will become ridiculous to deal with otherwise
//     and run the risk of peculiar interactions when multiple calls are joined on a single page.
//
//   -- Keith Brings 1/19/2008
/////////////////////////////////////////////////////////////////////////////////////////////////////





function ajax_isKosher()
{

    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
//            window.alert(response);
            if (response == '0') { 
            // the messages were not the same --> curse words or innapropriate chareceters.
			// It would be nice if I knew how to pass variables back here as I could list the adjusted search query.
	            document.getElementById('isKosher').style.color = 'red';
              document.getElementById('isKosher').innerHTML = 'Please only search for alphanumeric characters and remember no swearing!';
               clean = false;
            }
            else {
clean = true;
	            document.getElementById('isKosher').style.color = 'red';
              document.getElementById('isKosher').innerHTML = '';
            }
        }


    }

    catch(e){}
    finally{}
    proceed = true; // let searchbox->submit proceed.
}
function ajax_isKosher_fs()
{

    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
//            window.alert(response);
            if (response == '0') { 
            // the messages were not the same --> curse words or innapropriate chareceters.
			// It would be nice if I knew how to pass variables back here as I could list the adjusted search query.
	            document.getElementById('isKosher_fs').style.color = 'red';
              document.getElementById('isKosher_fs').innerHTML = 'Please only search for alphanumeric characters and remember no swearing!';
               clean_fs = false;
            }
            else {
clean_fs = true;
	            document.getElementById('isKosher_fs').style.color = 'red';
              document.getElementById('isKosher_fs').innerHTML = '';
            }
        }


    }

    catch(e){}
    finally{}
    proceed_fs = true; // let searchbox->submit proceed.
}

// the function is the same as check username, but the message is different
function ajax_checkReferrer()
{

	var responseArray = new Array();

    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
//            window.alert(response);  //response comes from ajax_check_username.html

			responseArray = response.split( ',,,' ); //tokenize response variable using ',,,' as separator
//			window.alert(responseArray[0]);
//			window.alert(responseArray[1]);

		  if (responseArray[0] == '0') {

			//replace old username if found to be vulgar in ajax_check_username.html
			document.getElementById('referrer').value = responseArray[1]; 
	         document.getElementById('referrer_status').style.color = 'red';
              document.getElementById('referrer_status').innerHTML = 'username not found!';

            }
            else {
               document.getElementById('referrer_status').style.color = 'green';
              document.getElementById('referrer_status').innerHTML = 'username found!';
           }
        }
    }
    catch(e){}
    finally{}
}

function ajax_checkUserName()
{

	var responseArray = new Array();

    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
//            window.alert(response);  //response comes from ajax_check_username.html

			responseArray = response.split( ',,,' ); //tokenize response variable using ',,,' as separator
			//window.alert(responseArray[0]);
			//window.alert(responseArray[1]);

			
		  if (responseArray[0] == 0) {

			//replace old username if found to be vulgar in ajax_check_username.html
			document.getElementById('username').value = responseArray[1]; 

              document.getElementById('username_available').style.color = 'green';
             username_exists = true;
              document.getElementById('username_available').innerHTML = 'username available!';
            }
            else {
            username_exists = false;
	         document.getElementById('username_available').style.color = 'red';
              document.getElementById('username_available').innerHTML = 'username not available!';
            }
        }
    }
    catch(e){}
    finally{}
}


function ajax_checkEmail()
{
    try{
    
        if((http.readyState == 4) && (http.status == 200)){
            var response = http.responseText;
//            window.alert(response);
	  
            if (response == 0) {
			email_exists = false;
            }
            else {
			email_exists = true;
            }
        }
    }
    catch(e){}
    finally{}
}



function ajax_getUserByName()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
//  window.alert(response);
            document.getElementById('recip_id').value = response;
        }
    }
    catch(e){}
    finally{}
}

function ajax_timePointAward()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
	    //setTimeout('resetTimer(' + response + ')', 2000);        
	    setTimeout('resetTimer(600)', 4000);
        
        var date = new Date();
        sendRequestTextGet('ajax_point_update.html', 'cachebust=' + date.getTime(), 'ajax_pointUpdate');
        }
    }
    catch(e){}
    finally{}

//  window.alert(response);

}

function ajax_petChatUpdate()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
          var response = http.responseText;
          var re = new RegExp('^<!-- chat -->');
          if (response.match(re))
		        document.getElementById('pet_chat_window').innerHTML = response;
        }
    }
    catch(e){}
    finally{}
}

function ajax_pointUpdate()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
		  	  var points = response;
		      document.getElementById('header_point_total').innerHTML = points  + ' CD';
        }
    }
    catch(e){}
    finally{}
}

function ajax_ratingUpdate() {
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
            eval("Data = " + response);
            if (!Data['avg_rating']) return true;
            //alert (Data);
            if (document.getElementById(Data['photo_id'] + '_avg_rating'))
              document.getElementById(Data['photo_id'] + '_avg_rating').innerHTML = Data['avg_rating'];
            if (document.getElementById(Data['photo_id'] + '_num_votes'))
              document.getElementById(Data['photo_id'] + '_num_votes').innerHTML = Data['num_votes'];
            rating = Math.ceil ( Data['avg_rating'] * 2) / 2;
            for (i = 1; i <= 5; i++) {
              img = document.getElementById(Data['photo_id'] + '_rating_' + i);
              if (rating >= i) img.name = 'star-rated';
              else if (rating >= i - 0.5) img.name = 'star-half';
              else img.name = 'star-blank';

              img.src = 'profile/' + img.name + '.gif';
              document.getElementById(Data['photo_id'] + '_ratinghref_' + i).onclick = function() { return false; };
              img.onmouseover = function() { };
              img.onmouseout = function() { };
            }
		      //document.getElementById('header_point_total').innerHTML = points  + ' CD';
        }
    }
    catch(e){}
    finally{}

    //alert (response);
}

function ajax_timeLeftUpdate()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
			timeLeft = response;
			resetTimer(timeLeft);
        }
    }
    catch(e){}
    finally{}
}

function ajax_changeLogin()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
		  	  var loginBoxHTML = response;
		      document.getElementById('ajaxafied_login').innerHTML = loginBoxHTML;
       }
    }
    catch(e){}
    finally{}
}

function ajax_changeLeaderBoard()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
		  	  var leadersDisplay = response;
		      document.getElementById('main_leaders_div').innerHTML = leadersDisplay;
       }
    }
    catch(e){}
    finally{}
}

function ajax_changeMyCdeLeaderBoard()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
		  	  var myCdeLeadersDisplay = response;
		      document.getElementById('myCDE_leaders').innerHTML = myCdeLeadersDisplay;
       }
    }
    catch(e){}
    finally{}
}

function ajax_ApproveDesign()
{
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
		  	  var approveDesign = response;
		      
       }
    }
    catch(e){}
    finally{}
}


function createRequestObject() {
    var xmlhttp;
    try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e) {
        try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
        catch(f) { xmlhttp=null; }
    }
    if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
        xmlhttp=new XMLHttpRequest();
    }

   return  xmlhttp;
}


function sendRequestTextGet(script_name, vars, response_handler) {
//  alert(script_name);
    var rnd = Math.random();
//    vars = escape(vars);
//    window.alert(script_name + ', ' + vars + ', ' + response_handler);
//    window.alert(vars);
var date = new Date();
if (vars.length == 0)
{
vars = "cachebust=" + date.getTime();
} else vars += "&cachebust=" + date.getTime();



//alert(vars);



    try{
        http.open('GET',  script_name + '?' + vars);
        http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

        // Note: (Keith Brings) these if's should be daisy chained to improve efficiency.

	switch(response_handler)
        {
	case 'ajax_petChatUpdate':
        http.onreadystatechange = ajax_petChatUpdate;	
	break;
	
	case 'ajax_pointUpdate':
        http.onreadystatechange = ajax_pointUpdate;
        break;

        case 'ajax_getUserByName':
        http.onreadystatechange = ajax_getUserByName;
        break;

        case 'ajax_timePointAward':
        http.onreadystatechange = ajax_timePointAward;
        break;

        case 'ajax_ratingUpdate':
        http.onreadystatechange = ajax_ratingUpdate;
        break;

        case 'ajax_checkIinvite':
        http.onreadystatechange = ajax_checkIinvite;
        break;

        case 'ajax_isKosher_fs':
        http.onreadystatechange = ajax_isKosher_fs;
        break;

        case 'ajax_isKosher':
        http.onreadystatechange = ajax_isKosher;
        break;

        case 'ajax_checkEmail':
        http.onreadystatechange = ajax_checkEmail;
        break;

        case 'ajax_checkReferrer':
        http.onreadystatechange = ajax_checkReferrer;
        break;

        case 'ajax_checkUserName':
        http.onreadystatechange = ajax_checkUserName;
        break;

       case 'ajax_changeLogin':
        http.onreadystatechange = ajax_changeLogin;
        break;

        case 'ajax_getInternalAd':
        http.onreadystatechange = ajax_getInternalAd;
        break;
        
        case 'ajax_Leaderboards':
        http.onreadystatechange = ajax_changeLeaderBoard;
        break;
        
        case 'ajax_myCdeLeaderboard':
        http.onreadystatechange = ajax_changeMyCdeLeaderBoard;
        break;
        


	default:
	//http.onreadystatechange = handleResponseText;
	break;

	}
        http.send(null);
    }
    catch(e){}
    finally{}
}


function handleResponseText() {
    try{
        if((http.readyState == 4)&& (http.status == 200)){
            var response = http.responseText;
            if (response == 0) {

            }
            window.alert(response);
        }
    }
    catch(e){alert("hello");}
    finally{}
}

function ajax_getInternalAd() {


}

