/**
 * $Id: utils.js,v 1.1.2.13 2005/01/27 16:48:50 lchan Exp $
 * 
 * Filebasket Utilities
 * 
 * You're welcome to rip this for usage on your own web sites -- but make
 * sure to give credits where appropriate.
 * 
 * @author 	Peter Theill 	<ptheill@filebasket.com>
 */


/**
 * Adds a product to users basket. The item will appear in the 
 * right menu with name, price and size together with a direct
 * link to detailed product page.
 * 
 */

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
 
               
function addToBasket(id, name, version, priceUsd, size) {
	
	location.replace("/basket.add.php?id="+id+"&name="+escape(name)+"&version="+escape(version)+"&price="+escape(priceUsd)+"&size="+size+"&url="+escape(location.href));
	
	// notify menu about a new item in the basket
	if (typeof onNewItem != 'undefined') {
		onNewItem(id, escape(name));
	}
	
} // > function addToBasket(...)


function addExternalToBasket(name, description, productPage, url1, identifier) {
	
	location.replace("/basket.add.php?t=e&n="+escape(name)+"&d="+escape(description)+"&p="+escape(productPage)+"&u1="+escape(url1)+"&i="+escape(identifier)+"&url="+escape(location.href));
	
	// notify menu about a new item in the basket
	if (typeof onNewExternalItem != 'undefined') {
		onNewExternalItem(escape(name));
	}
	
} // > function addExternalToBasket(...)


function removeFromBasket(id, name) {
	
	location.replace("/basket.remove.php?id="+id+"&name="+escape(name)+"&url="+escape(location.href));
	
	// notify menu about a removed item in the basket
	if (typeof onDeleteItem != 'undefined') {
		onDeleteItem(id, escape(name));
	}
	
	// reload page since you are removing an item from your basket while 
	// having the basket shown
	if (location.href.indexOf("basket.php") > -1) {
		location.replace(location.href);
	}
	
} // > function removeFromBasket(...)


function removeExternalFromBasket(name, identifier) {
	
	location.replace("/basket.remove.php?t=e&n="+escape(name)+"&i="+escape(identifier)+"&url="+escape(location.href));
	
	// notify menu about a removed item in the basket
	if (typeof onDeleteExternalItem != 'undefined') {
		onDeleteExternalItem(escape(name));
	}
	
	// reload page since you are removing an item from your basket while 
	// having the basket shown
	if (location.href.indexOf("basket.php") > -1) {
		location.replace(location.href);
	}
	
} // > function removeExternalFromBasket(...)

function goToProductDownloadPage(){
    alert("hello");
}

function downloadFileIndirect(id, url) {
   
	location.href = "/product.download.php?id="+id+"&url="+url+"&itn=1";
}

function downloadFileIndirectWithSiteID(id, url, siteID) {
   
    location.href = "/product.download.php?id="+id+"&url="+url+"&itn=1&SiteID="+siteID;
}

function Abrir(url , rediURL) {

	if(navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Netscape") != -1){
	
		location.href = url 	
	}
	else{
	
	    window.open(url,'download','toolbar=0,location=no,directories=0,status=0,scrollbars=yes,resizable=0,width=700,height=600,top=0,left=0');
	    window.focus();    
	    location.href = rediURL
	}
}

