

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 270;	// maximum image size.

if (document.getElementById || document.all){
	document.write('<div id="tooltipimageid">');
	document.write('</div>');
}

function gettooltipobj(){
if (document.getElementById && document.getElementById("tooltipimageid"))
return document.getElementById("tooltipimageid").style
else if (document.all)
return document.all.tooltipimagid.style
}

function gettooltipobjnostyle(){
if (document.getElementById && document.getElementById("tooltipimageid"))
return document.getElementById("tooltipimageid")
else if (document.all)
return document.all.tooltipimagid
}


function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
var playerMouseOffset = 0;

function showtooltip(file,type,title,width,height,id, attr1,attr2,attr3,audiothumb){
	if(type == 'video') {
		if(width <= 0) {
			width = 300;
		}
		if(height > 0) {
			var factor = width / 300;
			if(factor != 0) {
				var new_height = height / factor;
				if(new_height > 100) {
					height = new_height;
				}
				else {
					height = 150;
				}
			}
			else {
				width = 300;
				height = 150;
			}
		}
		else {
			height = 150;
		}
		width = 300;
	}

	if (height > 0){
		currentimageheight = height+60;
		
	}
	
	watermark_x = parseInt((width-218)/2);
	watermark_y = parseInt((height-31)/2);

	document.onmousemove=followmouse;

	
	
	if(type=='text') {
		var html = '<table border="0" cellpadding="0" cellspacing="0">';
		html = html + '<tr><td  valign="top">';
	    html = html + '<table class="thin_text" >';
	    html = html + '<tr><td >';
		html = html + title + '</td></tr>';					
		html = html + '</table></td></tr></table>';
					
	} else {
		var html = '<div class = "thin" style = "width:'+width+'px;">';				

		if(type=='photo') {			
			html = html + '<img src = ' + file + ' width="'+width+'">';			
		}
		if(type=='video') {
			temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: black;">'
                    + '<a class="player" href="' + file + '" style="display:block;width:' + width + 'px;height:' + height + 'px;"></a>'
                    + '</div>';

		   html += temp;
		}
		if(type=='audio') {
			temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: white;width:266px;height:119px;" class="player">'
                    + '</div>';
				
			temp1 = '<div style="height:0px;">'
					+	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="0" height="0" id="434_player" align="middle">'
					+	'<param name="allowfullscreen" value="true" />'
					+	'<param name="allowscriptaccess" value="always" />'
					+	'<param name="allownetworking" value="all" />'
					+	'<param name="movie" value="http://mediastock.ca/players/audio.swf" />'
					+	'<param name="quality" value="high" />'
					+	'<param name="bgcolor" value="#000000" />'
					+	'<param name="FlashVars" value="file=http://mediastock.ca/downloads/MediastockWatermark.mp3" /> '
					+	'<embed FlashVars="file=http://mediastock.ca/downloads/MediastockWatermark.mp3" src="http://mediastock.ca/players/audio.swf" quality="high" bgcolor="#000000" width="0" height="0" name="434_player" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
					+	'</object>'
					+	'</div>';

			html += temp + temp1;		   
		}
					
		html = html + '<div style = "margin-top:5px;"><div style = "float:left;font-weight:bold;">'+title+'</div>';						 
		html = html + '<div style = "float:right;color:#999">#'+id+'</div></div>';
		html = html + '<div style = "clear:both;padding:0px">'+attr1+'<br>'+attr2+'<br>'+attr3+'</div>';  
		html = html + '</div>';
	}

	gettooltipobjnostyle().innerHTML = html;
	
	if(type=='video') {
		flowplayer("a.player", "/flowplayer.commercial-3.2.5.swf", {         		
			key: '#$39e2432b50d71ab3768',
			logo: {
				url: '/players/watermark.png',
				fullscreenOnly: false,
				displayTime: 0,
				top: watermark_y,
				right: watermark_x
			},
			clip: {
					autoPlay: true,
					autoBuffering: true,
					onBeforeFinish: function() {
						return false;
					}
			},
			canvas: {backgroundColor: "#48494b"},

			plugins: {
 				controls: null
			}
        });
		
	}
	if(type=='audio') {
		$f("div.player", "/flowplayer.commercial-3.2.5.swf", {
			key: '#$39e2432b50d71ab3768',
			playlist: [{url: audiothumb, duration: 0}, {url: file, onBeforeFinish: function(){ return false; }}],
			
			plugins: {    			
					controls: null
			},
			clip: {
					autoPlay: true,
					autoBuffering: true
			}
		});
	}
	gettooltipobj().visibility="visible";

}


function hidetooltip(){
	gettooltipobj().visibility="hidden"
	gettooltipobjnostyle().innerHTML=""
	document.onmousemove=""
	gettooltipobj().left="-500px"

}

