﻿/*
Function open popup window with name
*/
function OpenCenterPopup(file, name, width, height, scroll)
{
	var maxY = screen.availHeight;
	var maxX = screen.availWidth;  
	var x = (maxX - width) / 2;
	var y = (maxY - height) / 2;
	if (!scroll) scroll = 'no'; else scroll = 'yes';
	var w = window.open(file, name, 'status=yes,scrollbars='+scroll+',width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
	if (w != null)
		w.focus();

	return w;
}

// showFlash
function showFlash (url, width, height)
{
    document.write(
	    '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'"> '+
	    '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+url+'" /><param name="quality" value="high" /> '+
	    '<embed src="'+url+'" quality="high" width="'+width+'" height="'+height+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> '+
	    '</object>'
    );
}

// writeFlash
function writeFlash(s)
{
    document.write(s);
}

// expand or collapse a div
function expandCollapse(tr) {
	tr = document.getElementById(tr);
	if (tr.style.display == 'block') {
		tr.style.display = 'none';
	} else {
		tr.style.display = 'block';
			tr.focus();
	}
}

/*
Switches between images on pics.aspx
*/
function SwitchImage(mainPicClientID, mainPicImgSrc, mainPicDescClientID, text)
{
    document.getElementById(mainPicClientID).src = mainPicImgSrc;
    if(document.all){
		document.getElementById(mainPicDescClientID).innerText = text;
	} else{
		document.getElementById(mainPicDescClientID).textContent = text;
	}
}

// add a dead url report count on download.aspx and software.aspx
function addUrlReportCount(ajaxObjectName, softwareId, urlId, divUrlReportLink) {
	var ajaxObj = eval(ajaxObjectName);
	var divUrlReportLink = document.getElementById(divUrlReportLink);
	ajaxObj.AddUrlReportCount(softwareId, urlId);
	// show message
	if(document.all){
		 divUrlReportLink.innerText = 'הדיווח התקבל - תודה.';
	} else{
		divUrlReportLink.textContent = 'הדיווח התקבל - תודה.';
	}
}

// add a new version report count
function addVersionReportCount(softwareId, divVersionReportLink) {
	var divVersionReportLink = document.getElementById(divVersionReportLink);
	Web_software.AddNewVersionReportCount(softwareId);
	// show message
	if(document.all){
		 divVersionReportLink.innerText = 'הדיווח התקבל - תודה.';
	} else{
		divVersionReportLink.textContent = 'הדיווח התקבל - תודה.';
	}
}


// add or remove a software to the user's my softwares list
// AJAX method
function addRemoveToMySoftwares(softwareId, action) {
	Web_software.AddRemoveUserSoftware(softwareId, action);
	if (action == 0) {// add
		alert('התוכנה התווספה לרשימת התוכנות שלך, ומעכשיו ישלחו אליך עידכונים במידה ויהיו גירסאות חדשות');
	}
}

