/*
Common Library Functions 
*/

function validURL(url) {
	var v = new RegExp();
	v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	if (!v.test(url)) { return false;	}
	else { return true; }
} 
function limitTo(el,limit) {
	if (el.value.length > limit)
	el.value = el.value.substring(0, limit);
}
function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

var Accordion = Class.create();

Accordion.prototype = {
	initialize: function(id, tag, name) {
		this.id = id;
		this.headerTag = tag.toUpperCase();
		this.instance = name;
		this.headingClassName = (arguments[3] || "panel");
		this.contentClassName = (arguments[4] || "panelBody");
		this.panels = new Array();

		var tags = $(id).getElementsByTagName('*');		
		for ( var i = 0; i < tags.length; i++) {
			switch(tags.item(i).tagName) {
				case this.headerTag:
					tags.item(i).onclick = this._returnEvalCode(this.instance);
					break;

				default:
					if (Element.hasClassName(tags.item(i), this.headingClassName)) {
						tags[i]._index = this._returnIndex(this.panels.length);
						this.panels[this.panels.length] = tags.item(i);
						//the line above is same meaning as "this.panels.push(tags.item(i));"
						if (this.panels.length == 2) {
							tags.item(i).id = "visible";	
							var h3s = tags.item(i).getElementsByTagName('h3');
							var contractP = tags.item(i).getElementsByTagName('span');
							for( var i=0; i<h3s.length; i++){
								Element.addClassName(h3s.item(i),'acc-contract');
								Element.addClassName(contractP.item(i),'span-contract');
							}
						}
					}
					if (Element.hasClassName(tags.item(i), this.contentClassName)) {
						tags.item(i).style.display = "none";
					}
					break;

			}
		}
		this.length = this.panels.length;
		this.show(0, true);
	},

	show: function(index, force) {
		if ( (index >= this.length) || (index < 0) ) {
			return;
		}

		if ( $('visible') == this.panels[index] ){
			if (force) {
				for(var i = 0; i < this.length; i++) {
					if(this._body(this.panels[i]).style.display != "none") { new Effect.SlideUp(this._body(this.panels[i])); }
				}
				new Effect.SlideDown(this._body(this.panels[index]));
				return;
			}
			return;
		}

		new Effect.Parallel(
			[
				new Effect.SlideUp( this._body($('visible')) ),
				new Effect.SlideDown( this._body(this.panels[index]) )
			], {
				duration: 0.2
			}
		);
		var h3s_a = $('visible').getElementsByTagName('h3');
		var contractP_a = $('visible').getElementsByTagName('span');
		for( var i=0; i<h3s_a.length; i++){
			Element.removeClassName(h3s_a.item(i),'acc-contract');
			Element.removeClassName(contractP_a.item(i),'span-contract');
		}
		$('visible').id = "";
		this.panels[index].id = "visible";
		var h3s_b = this.panels[index].getElementsByTagName('h3');
		var contractP_b = this.panels[index].getElementsByTagName('span');
		for( var i=0; i<h3s_b.length; i++){
			Element.addClassName(h3s_b.item(i),'acc-contract');
			Element.addClassName(contractP_b.item(i),'span-contract');
		}
		return;
	},

	_body: function(e) {
		var tags = e.getElementsByTagName('*');
		for( var i=0; i<tags.length; i++) {
			if (Element.hasClassName(tags.item(i), this.contentClassName)) { return tags.item(i); }
		}
	},

	_returnIndex: function(i) {
		return function() { return i; }
	},

	_returnEvalCode: function(s) {
		return function(){ eval(s + ".show(" + this.parentNode._index() + ");"); }
	}
};

/*sfHover = function() {
	if($("main")){
		var sfEls = document.getElementById("main").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() { 
				Element.addClassName(this,'sfhover');
			}
			sfEls[i].onmouseout=function() { 
				Element.removeClassName(this,'sfhover')
			}
		}
	}
}*/

sfHover = function() {
	if($("main")){
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
	}
}

hoverSf = function() {
	if($("feat-group-others-more")){
		var sfEls = document.getElementById("feat-group-others-more").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() { 
				Element.addClassName(this,'fshover');
				Element.addClassName(this.childNodes[0],'mrchover');
			}
			sfEls[i].onmouseout=function() { 
				Element.removeClassName(this,'fshover')
				Element.removeClassName(this.childNodes[0],'mrchover');
			}
		}
	}
}

