/*
Page:           functions.js
Created:        Nov 15 2006
Modified:       Nov 13 2007
For a little AJAX trickery
--------------------------------------------------------- 
ryan masuga, masugadesign.com
ryan@masugadesign.com 
--------------------------------------------------------- */
var xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

// function sndReq(vote,id_num,ip_num,units) {
// 	var theBigPic = document.getElementById('unit_ul'+id_num); // the UL
// 	
// 	// switch UL with a loading div
// 	theUL.innerHTML = '<div class="loading"></div>';
// 	
//     xmlhttp.open('get', 'rpc.php?j='+vote+'&q='+id_num+'&t='+ip_num+'&c='+units);
//     xmlhttp.onreadystatechange = handleResponse;
//     xmlhttp.send(null);	
// }

//function handleResponse() {
//  if(xmlhttp.readyState == 4){
//		if (xmlhttp.status == 200){
//       	
//        var response = xmlhttp.responseText;
//        var update = new Array();
//
//        if(response.indexOf('|') != -1) {
//            update = response.split('|');
//            changeText(update[0], update[1]);
//        }
//		}
//    }
//}


/* http://brothercake.com/site/resources/scripts/domready/
**************************************************************************/
function domFunction(f, a) {
	var n = 0;
	var t = setInterval(function() {
		var c = true;
		n++;
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)) {
			c = false;
			if(typeof a == 'object') {
				for(var i in a) {
					if((a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)) { 
						c = true; 
						break; 
					}
				}
			}
			if(!c) { f(); clearInterval(t); }
		}
		if(n >= 60) {
			clearInterval(t);
		}
	}, 250);
};

/*
 * cssjs
 * written by Christian Heilmann (http://icant.co.uk)
 * eases the dynamic application of CSS classes via DOM
 * parameters: action a, object o and class names c1 and c2 (c2 optional)
 * actions: swap exchanges c1 and c2 in object o
 *			add adds class c1 to object o
 *			remove removes class c1 from object o
 *			check tests if class c1 is applied to object o
 * example:	cssjs('swap',document.getElementById('foo'),'bar','baz');
 */

//function cssjs(a,o,c1,c2)
//{
//	switch (a){
//		case 'swap':
//			o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
//		break;
//		case 'add':
//			if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
//		break;
//		case 'remove':
//			var rep=o.className.match(' '+c1)?' '+c1:c1;
//			o.className=o.className.replace(rep,'');
//		break;
//		case 'check':
//			return new RegExp('\\b'+c1+'\\b').test(o.className)
//		break;
//	}
//}



/*
function externalLinks() 
{
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++)
 {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
   {
	 var oLink = anchors[i];
	   if(oLink.className.search(/noicon/) == -1)
	   { // find the non-noicon ones, and set a class of linkpic
	     anchor.setAttribute("class", "link_ext");
	   }
	 anchor.target = "_blank";
   }
  }
};


function lightboxLinks() 
{
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];

	var lBox = /lightbox/;
	var string1 = anchor.getAttribute("rel");
	var matchPos1 = string1.search(lBox);
	
   //if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "lightbox") {
   if (anchor.getAttribute("href") && (matchPos1 == -1)) {
	
	
	
	
	
	
	
	
	var oLink = anchors[i];
	// http://www.robertnyman.com/2006/03/23/ajax-javascript-and-accessibility/
	if(oLink.className.search(/noicon/) == -1){ // find the non-noicon ones, and set a class of linkpic
		anchor.setAttribute("class", "link_pic"); 
	}
	
	}
	
	
	
   }
 }
};

*/

/* Load the scripts
************************************************************************* */
var foobar = new domFunction(function() {
	//externalLinks();
	//lightboxLinks();
	});