function Abrir_Janela(URL) { 
var width = 380; 
var height = 250; 
var left = 200; 
var top = 100; 
window.open(URL,'janela1', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no'); 

} 


function Abrir_Site(URL) { 
var width = 777; 
var height = 600; 
var left = 0; 
var top = 0; 
window.open(URL,'janela1', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no'); 

}

function POP_UP(URL) { 
var width = 336; 
var height = 280; 
var left = 0; 
var top = 0; 
window.open(URL,'janela1', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no'); 

}

function downloadFileDirectWithMirrorSite(id, url, siteID, directURL, mirror_Site) {
      
	if(navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Netscape") != -1){
		location.href = "/product.download.redirect.php?id="+id+"&url="+url+"&itn=1&SiteID="+siteID+"&mirrorsite="+mirror_Site;	
	}
	else{
	    window.open(directURL,'download','toolbar=0,location=no,directories=0,status=0,scrollbars=no,resizable=0,width=1,height=1,top=0,left=0');
	    window.focus();  
	    
	    location.href = "/product.download.redirect.php?id="+id+"&url="+url+"&itn=1&SiteID="+siteID+"&mirrorsite="+mirror_Site;	
	}
}

function redirectToMirrorPage(id) {
      
    location.href = "http://www.ziggi.com.br/downloads/download.asp?link="+id;
}


// [<] OBSOLETED
function downloadFileNow(id, url) {
	downloadFileIndirect(id, url);
}

function acceleratedDownload(data) {
	;
}

/**
 * Grabs out extension of a given image and inserts a 'disabled' text since 
 * it's how we name disabled images.
 */
function disableImage(imageName) {
	if (typeof document.images != 'undefined' && typeof document.images[imageName] != 'undefined') {
		if ((lastDot = document.images[imageName].src.lastIndexOf(".")) != -1) {
			extension = document.images[imageName].src.substr(lastDot);
			filename = document.images[imageName].src.substr(0, lastDot);
			document.images[imageName].src = filename + ".disabled" + extension;
		}
	}
} // > function disableImage(...)


function disableLink(linkName) {
	if (typeof document.links != 'undefined') {
		for (var i = 0; i < document.links.length; i++) {
			if (typeof document.links[i] != 'undefined' && document.links[i].name == linkName) {
				document.links[i].onclick = "return false;";
			}
		}
	}
} // > function disableLink(...)


/**
 * Displays a screen for an application -- the window opened match the 
 * size of the image.
 * 
 */
function displayScreenshot(url, originalUrl, name, width, height) {
	var winWidth = width + 8;
	var winHeight = height + 16 + 32;
	
	if ((screen.width <= winWidth) || (screen.height <= winHeight)) {
		width /= 2;
		height /= 2;
		
		winWidth = width + 8;
		winHeight = height + 16 + 32;
	}
	
	try {
		window.open(
			"/screenshot.display.php?url="+escape(url)+"&originalUrl="+escape(originalUrl)+"&name="+escape(name)+"&width="+width+"&height="+height, 
			"screenshot"+escape(new Date().getMilliseconds()), 
			"width="+winWidth+",height="+winHeight
		);
	}
	catch (x) {
		alert(
			"Hmm, it wasn't possible to show the screenshot window. Make sure you haven't\n" +
			"installed any 'popup stoppers' which is blocking this window from showing."
		);
	}
	
} // > function displayScreenshot(url, name, width, height)


function displayPrintSheet(productId) {
	
	var w = window.open(
		"/product.print.php?id=" + productId,
		"product_print_" + escape(new Date().getMilliseconds()), 
		"width=400,height=480,toolbar=0,statusbar=0,scrollbars=1"
	);
	
	w.print();
	
} // > function displayPrintSheet(...)


/**
 * Displays a new window with specified dimensions and set its focus. The 
 * content of the window will be determined by the hindId parameter which
 * is a constant referred server-side.
 * 
 * @param 	hintId 	Identifier of hint constant.
 * @param 	width 	Width of window.
 * @param 	height 	Height of window.
 */
function displayHintWindow(hintId, width, height) {
	
	if (!width)
		width = 320;
		
	if (!height)
		height = 320;
	
	w = window.open(
		"/hint.php?id=" + hintId,
		"hintWindow", 
		"width="+width+",height="+height+",toolbar=0,statusbar=0,scrollbars=1,resizable=1"
	);
	
	w.focus();
	
	return true;
	
} // > function displayHintWindow(...)


// could be extended ;o)
function checkEmail(pValue) {
	if (pValue.indexOf('@') < 1)
		return false;
	
	return true;
}

//block spam emails
function get_edress(){

	//http://www.webdevtips.co.uk/codegen/email_scramble.shtml
	
	var edress = 'simtel_support_at_simtel_dot_net';
	var re= /_at_/gi;
	edress = edress.replace(re,'@');
	var re= /_dot_/gi;
	edress = edress.replace(re,'.');
	var the_link="mai" + "lto" +":"+edress+"?subject=Simtel%20Feedback&body=Thank%20you%20for%20contacting%20Simtel support.%0D%0APlease%20provide%20as%20much%20information%20as%20possible%20so%20that%20your%20concerns%20will%20be%20addressed%20efficiently." ;
	window.location=the_link;

}

// >> EOF