var Fabtabs = Class.create();

Fabtabs.prototype = {
	initialize : function(element) {
		this.element = $(element);
		var options = Object.extend({}, arguments[1] || {});
		this.menu = $A(this.element.getElementsByTagName('a'));
		this.show(this.getInitialTab());
		this.menu.each(this.setupTab.bind(this));
	},
	setupTab : function(elm) {
		Event.observe(elm,'click',this.activate.bindAsEventListener(this),false)
	},
	activate :  function(ev) {
		var elm = Event.findElement(ev, "a");
		Event.stop(ev);
		this.show(elm);
		this.menu.without(elm).each(this.hide.bind(this));
	},
	hide : function(elm) {
		$(elm).removeClassName('active-tab');
		Element.removeClassName($(elm).parentNode,'active-tab-li');
		$(this.tabID(elm)).removeClassName('active-tab-body');
	},
	show : function(elm) {
		$(elm).addClassName('active-tab');
		//elm.parentNode.addClassName('active-tab-li');
		Element.addClassName($(elm).parentNode,'active-tab-li');
		//Element.addClassName($('bus_profile').parentNode,'formError');
		$(this.tabID(elm)).addClassName('active-tab-body');

	},
	tabID : function(elm) {
		return elm.href.match(/#(\w.+)/)[1];
	},
	getInitialTab : function() {
		if(document.location.href.match(/#(\w.+)/)) {
			var loc = RegExp.$1;
			var elm = this.menu.find(function(value) { return value.href.match(/#(\w.+)/)[1] == loc; });
			return elm || this.menu.first();
		} else {
			return this.menu.first();
		}
	}
	
}



var Cookiejar = Class.create();
Cookiejar.prototype = {
	jar: {},
	jarname: "jar",
	expiration: 1 * 365 * 24 * 60 * 60 * 1000,
	dividerElement: "#",
	dividerIdValue: ":",
	path: "",
	domain: null,
	secure: false,

  initialize: function(jarname, path) {
  	this.jarname = jarname;
  	this.path = path;
  	this._read();
  },

  cookieExists: function(c_id) {	
    if (c_id == "") return false;
  	return !isUndefined(this.jar[c_id]);
  },

  delCookie: function(c_id) {
    delete this.jar[c_id];
  	this._write();
  },
			
  setCookie: function(c_id, c_value) {
  	this.jar[c_id] = c_value;
  	this._write();
  },

  getCookie: function(c_id) {	
    return this.jar[c_id] || null;
  },

  reset: function() {
  	this.jar = {};
  	Cookie.remove(this.jarname, this.path, this.domain);
  },

  setExpiration: function(years, days, hours, mins, secs, mill) {
    this.expiration =
	             (((years) ? (years) : 1)   * 365 * 24 * 60 * 60 * 1000) +
	  				   (((days)  ? (days)  : 365) * 24 * 60 * 60 * 1000) +
	  				   (((hours)  ? (hours) : 24) * 60 * 60 * 1000) +
					     (((mins)  ? (mins)  : 60)  * 60 * 1000 ) +
					     (((secs)  ? (secs)  : 60)  * 1000) +
					     ((mill)  ? (mill)   : 1000);
   	this._write();					
  },

  _read: function() {
    var cookiestring = Cookie.get(this.jarname) || "";
    cookiestring.split(this.dividerElement).each(
      function(pair){
        pair = pair.split(this.dividerIdValue);
        this.jar[pair[0]] = pair[1];
      }.bind(this)
    );
  },

  _write: function() {
  	var dateObj = new Date();
  	dateObj.setTime(dateObj.getTime() + this.expiration);

  	var base = new Date(0);
      var skew = base.getTime();
      if (skew > 0)
         dateObj.setTime(dateObj.getTime() - skew);

    var cookiestring = "";
    for (var i in this.jar){
      cookiestring += this.dividerElement + encodeURIComponent(i) +
this.dividerIdValue + encodeURIComponent(this.jar[i]);
    }
    Cookie.set(this.jarname, cookiestring, dateObj, this.path,
this.domain, this.secure);

  }
};

var Cookie = {
  get: function(name){
    if(typeof (document.cookie) == 'string'){
      var start = document.cookie.indexOf(name+"=");
      var len = start+name.length+1;
      if ((!start) && (name != document.cookie.substring(0,name.length))){
        return null;
      }
      if (start == -1) return null;
      var end = document.cookie.indexOf(";",len);
      if (end == -1) end = document.cookie.length;
      return decodeURIComponent(document.cookie.substring(len,end));
    } else {
      /* document.cookie is not a string so return an
      empty string. When tested this will type-convert to
      boolean false (accurately) giving the impression that
      client-side cookies are not available on this system:-
      */
      return "";
    }
  },

  set: function(name, value, expires, path, domain, secure) {
    if(typeof (document.cookie) == 'string'){
      document.cookie = name + "=" + encodeURIComponent(value) +
            ( (expires) ? ";expires=" + expires.toGMTString() : "") +
            ( (path) ? ";path=" + path : "") +
            ( (domain) ? ";domain=" + domain : "") +
            ( (secure) ? ";secure" : "");
    }//else document.cookie is not a string so do not write to it.
  },

  remove: function(name, path, domain) {
    if (this.get(name)) {
      document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }
};

function limitTo(el,limit) {
	if (el.value.length > limit)
	el.value = el.value.substring(0, limit);
}

function validURL(url) {
	var v = new RegExp();
	v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	if (!v.test(url)) { return false;	}
	else { return true; }
} 

function testFileType() {
	fileName = $('uploadfoto').value;
	fileTypes = new Array ('.gif', 'jpg', 'png', 'jpeg');
	if (!fileName) return;
	dots = fileName.split(".")
	fileType = "." + dots[dots.length-1];
	if(fileTypes.join(".").indexOf(fileType.toLowerCase()) != -1){ 
		$('previewFoto').innerHTML = ''; xxx='file://localhost/' + fileName; xxx=xxx.toLowerCase();
		
		if (xxx.substring(0,xxx.lastIndexOf('.png'))||xxx.substring(0,xxx.lastIndexOf('.jpg'))||xxx.substring(0,xxx.lastIndexOf('.jpeg'))||xxx.substring(0,xxx.lastIndexOf('.gif'))){
			var img=document.createElement('img'); img.setAttribute('src',xxx); img.setAttribute('width',150); img.setAttribute('height',150); //$('previewFoto').appendChild(img);
		}
		Element.removeClassName($('uploadfoto').parentNode,'formError');
		$('fotoValidateIE').value = '1';
	}else{
		$('uploadfoto').value = '';
		$('fotoValidateIE').value = '0';	
		Element.addClassName($('uploadfoto').parentNode,'formError');
		alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
	}
}

function loadUploadIframe(){
	if($('uploadPhotoFrame')){
		var iframe = '<ifr'+'ame width="0" height="0" name="uploadFrame" id="uploadFrame" src="" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; "></ifr'+'ame>';
		new Insertion.Bottom('uploadPhotoFrame', iframe); 
		
		if($('uploadphotoformbt')) $('uploadphotoformbt').disabled = false;
	}
}

function showContent(event){
	urchinTracker("clicks"+chnnl+"/blogs-rotate");
	var obj = document.getElementsByClassName("vis");
	var view = obj['0'].id;
	var content = view.substr(7);
	//alert(content);
	if(event == "next"){
		
		if(content < 3){
			content++;
			//alert($(view));
			Element.removeClassName($(obj['0'].id),'vis');
			document.getElementById(obj['0'].id).style.display = "none";
			$('content'+content).addClassName('vis');
			new Effect.Appear("content"+content);
		}else{
			content++;
			Element.removeClassName($(obj['0'].id),'vis');
			document.getElementById(obj['0'].id).style.display = "none";
			$('content1').addClassName('vis');
			new Effect.Appear("content1");
		}
	}else{
		if(content > 1){
			content--;
			Element.removeClassName($(obj['0'].id),'vis');
			document.getElementById(obj['0'].id).style.display = "none";
			$('content'+content).addClassName('vis');
			new Effect.Appear("content"+content);
		}else{
			content--;
			Element.removeClassName($(obj['0'].id),'vis');
			document.getElementById(obj['0'].id).style.display = "none";
			$('content3').addClassName('vis');
			new Effect.Appear("content3");
		}
	}
//	alert(view);
}

var album = { 
		
  startup: function() { 
	 
     this.ajaxUpdate = new PeriodicalExecuter(album.cycle, 5) // change image every 5 seconds 
    
    
  }, 
  
  cycle: function() {
	  var totalitem = $F('totalitem');
	  //alert(totalitem);
	  
	  Element.hide('flashbox-' + cont);
	  Element.removeClassName($('flashbox-a-' + cont),'highlight');
	  Element.hide('video-desc-' + cont);
	  //Element.removeClassName($('flash-h3-' + cont),'highlighted');
	  cont ++;
	  //if(cont === totalitem) cont = 1;
	  if(cont == totalitem){
		  cont = 1;
	  }
	  
	  Element.show('flashbox-' + cont);
	  Element.addClassName($('flashbox-a-' + cont),'highlight');
	  Element.show('video-desc-' + cont);
	  //album.slide_horiz();
	  
	  //Element.addClassName($('flash-h3-' + cont),'highlighted');
    
  }, 
  
  stop: function(){
	  this.ajaxUpdate.stop();
  },
  slide_horiz: function(){
	  new Spry.Effect.Slide('flashbox-' + cont, {horizontal: true, toggle: true});
  }
}

function stopandpick(viewcont){
	album.stop();
	var objid = document.getElementsByClassName("highlight");
	var viewid = objid['0'].id;
	
	var contentid = viewid.substr(11);
	
	Element.removeClassName("flashbox-a-"+contentid, "highlight");
	//Element.removeClassName("flash-h3-"+contentid, "highlighted");
	document.getElementById("flashbox-"+contentid).style.display = "none";
	Element.addClassName("flashbox-a-"+viewcont, "highlight");
	//Element.addClassName("flash-h3-"+viewcont, "highlighted");
	Element.show("flashbox-"+viewcont);
}

function setPick(viewcont){
	//alert($('checkChecker').value);
	//alert(viewcont);
	$('pickedID').value = viewcont;
	if($('checkChecker').value == 1){
		$('checkChecker').value = 2;
		stopandpick(viewcont);
		
		//Element.removeClassName("flashbox-a-"+viewcont, "highlight");
	}
	
	var i=1;
	for (i=1;i<=5;i++){
		//alert(i);
		if(viewcont == i){
			Element.show('video-desc-'+i);
		}else{
			Element.hide('video-desc-'+i);
		}
	}
}

function resetPick(viewcont2){
	//alert(viewcont);
	//Element.removeClassName("flashbox-a-"+viewcont, "highlight");
	if(viewcont2 != $('pickedID').value){
		//$('checkChecker').value = 2;
		if($('checkChecker').value == 2 && $('pickedID').value != ''){
			//Element.removeClassName("flashbox-a-"+$('pickedID').value, "highlight");
			$('checkChecker').value = 1;
			cont = $('pickedID').value; album.startup();
			$('pickedID').value = "";
		}
	}
}

function pickFave(viewcont){
	urchinTracker("clicks"+chnnl+"/pick-fn-fave");
	var objid = document.getElementsByClassName("show");
	var viewid = objid['0'].id;
	
	var contentid = viewid.substr(8);
	
	Element.removeClassName("li-fave-"+contentid, "show");
	Element.hide("fave-"+contentid);
	Element.addClassName("li-fave-"+viewcont, "show");
	Element.show("fave-"+viewcont);
}

/*** Tagboard functions ****/
function tb_msg() {
	urchinTracker("clicks"+chnnl+"/submit-shoutout");
	var showResponse = function (originalRequest) { 
		if(trim(originalRequest.responseText) != 0){ 
			$('tb_screen').innerHTML = '<div id="myfn_tagboard">'+originalRequest.responseText+'</div>';
		}
	};
	
	var showProgress = function () { $('span_feed').innerHTML = 'Loading'; }
	parameter = Form.serialize('frm_tagboard');		
	var url = publicdomainobj + "myfn/tb.php";
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: parameter, onComplete: showResponse});			
	//new Effect.BlindUp($('dv_frm_tb'));			
	//$('btn_blind').value = "Post";		
	//winDirection="grow";	
	$('shout_msg').value = "";
}

function check_shout(frm, condition){
	urchinTracker("clicks"+chnnl+"/check-shoutout");
	//var shout_msg = trimString (getElementById('shout_msg').value);
	var shout_msg = $('shout_msg').value;
	if(condition == 1){
		if (shout_msg != "") {
			tb_msg(frm);		
		} else {
			alert("Please enter your message");	
		}
	}else{
		Element.hide('span_feed');
		Effect.Appear('alert-shoutout');
	}
	return false;		
}//end check_shout

function get_shouts() {
	urchinTracker("clicks"+chnnl+"/get-shouts");
	var showResponse = function (originalRequest) { 
		if(trim(originalRequest.responseText) != 0){ 
			$('tb_screen').innerHTML = '<div id="myfn_tagboard">'+originalRequest.responseText+'</div>';
		}
	};
	var showProgress = function () { $('tb_screen').innerHTML = 'Loading'; }
	//, onLoading: showProgress
	var url = publicdomainobj + "myfn/get_shouts.php";
	var myAjax = new Ajax.Request( url,	{method: 'get', onComplete: showResponse});
}

function reportProfanity(msg)
{
	urchinTracker("clicks"+chnnl+"/report-shoutout");
	var showResponse = function (originalRequest) { 
		if(trim(originalRequest.responseText) != 0){ 
			$('tb_screen').innerHTML = originalRequest.responseText;
		}
	};
	var showProgress = function () { $('tb_screen').innerHTML = 'Loading'; }
	//, onLoading: showProgress
	parameter = "?msg="+msg;
	var url = publicdomainobj + "myfn/boardReporter.php";
	var myAjax = new Ajax.Request( url,	{method: 'get',asynchronous: 'false', parameters: parameter, onComplete: showResponse});	
}

/*function sendComment(){
	//alert(1);
	var showResponse = function (originalRequest) {
		$('contact-form').innerHTML = originalRequest.responseText; 
	};
	var showProgress = function () { $('contact-form').innerHTML = '&nbsp;In progress...'; }
	inputs = Form.getElements( 'sendcomment' );
	var err = 0;
	var j = 0;
	for(var i = 1; i < inputs.length; i++){
		if((Element.hasClassName(inputs[i],'required'))&&(trim(inputs[i].value) == '')){
			err++;
			Element.addClassName(inputs[i].parentNode,'formError');
		}else{
			Element.removeClassName(inputs[i].parentNode,'formError');
		}
		j++;
	}
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
//	alert($F('email'));
	if(filter.test($F('contact_email'))){ Element.removeClassName($('contact_email'),'formError')}
	else{alert('The email address you entered is invalid. \n\n Please enter a valid email address.'); err++; Element.addClassName($('contact_email'),'formError')}
	if(trim($('lname').value) == ''){ Element.addClassName($('lname'),'formError'); err++; }
	else Element.removeClassName($('contact_email'),'formError');
	if(trim($('contact_email').value) == ''){ Element.addClassName($('contact_email'),'formError'); err++; }
	else Element.removeClassName($('contact_name'),'formError');
	if(trim($('contact_name').value) == ''){ Element.addClassName($('contact_name'),'formError'); err++; }
	else Element.removeClassName($('contact_city'),'formError');
	if(trim($('contact_city').value) == ''){ Element.addClassName($('contact_city'),'formError'); err++; }
	else Element.removeClassName($('contact_country'),'formError');
	if(trim($('contact_country').value) == ''){ Element.addClassName($('contact_country'),'formError'); err++; }
	else Element.removeClassName($('contact_country'),'formError');
	if(trim($('contact_subject').value) == ''){ Element.addClassName($('contact_subject'),'formError'); err++; }
	else Element.removeClassName($('contact_subject'),'formError');
	if(trim($('contact_comment').value) == ''){ Element.addClassName($('contact_comment'),'formError'); err++; }
	else Element.removeClassName($('contact_comment'),'formError');
	
	if (err != 0){
		alert('You have not filled out all the required fields correctly. \n\n Please submit the required information.');
	}else{
		parameter = Form.serialize( 'sendcomment' );
		var url = publicdomainobj + "contact-process.xml.php";
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: parameter, onComplete: showResponse, onLoading: showProgress });		
	}
}*/

function userInquire(){
	var showResponse = function (originalRequest) {
		$('inquirecontent').innerHTML = originalRequest.responseText;
		//alert("Message Sent.");
		location.href = '/index.php?channel=contact-us';
	};
	var showProgress = function () { $('inquirecontent').innerHTML = '&nbsp;In progress...'; }
	inputs = Form.getElements( 'regInquire' );
	var err = 0;
	var j = 0;
	for(var i = 1; i < inputs.length; i++){
		if((Element.hasClassName(inputs[i],'required'))&&(trim(inputs[i].value) == '')){
			err++;
			Element.addClassName(inputs[i].parentNode,'formError');
		}else{
			Element.removeClassName(inputs[i].parentNode,'formError');
		}
		j++;
	}
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
//	alert($F('email'));
	if(filter.test($F('contact_email'))){ Element.removeClassName($('contact_email'),'formError')}
	else{alert('The email address you entered is invalid. \n\n Please enter a valid email address.'); err++; Element.addClassName($('contact_email'),'formError')}
	if(trim($('contact_name').value) == ''){ Element.addClassName($('contact_name'),'formError'); err++; }
	else Element.removeClassName($('contact_name'),'formError');
	if(trim($('contact_email').value) == ''){ Element.addClassName($('contact_email'),'formError'); err++; }
	else Element.removeClassName($('contact_email'),'formError');
	if(trim($('contact_city').value) == ''){ Element.addClassName($('contact_city'),'formError'); err++; }
	else Element.removeClassName($('contact_city'),'formError');
	if(trim($('country_id').value) == ''){ Element.addClassName($('country_id'),'formError'); err++; }
	else Element.removeClassName($('country_id'),'formError');
	if(trim($('contact_subject').value) == ''){ Element.addClassName($('contact_subject'),'formError'); err++; }
	else Element.removeClassName($('contact_subject'),'formError');
	if(trim($('contact_comment').value) == ''){ Element.addClassName($('contact_comment'),'formError'); err++; }
	else Element.removeClassName($('contact_comment'),'formError');
	
	if (err != 0){
		alert('You have not filled out all the required fields correctly. \n\n Please submit the required information.');
	}else{
		parameter = Form.serialize( 'regInquire' );		
		var url = "./objects/contact-process.xml.php";//publicdomainobj + 
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: parameter, onComplete: showResponse, onLoading: showProgress });		
	}
}

function showImageFull(filename) {
	//var err = 0;
	var showResponse = function (originalRequest) { 
		$('photo-full').innerHTML = originalRequest.responseText;
	};
	var showProgress = function () { $('photo-full').innerHTML = '&nbsp;In progress...'; }
	
	parameter = "filename="+filename;
	var url = "./objects/gallery-load-img.xml.php";
	var myAjax = new Ajax.Request( url,	{method: 'get', parameters: parameter, onComplete: showResponse, onLoading: showProgress});
}

function submitArticleSearch() {
	if((trim($('searchKey').value) == '') || (trim($('searchKey').value) == 'Search our website!')){
		alert('Please enter a keyword.');
		return false;
	}else{
		return true;	
	}
}

/* jasper function start*/

function submitNewsletter() {
	if((trim($('newsletterKey').value) == '') || (trim($('newsletterKey').value) == 'Subcribe to our newsletter')){
		alert('Please enter your email address.');
		return false;
	}else{
		return true;	
	}
}
/* jasper function end */
/*function showVideoFull(filename) {
	//var err = 0;
	var showResponse = function (originalRequest) { 
		$('fullvideo-container').innerHTML = originalRequest.responseText;
	};
	var showProgress = function () { $('fullvideo-container').innerHTML = '&nbsp;In progress...'; }
	
	parameter = "filename="+filename;
	var url = "./objects/gallery-load-vid.xml.php";
	var myAjax = new Ajax.Request( url,	{method: 'get', parameters: parameter, onComplete: showResponse, onLoading: showProgress});
}*/

function chkFOTW(id){
	//alert(id);

	var showResponse = function (originalRequest) { 
		$('fighters-list').innerHTML = originalRequest.responseText;
		location.href = '/admin/tools/fighters/manager.php';
	};
	var showProgress = function () { $('fighters-list').innerHTML = '&nbsp;In progress...'; }
	
	parameter = "id="+id;
	var url = "fotw.xml.php";
	var myAjax = new Ajax.Request( url,	{method: 'get',asynchronous: 'false', parameters: parameter, onLoading: showProgress, onComplete: showResponse});
	
}

function init(){
	sfHover();
	
	if($("flashbox")){
	//	var cont = 1;
		//var cont2 = 2;
		album.startup();
	}
	
	if($("photos-official")) initscroll2('photos-official');
	//if($("sendComment")) Event.observe('sendComment', 'click', sendComment, false);
	if($("userInquire")) Event.observe('userInquire', 'click', userInquire, false);
	
	loadUploadIframe();
	
	//Shadowbox.init();
}

Event.observe(window, 'load', init);