﻿var RightClick = {
	/**
	 *  Constructor
	 */ 
	init: function () {
		var url=document.domain;
		if(url!='www.7shan.com')
		{
		document.getElementById("test_index").innerHTML='<a href="javascript:window.external.AddFavorite("http://www.7shan.com","奇山宠物乐园")"><img src="images/nav_r1_c1.gif" width="147" height="63" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.7shan.com/download_tata/" target="_blank"><img src="images/nav_r1_c8.gif" width="147" height="63" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.7shan.com/recharge" target="_blank"><img src="images/nav_r1_c5.gif" width="147" height="63" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.7shan.com/New/index.php" target="_blank"><img src="images/nav_r1_c6.gif" width="147" height="63" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://bbs.7shan.com/index.php" target="_blank"><img src="images/nav_r1_c7.gif" width="147" height="63" border="0" /></a>'
		}
		this.FlashObjectID = "index";
		this.FlashContainerID = "flashcontent";
		this.Cache = this.FlashObjectID;
		
		if(window.addEventListener)
		{
			 window.addEventListener("mousedown", this.onGeckoMouse(), true);
		} else {
			document.getElementById(this.FlashContainerID).onmouseup = function() 
			{ 
				document.getElementById(RightClick.FlashContainerID).releaseCapture(); 
			}
			document.oncontextmenu = function()
				{ 
					if(window.event.srcElement.id == RightClick.FlashObjectID) 
					{
						return false; 
					} 
					else 
					{ 
						RightClick.Cache = "nan"; 
					}
				}
			document.getElementById(this.FlashContainerID).onmousedown = RightClick.onIEMouse;
		}
		document.getElementById(this.FlashObjectID).focus();
	},
	/**
	 * GECKO / WEBKIT event overkill
	 * @param {Object} eventObject
	 */
	killEvents: function(eventObject) {
		if(eventObject) {
			if (eventObject.stopPropagation) eventObject.stopPropagation();
		
		}
	},
	/**
	 * GECKO / WEBKIT call right click
	 * @param {Object} ev
	 */
	onGeckoMouse: function(ev)
		{

	  	return function(ev){
			
	    if (ev.button != 0) {
			
			RightClick.killEvents(ev);
			if(ev.target.id == RightClick.FlashObjectID && RightClick.Cache == RightClick.FlashObjectID) {
	    		RightClick.call();
			}
			RightClick.Cache = ev.target.id;
		}
	  }
	},
	/**
	 * IE call right click
	 * @param {Object} ev
	 */
	onIEMouse: function() {
	  	if (event.button > 1) {
			if(window.event.srcElement.id == RightClick.FlashObjectID && RightClick.Cache == RightClick.FlashObjectID) {
				RightClick.call(); 
				
			}
			document.getElementById(RightClick.FlashContainerID).setCapture();
			if(window.event.srcElement.id)
			RightClick.Cache = window.event.srcElement.id;
		}
	},
	/**
	 * Main call to Flash External Interface
	 */
	call: function() {
		//document.getElementById(this.FlashObjectID).rightClick();
	}
}
