var NewWin, TrueWin;

function newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

function error_message(){
alert('Your browser isn\'t supported!');
}
function getRefToDiv(divID) {
if( document.layers ) { 
return document.layers[divID]; }
if( document.getElementById ) { 
return document.getElementById(divID); }
if( document.all ) { 
return document.all[divID]; }
if( document[divID] ) { 
return document[divID]; }
return false;
}
function showDiv(divID_as_a_string) {
myReference = getRefToDiv(divID_as_a_string);
if( !myReference ) {
error_message();
return false; 
}
if( myReference.style ) { 
myReference.style.visibility = 'visible';
myReference.style.display='block';
} else {
if( myReference.visibility ) { 
myReference.visibility = 'show';
myReference.style.display='block';
} else {
error_message();
return false; 
}
}
return true;
}
function hideDiv(divID_as_a_string) {
myReference = getRefToDiv(divID_as_a_string);
if( !myReference ) {
return false; 
}
if( myReference.style ) { 
myReference.style.visibility = 'hidden';
myReference.style.display='none';
} else {
if( myReference.visibility ) { 
myReference.visibility = 'hide';
myReference.style.display='none';
} else {
return false; 
}
}
return true;
}
function expDiv(id,s){
myReference = getRefToDiv(id);
if( !myReference ) {
return false; 
}
if( myReference.style ){
myReference.style.height = s;
}else{
if( myReference.height ) { 
myReference.height = s;
myReference.style.height=s;
} else {
return false; 
}
}
}
function colDiv(id,s){
myReference = getRefToDiv(id);
if( !myReference ) {
return false; 
}
if( myReference.style ){
myReference.style.height = s;
}else{
if( myReference.height ) { 
myReference.height = s;
myReference.style.height = s;
} else {
return false; 
}
}
}
function ExpColDiv(id){
myReference = getRefToDiv('mp'+id);
if(myReference.style.height == '100%'){
colDiv('mp'+id,'76px');
showDiv('mph'+id);
hideDiv('mph2'+id);
}else{
expDiv('mp'+id,'100%');
hideDiv('mph'+id);
showDiv('mph2'+id);
}

}
function writeToDiv(div_name,t){
var menuobj=document.getElementById? document.getElementById(div_name) : document.all? eval('document.all.'+div_name) : document.layers? eval('document.'+div_name+'.document.'+div_name) : "";
if (document.getElementById||document.all)
menuobj.innerHTML=t;
else if (document.layers){
menuobj.document.write(t);
menuobj.document.close();
}
}
function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
function NMOV(IMGNAME,P,I){
document.images[IMGNAME].src='/images/'+I+P+'.gif';
}
function NMOU(IMGNAME,P,I){
document.images[IMGNAME].src='/images/'+I+P+'.gif';
}
function calc_click(){
var i = new Image;
i.src = '/bookmark.php';
}
function addBookmark() {
title = document.title;
url = window.location;
calc_click();
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
}else if( window.external ) {
window.external.AddFavorite( url, title);
}else if(window.opera && window.print) {
return true;
}
}
function preloadImages() {
var pic1 = new Image();
pic1.src = '/images/logo_t_2.gif';
}
function countDown(div_name,yr,m,d,h,mn,s){return;}

function rateIt(t,i,r,p,isl){
if(t < 1 || r < 0 || r > 5 || i < 1 || isl < 1)
return;
var im = new Image;im.src = '/rating/?t='+t+'&i='+i+'&r='+r; var h; showDiv('rating_'+p+'_done_'+i); setTimeout("hideDiv('rating_"+p+"_done_"+i+"');",5000);
}
function rateItWrite(t,tid,s,id,isl){
	var add_url;
	add_url = isl > 0 ? '' : 'alert(\'Please login first\'); void(0);';
	document.write('<IMG SRC="/images/'+s+'" USEMAP="#5stars'+id+'" BORDER=0 name="5stars'+id+'"><MAP NAME="5stars'+id+'"><AREA SHAPE="rect" COORDS="1,0,11,11", HREF="javascript:'+add_url+'rateIt('+tid+','+id+',1,\''+t+'\','+isl+');" ALT="1 Star" onMouseOver="document.images[\'5stars'+id+'\'].src=\'/images/1stars2.gif\';" onMouseOut="document.images[\'5stars'+id+'\'].src=\'/images/'+s+'\';"><AREA SHAPE="rect" COORDS="12,0,21,11", HREF="javascript:'+add_url+'rateIt('+tid+','+id+',2,\''+t+'\','+isl+');" ALT="2 Stars" onMouseOver="document.images[\'5stars'+id+'\'].src=\'/images/2stars2.gif\';" onMouseOut="document.images[\'5stars'+id+'\'].src=\'/images/'+s+'\';"><AREA SHAPE="rect" COORDS="22,0,32,11", HREF="javascript:'+add_url+'rateIt('+tid+','+id+',3,\''+t+'\','+isl+');" ALT="3 Stars" onMouseOver="document.images[\'5stars'+id+'\'].src=\'/images/3stars2.gif\';" onMouseOut="document.images[\'5stars'+id+'\'].src=\'/images/'+s+'\';"><AREA SHAPE="rect" COORDS="33,0,42,11", HREF="javascript:'+add_url+'rateIt('+tid+','+id+',4,\''+t+'\','+isl+');" ALT="4 Stars" onMouseOver="document.images[\'5stars'+id+'\'].src=\'/images/4stars2.gif\';" onMouseOut="document.images[\'5stars'+id+'\'].src=\'/images/'+s+'\';"><AREA SHAPE="rect" COORDS="43,1,53,11", HREF="javascript:'+add_url+'rateIt('+tid+','+id+',5,\''+t+'\','+isl+');" ALT="5 Stars" onMouseOver="document.images[\'5stars'+id+'\'].src=\'/images/5stars.gif\';" onMouseOut="document.images[\'5stars'+id+'\'].src=\'/images/'+s+'\';"></MAP>');}
function selfRefresh(){
	window.top.location.href = window.top.location.href+'?&dsrefresh=1';
}
function priceCompare(t,k){
if(t == 'amazon') window.open('http://www.amazon.com/gp/search?ie=UTF8&keywords='+document.getElementById('k'+k).value+'&tag=dealsuckercom-20&index=blended&linkCode=ur2&camp=1789&creative=9325');
if(t == 'froogle') window.open('http://froogle.google.com/froogle?q='+document.getElementById('k'+k).value);
if(t == 'ebay') window.open('http://rover.ebay.com/rover/1/711-1751-2978-71/1?AID=5463217&PID=2196950&mpre=http%3A//search.ebay.com/search/search.dll%3Fsatitle%3D'+document.getElementById('k'+k).value);
}

function pct(i){
if(i < 1) return;
var im = new Image;im.src = '/partners/click.php?i='+i;
}

function IV(i){
	newWindow('/video/?id='+i, 'video', 450, 400, 0, 0, 0, 0, 0, 0, 0);
}
function jShowHideDiv(name){
	myReference = getRefToDiv(name);
	if(myReference.style.display == 'none')
		showDiv(name);
	else
		hideDiv(name);
}
function resizeElement(el_id,h,w){
	if(h > 0)
		document.getElementById(el_id).style.height = h+'px';
	if(w > 0)
		document.getElementById(el_id).style.width = w+'px';
}

function getPixelsFromTop(obj){
	objFromTop = obj.offsetTop;
	while(obj.offsetParent!=null) {
		objParent = obj.offsetParent;
		objFromTop += objParent.offsetTop;
		obj = objParent;
	}
	return objFromTop;
}
