// JQuery doover v 0.33 module - to make rollovers by Elennaro
/*
* jQuery 1.3 or higher required
*
* It's Simple to use
* Add class="doover" to the  tag containing the image.
* Than add to your Images folder the hover images with imagename+1 format
* For example if your normal state image is "image.png" add "image1.png" for over state in the same folder
* Or you can place the path to the hover image  to 'rel' attribute (rel='img:path/image_to_over.jpg') of a  tag <a>
* For example <a href="#" rel='img:path/image_to_rollover.png' class='doover'><img src='image.png' /></a>
* 
* NOTE! The image should be placed directly after the  tag (see below) wihout any spaces or linebrakes!!!
*  <a href="#" class='doover'><img src='image.png' /></a>
*
* After version 0.31 no more png fix plugins required to make this script work with transparent pngs PNG at IE lt 7
* It works normally with the Filter PNG Alpha Fix v2.0 Alpha by Angus Turnbull http://www.twinhelix.com
* It's not good for jQuery ifixpng (some flicks of white bg befor alpha filter applies)
* I did not checked it with oher Alpha image filter based PNG fixes...
*
* Elennaro: elennaro@mail.ru (2009)
*
*/
jQuery(document).ready(function() {
								
//Preloading all the images for hovers
//Not realised Yet

//var srcimg;
var itspng = false;

//doover
jQuery("a.doover").hover(function() { 
		//a - path to the image		
		var a;
		//B - contents of rel
		var b = jQuery(this).attr('rel');			
		// IE6 Fix PNG
		if (jQuery.browser.msie && jQuery.browser.version < 7 && this.childNodes[0].style.filter.lastIndexOf('.png') >0) {
			itspng = true;
			//px - 1 pixel image src for Png Fixes
			px = this.childNodes[0].src;
			//oft - old filter
			oft = this.childNodes[0].style.filter;
			//a - old img src
			a = oft.substring(oft.lastIndexOf('src=')+5, oft.lastIndexOf('.png')+4);
		} else { a = this.childNodes[0].src; }
		//srcimg - will be the old source for img
		srcimg = a;
		// If rel Attribute exist:
		if ( b.indexOf('img:') > -1){
			a = b.substring(4);
		} else {
		//Adding '1' to image name		
		a = (a.substring(0, a.lastIndexOf('.')))+'1'+(a.substring(a.lastIndexOf('.'),a.length));	
		}	
		//Applying new src to image	
		this.childNodes[0].src = a;
		//Applying Filter to img
		if (itspng) {
			// al - new filter
			al = oft.substring(0, oft.lastIndexOf('src=')+5) + a + oft.substring(oft.lastIndexOf('.png')+4);
			//alert(a);
			//alert(al);
			jQuery(this.childNodes[0]).css({filter: al}).attr({src:px});
		}
		//alert("Hello world!"+a);
   }, function () { //rollout
   		this.childNodes[0].src = srcimg;
   		if (itspng){
			jQuery(this.childNodes[0]).css({filter: oft}).attr({src:px});
		}
		itspng = false;
});
});