$(document).ready(function(){

        $("#search").click(function (){
                document.searchform.submit();
        });

         $("#subscribe-submit").click(function (){
                document.subscribe-me.submit();
        });
        $(".claimLink a").click(function ()
		{
			$(this).parent().parent().find(".dia-wrap").show();
			$(this).html("Click here to open site");
			$(this).parent().css ('background','transparent url(../images/tip_sprite.gif) no-repeat scroll -150px 0');
		});
})


function showdiv(n,vcode,vlink){
      //  alert(vcode);
	try{
	$("#subitem_"+n+"")[0].style.display="block";
	}catch(e){}
        if ( typeof(vcode) != "undefined")
        {
                try{
			//copy2Clipboard(vcode);
		}
		catch(e){
                        //alert('a1a');
		}
           /*     alert(vcode);
                var clip = new ZeroClipboard.Client();
                clip.setText(vcode);
                clip.addEventListener('complete', function(client, text) {
                    alert("Copied text to clipboard:\n" + text);
                });*/

              //  window.clipboardData.setData("Text",vcode);
        }
        if(typeof(vlink) != "undefined")
        {
             //   alert('aa');
                window.open(vlink);

        }
}
function hidediv(n){
	$("#subitem_"+n+"")[0].style.display="none";
}
function bookmarksite(title,url){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}


function copyfunc(thetext, elemname)
{
        ZeroClipboard.setMoviePath( '/scripts/ZeroClipboard.swf' );
      //  alert(elemname);
    var clip = new ZeroClipboard.Client();

    clip.setText( thetext);
    clip.glue(elemname);
}


function copy2Clipboard(txt){
	if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData("Text",txt);
	}
	else if(navigator.userAgent.indexOf("Opera")!=-1){
		window.location=txt;
	}
	else if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch(e){
			//alert("您的firefox安全限制限制您进行剪贴板操作，请打开’about:config’将signed.applets.codebase_principal_support’设置为true’之后重试，相对路径为firefox根目录/greprefs/all.js");
			return false;
		}
		var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if(!clip)return;
		var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if(!trans)return;
		trans.addDataFlavor('text/unicode');
		var str=new Object();
		var len=new Object();
		var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=txt;str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid=Components.interfaces.nsIClipboard;
		if(!clip)return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
}
/*
function bookmarksite(title,url){
//        Bookmark.bookmarkPage(url);
//        return false;
//        var canBookmarkPage = ();
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
	else
                //if(document.all)
        {
                if(typeof window.external == 'object') {
				window.external.AddFavorite(url, title);
				return true;
			} else {
				return false;
			}

        }
}

var Bookmark = function() {
	var browser = navigator.userAgent.toLowerCase();
	var keystroke = ((browser.indexOf('mac')!=-1) ? 'Command/Cmd':'CTRL') + ' + D';
	var canBookmarkPage = (typeof window.external == 'object');

	return {
		bookmarkPage : function(url) {
			if(this.canBookmark()) {
				window.external.AddFavorite(url);
				return true;
			} else {
				return false;
			}
		},

		canBookmark : function () {
			return canBookmarkPage;
		},

		getKeystroke : function () {
			return keystroke;
		}
	};
}();
*/
function setHomepage(url)
{
	 if (document.all)
	 {
			document.body.style.behavior='url(#default#homepage)';
			document.body.setHomePage(url);

	    }
	    else if (window.sidebar)
	    {
	    if(window.netscape)
	    {
		 try
	   {
		    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		 }
		 catch(e)
		 {
	    alert("this action was aviod by your browser，if you want to enable，please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
		 }
	    }
	    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
	    prefs.setCharPref('browser.startup.homepage',url);
	 }
}
