// JavaScript Document
String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
};

function cText(obj, textToRemove)
{
	obj.value=obj.value.replace(textToRemove, "");
}
function addText(obj, textToAdd)
{
	if (obj.value.trim() == "")
	{
		obj.value=textToAdd;
	}
}
function SetHackerSafeContextMenu()
{
	var ObjImageHacker = document.getElementById('secure_image');
	var onC='alert("Copying Prohibited by Law - HACKER SAFE is a Trademark of ScanAlert"); return false;'; 
	ObjImageHacker.oncontextmenu=new Function(onC);
	return false;
}
 function OpenCertDetails(URL)
 {
thewindow =window.open(URL, 'anew',config='height=550,width=500,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=yes');
 }
 function OpenNewWindow(url)
 {
	thewindow =window.open(url);
 }
 function OpenSmallWindow(url)
 {
	thewindow =window.open(url,'anew',config='height=550,width=600,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=yes');
 } 
 function _cln_enter(){
 window.open('http://chat.livechatnow.com/js/enter.php?url=&refer=&name=&email=&skin=lime1&survey=&survey_ec=&survey_lm=&user=&uid=&sid=&cid=16137&op=&ip=&group=General&q=&track=','_chat_16137','resizable=yes,menubar=no,scrollbars=no, width=600, height=500');
 return false;
}
function GoToBestseller(Pid, View)
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.BestForm;
	}
	else {
		theform = document.forms["BestForm"];
	}
	theform.BestPid.value = "bestToy-" + Pid;
	theform.View.value = View;
	theform.submit();
}

function removeClass(obj, className) {
	var classNames = obj.className.split(" ");
	var result = [];
	for (var i = 0; i < classNames.length; i++) {
		if(classNames[i] != "" && classNames[i] != className)
			result[result.length] = classNames[i];
	}
	obj.className = result.join(" ");
}

function addClass(obj, className) {
	obj.className += " " + className;
}
function ContainsClass(obj, className) {
	var classNames = obj.className.split(" ");
	var ObjectContainsClass = false;
	for (var i = 0; i < classNames.length; i++) {
		if(classNames[i] == className)
			ObjectContainsClass = true;
	}
	return ObjectContainsClass;
}
function TrackingUrlSection()	{
	var TrackingUrlSection = document.getElementById("tracking_url_section");
	var TableGetUrl= document.getElementById("table_panel_get_url");
	var	SelectTags = document.getElementsByTagName("select");
	var	ObjectTags = document.getElementsByTagName("object");
	
	if (TrackingUrlSection.style.display == "none")
	{
		TrackingUrlSection.style.display = "block";
		//adding class active to panel, option "Get URL"
		addClass(TableGetUrl, "active_option");
		
		var textarea = document.getElementById("txtComment");
		textarea.focus();
		
		//hide 'object'(flash) elements when displaying Grab Url
		for(i=0;i<ObjectTags.length;i++){
				addClass(ObjectTags[i], "v_hidden");
		}
		//hide all select tags - fixing bug for IE6
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			for(i=0;i<SelectTags.length;i++){
				addClass(SelectTags[i], "v_hidden");
			}
		}
	}
	else
	{
		TrackingUrlSection.style.display = "none";
		//removing class active from panel
		removeClass(TableGetUrl, "active_option");
		
		//display object elements when displaying Grab Url
		for(i=0;i<ObjectTags.length;i++){
				removeClass(ObjectTags[i], "v_hidden");
		}
		//display all select tags - fixing bug for IE6
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			for(i=0;i<SelectTags.length;i++){
				removeClass(SelectTags[i], "v_hidden");
			}
		}
	}
	GrabUrl_SetTitle();
}
function increaseNumberInSpan(SpanId)
{
	var objNumGrUrl = document.getElementById(SpanId);
		objNumGrUrl.innerHTML = ((parseInt(objNumGrUrl.innerHTML) + 1).toString() );
}
function SaveURL(Uri, CommentQueryStringParam) {
	objTxtComment = document.getElementById("txtComment");
	objImageSaveUrl = document.getElementById("img_save_url");
	var URL;
	if (Uri.indexOf('?')>-1)
	{
		URL = Uri + '&' + CommentQueryStringParam + '=' + objTxtComment.value;
	}
	else
	{
		URL = Uri  + '?' + CommentQueryStringParam + '=' + objTxtComment.value;
	}
		objImageSaveUrl.src = URL;
		TrackingUrlSection();
		//increase number of grabed urls.
		increaseNumberInSpan('num_gr_urls');
}
function GrabProduct(Uri, GrabProdQueryParam)
{
	var objImgGrabProd = document.getElementById("img_grab_prod");
	var URL;
	if (Uri.indexOf('?')>-1)
	{
		URL = Uri + '&' + GrabProdQueryParam + '=1';
	}
	else
	{
		URL = Uri  + '?' + GrabProdQueryParam + '=1';
	}
	objImgGrabProd.src = URL;
	//change images
	var objBtnGrab = document.getElementById("btn_grab_prod");
	addClass(objBtnGrab, "hidden");
	objBtnGrab = document.getElementById("img_grabed_prod");
	removeClass(objBtnGrab, "hidden");
	//increase number of products in my desktop.
	increaseNumberInSpan('num_prod_desk');
}