function followmouse(e){

	if (typeof playerMouseOffset == 'undefined' ) {
			playerMouseOffset = 0;
	}
	
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]
	
	var offsetX = 320;
	var offsetY = 150;

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
	var scrolltop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	
	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 300){
			xcoord = e.pageX - xcoord - offsetX; 
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + offsetY)){
			if(scrolltop != 0){
				ycoord += e.pageY - Math.max(0,(offsetY + currentimageheight + e.pageY - docheight - scrolltop));
			}else{
				ycoord += e.pageY - Math.max(0,(offsetY + currentimageheight + e.pageY - docheight));
			}
			
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 300){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - offsetX; 
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + offsetY)){
			if(scrolltop != 0){
				ycoord += event.clientY + scrolltop - Math.max(0,(offsetY + currentimageheight + event.clientY - docheight));
			}else{
				ycoord += event.clientY + scrolltop - Math.max(0,(offsetY + currentimageheight + event.clientY - docheight));
			}
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
	ycoord -= playerMouseOffset;

	gettooltipobj().left=xcoord+"px"
	gettooltipobj().top=ycoord+"px"
}











function call_(url1, url2, url3, target1, target2, target3) {

    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {callDone_(target1, url2, target2, url3, target3);};
        req.open("GET", url1, true);
		
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {callDone_(target1, url2, target2, url3, target3);};
            req.open("GET", url1, true);
            req.send();
        }
    }
	
}    

function callDone_(target1, url2, target2, url3, target3) {
    
    if (req.readyState == 4) {
      
        if (req.status == 200) {
		
            results = req.responseText;
	    target1.innerHTML = results;
	    call__(url2, url3, target2, target3);		
			
            
        } else {
            target1.innerHTML = "call error:\n" + req.statusText;
        }
    }
}
function call__(url1, url2, target1, target2) {
	

    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {callDone__(target1, url2, target2);};
        req.open("GET", url1, true);
		
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {callDone__(target1, url2, target2);};
            req.open("GET", url1, true);
            req.send();
        }
    }
	
}    

function callDone__(target1, url2, target2) {
    if (req.readyState == 4) {
      
        if (req.status == 200) {
		
            results = req.responseText;
	    target1.innerHTML = results;
	    call_11(url2, target2);		
			
            
        } else {
            target1.innerHTML = "call error1:\n" + req.statusText;
        }
    }
}
function call(url1, url2, target1, target2) {
	

    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {callDone(target1, url2, target2);};
        req.open("GET", url1, true);
		
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {callDone(target1, url2, target2);};
            req.open("GET", url1, true);
            req.send();
        }
    }
	
}    

function callDone(target1, url2, target2) {
    if (req.readyState == 4) {
      
        if (req.status == 200) {
		
            results = req.responseText;
	    target1.innerHTML = results;
	    call_1(url2, target2);		
			
            
        } else {
            target1.innerHTML = "call error1:\n" + req.statusText;
        }
    }
}
function call_11(url, target) {
	if(document.getElementById('category').value != 0)
		{	//alert(document.getElementById('category').value);
			url += document.getElementById('category').value;
		
		}
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {callDone_11(target);};
        req.open("GET", url, true);
		
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {callDone_11(target);};
            req.open("GET", url, true);
            req.send();
        }
    }
	
}    

function callDone_11(target) {
    
    if (req.readyState == 4) {
      
        if (req.status == 200) {
		
            results = req.responseText;
	    target.innerHTML = results;
	   	
			
            
        } else {
            target.innerHTML = "call error2:\n" + req.statusText;
        }
    }
}
function call_1(url, target) {
	
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {callDone_1(target);};
        req.open("GET", url, true);
		
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {callDone_1(target);};
            req.open("GET", url, true);
            req.send();
        }
    }
	
}    

function callDone_1(target) {
    
    if (req.readyState == 4) {
      
        if (req.status == 200) {
		
            results = req.responseText;
			//alert(results);
			target.innerHTML = results;
        		//Custom.init();
  
        } else {
            target.innerHTML = "call error2:\n" + req.statusText;
        }
    }
}

function call_3(url, target) {
	
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {callDone_3(target);};
        req.open("GET", url, true);
		
        req.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {callDone_3(target);};
            req.open("GET", url, true);
            req.send();
        }
    }
	
}    

function callDone_3(target) {
    
    if (req.readyState == 4) {
      
        if (req.status == 200) {
		
            results = req.responseText;
			//alert(results);
			target.innerHTML = results;
        		//Custom.init();
				jQuery(function(){
					jQuery('select.catselect').jqTransSelect1();
				}); 
        } else {
            target.innerHTML = "call error2:\n" + req.statusText;
        }
    }
}

function call_2(url) {

    if (window.XMLHttpRequest) {
        req1 = new XMLHttpRequest();
        req1.onreadystatechange = function() {callDone_2();};
        req1.open("GET", url, true);
		
        req1.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req1 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req1.onreadystatechange = function() {callDone_2();};
            req1.open("GET", url, true);
            req1.send();
        }
    }
	
}    

function callDone_2() {
    
    if (req1.readyState == 4) {
      
        if (req1.status == 200) {
		
            results1 = req1.responseText;
            
        } else {
            
        }
    }
}

function call_alert(url) {

    if (window.XMLHttpRequest) {
        req1 = new XMLHttpRequest();
        req1.onreadystatechange = function() {callDone_alert();};
        req1.open("GET", url, true);
		
        req1.send(null);
    // IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req1 = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req1.onreadystatechange = function() {callDone_alert();};
            req1.open("GET", url, true);
            req1.send();
        }
    }
	
}    

function callDone_alert() {
    
    if (req1.readyState == 4) {
      
        if (req1.status == 200) {
			if(req1.responseText != ""){
	  	         alert(req1.responseText);
        	}    
        } else {
            
        }
    }
}






















