// hover fix plugin
/*jQuery.fn.fixHover.js : for all elements, add hover class on mouseover and remove on mouseout */
jQuery.fn.fixHover = function() {
	$(this).each(function() {
		var hoverClasses = ' hover';
		if($(this).attr('class')) {		
			var classes = $(this).attr('class');
			var classArray = classes.split(' ');
			$(classArray).each(function(){
				hoverClasses += ' ' + this + 'Hover';
			});
		}
		$(this).hover(
			function(){
				if(classes) $(this).attr('class', classes + hoverClasses);
				else $(this).addClass('hover');
			},
			function(){
				if(classes) $(this).attr('class', classes);
				else $(this).removeClass('hover');
			}
		);
	});
};

jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();


function slideSwitch() {
		$('#slideshow div[class!=active]').animate({opacity: 0.0}, 300);
    var $active = $('#slideshow div.active');

    if ( $active.length == 0 ) $active = $('#slideshow div:last');

    var $next =  $active.next().length ? $active.next() : $('#slideshow div:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}

$(document).ready(function(){ 
		// fix hover states : CSS3 feature
		$("#demo .bottom p").fixHover();
		$("#demo .bottom .last p").fixHover();
		// hide button text
		$(".submit, .validate").val("");
		// fix broken IE6
		$("img").pngfix();
		$("#coming-soon").pngfix();
}); 

var newWindow;
function popupWindow(slideshow,xmlpath,title,width,height)
{
	newWindow = window.open("/view.php?slideshow=" + slideshow + "&xmlpath=" + xmlpath + "&title=" + title + "","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height + ",left=" + (screen.width - width)/2 + ",top=" + (screen.height - height)/2 + "");
}