function SelectTextBox(obj){
	if (obj == null) return;
	obj.select();
}

function EncodeHtml(str){
	var ret = str;
	ret = ret.replace("&","&amp;","gi");
	ret = ret.replace("<","&lt;","gi");
	ret = ret.replace(">","&gt;","gi");
	ret = ret.replace("'","'","gi");
	ret = ret.replace("\"","&quot;","gi");
	
	return ret;
}

function MyUrls_OnSubmit(){
	tags = document.getElementsByTagName("textarea");
	for(i=0;i<tags.length;i++){
		if (tags[i].id.indexOf("txtHtmlTag")>=0){
			tags[i].style.display="none";
			tags[i].value = "";
		}
		if (tags[i].id.indexOf("txtComment")>=0){
			tags[i].style.display="none";
			tags[i].value = EncodeHtml(tags[i].value);
		}
	}
}

function GrabUrl_OnSubmit(){
	obj = document.getElementById("txtComment");
	if (obj == null) return;
	obj.value = EncodeHtml(obj.value);
}

function GrabUrl_SetTitle(){
	obj = document.getElementById("txtComment");
	if (obj == null) return;
	obj.value = document.title;
}
// bookmark panel function
function SetBookmark(Site)
{
	switch (Site)
	{
		case "del.icio.us":
			location.href='http://del.icio.us/post?v=4;url='+encodeURIComponent(location.href)+';title='+encodeURIComponent(document.title);
			break;
		case "linkatopia.com":
				var wd=window.document,s=wd.createElement('script');s.id='ks';s.type='text/javascript';s.src='http://linkatopia.com/innerpop_js.php';void(wd.body.appendChild(s))
			break;
		case "simpy.com":
			if(window.getSelection){txt=window.getSelection();}else if(document.getSelection){txt=document.getSelection();}else if(document.selection){txt=document.selection.createRange().text;}
		location.href='http://www.simpy.com/simpy/LinkAdd.do?title='+encodeURIComponent(document.title)+'&href='+encodeURIComponent(location.href)+'&note='+encodeURIComponent(txt)+'&_doneURI='+encodeURIComponent(location.href)+'&v=7&src=bookmarklet';
			break;
		case "reddit.com":
	location.href='http://reddit.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
			break;

		case "bringr.com":
	location.href='http://bringr.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
			break;
		case "digg.com":
	location.href='http://digg.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
			break;
		case "technorati.com":
	location.href='http://technorati.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
			break;
		case "slashdot.com":
	location.href='http://slashdot.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
			break;
		case "google.com":
	location.href='http://google.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)
			break;



    case "blinklist.com":
u=location.href;p=/https/;httpvar=(u.search(p)!=-1)?'https':'http';s=document.body.appendChild(document.createElement('script'));s.id='fs';s.language='javascript';void(s.src=httpvar+'://www.blinklist.com/Theme/Script/fav.js');
			break;
     case "taggly.com":
x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);if(navigator.appName.indexOf('Explorer')!=-1){d=encodeURIComponent(document.selection.createRange().text);}else{d=encodeURIComponent(window.getSelection());}location.href='http://www.taggly.com/bookmarks/?action=add&address='+a+'&title='+t+'&description='+d;void 0;
			break;
     case "bluedot.us":
{var w=window;w.l=w.location;
		w.SdP='secure.';
		w.bU=(w.l.protocol=='https:'?'https://'+w.SdP:'http://')+'bluedot.us';
		w.eUC=encodeURIComponent;
		function fBkF()
		{w.l.href=w.bU+'/Authoring.aspx?u='+w.eUC(w.l.href)+'&t='+w.eUC(document.title);}w.gT=w.setTimeout(fBkF,6999);
		w.d=w.document;w.sT=w.d.body;
		w.o=w.d.createElement('scri'+'pt');
		if(typeof w.o!='object')fBkF();
		w.o.setAttribute('src',w.bU+'/js/Authoring.js');w.o.setAttribute('type','text/javascript');
		void(w.sT.appendChild(w.o));
		}
			break;
     case "diigo.com":
(function(){s=document.createElement('script');s.type='text/javascript';s.src='http://www.diigo.com/javascripts/webtoolbar/diigolet_b_h_b.js';document.body.appendChild(s);})();
			break;
     case "gravee.com":
			void(open('http://www.gravee.com/account/bookmarkpop?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title),'Gravee',',alwaysraised=on,status=off,toolbar=off,modal=on,dialog=on,width=350,height=250'));
			break;
		case "wink.com":
{var e=encodeURIComponent,d=document; if(navigator.appName.indexOf('Explorer')!=-1){void(location.href='http://wink.com/_/tag?url='+e(location.href)+'&ttl='+e(d.title));}else{void(open('http://wink.com/_/tag?url='+e(location.href)+'&ttl='+e(d.title)+'&d='+e(d.selection?d.selection.createRange().text:d.getSelection()),'wink','dialog=1,modal=1,width=400,height=300'));}}
			break;
     case "thisnext.com":
/* Recommend the item on this page on ThisNext */ (function() {var x = document.getElementsByTagName('head').item(0);var so = document.createElement('script');var s = 'http://www.thisnext.com/js/bookmarklet/'+location.hostname.split('.').reverse().join('/')+'/';if (typeof so != 'object') so = document.standardCreateElement('script');so.setAttribute('src', s );so.setAttribute('type','text/javascript');x.appendChild(so);  })();
			break;
		case "wists.com":
(function() { if (document.getElementById) { var x = document.getElementsByTagName('head').item(0); var o = document.createElement('script'); if (typeof o != 'object') o = document.standardCreateElement('script'); o.setAttribute('src','http://www.wists.com/wistlet.js?x=' + Math.floor(Math.random() * 9999)); o.setAttribute('type','text/javascript'); x.appendChild(o); } } )();
		break;
     case "kaboodle.com":
if(navigator.appName.indexOf('Explorer')!=-1)
		{
			var _mg56v='0.2';(function(){var d=document;var s;try{s=d.standardCreateElement('script');}catch(e){}if(typeof(s)!='object')s=d.createElement('script');s.type='text/javascript';s.src='http://www.kaboodle.com/zg/g.js';s.id='c_grab_js';d.getElementsByTagName('head')[0].appendChild(s);})();
		}
		else
		{
			var _mg56v='0.3';(function(){var d=document;var s;try{s=d.standardCreateElement('script');}catch(e){}if(typeof(s)!='object')s=d.createElement('script');try{s.type='text/javascript';s.src='http://www.kaboodle.com/zg/g.js';s.id='c_grab_js';d.getElementsByTagName('head')[0].appendChild(s);}catch(e){ window.location ='http://www.kaboodle.com/za/selectpage?p_pop=false&amp;pa=url&amp;u='+window.location;}})();
		}
			break;
     case "mypicklist.com":
(function(){try{var x=document.getElementsByTagName('head').item(0);var o=document.createElement('script');if('object'!=typeof(o)){o=document.standardCreateElement('script');}o.setAttribute('src','http://www.mypicklist.com/dir_bookmarklet/custom_bookmarklet.js');o.setAttribute('type','text/javascript');x.appendChild(o);}catch(e){alert('Error: '+e);}})();
			break;
     case "trezr.com":
			window.location="http://www.trezr.com/post";
			break;
	}
}






