﻿function PopUpPurchase(Source,SID,type,destMember)
{
	var url = '../Subscribe/Purchase.aspx?Source='+Source+'&SID='+SID+"&destMember="+escape(destMember);

	// type : 1 = window.open ; 2 = redirect ; 3 = window.open + close parent
	switch(type)
	{
		case 2:
			location.href = url;
			break;
		case 1:
			var win = window.open(url,"purchase",'scrollbars=yes,toolbar=no,menubar=no,status=no,location=no,resizable=yes,width=750,height=620');
			if (win == null) ///alert ('אנא בטל את חוסם הפריטים המוקפצים');
				parent.location.href = url;
			break;
		case 3:
			var win = window.open(url,"purchase",'scrollbars=yes,toolbar=no,menubar=no,status=no,location=no,resizable=yes,width=750,height=620');
			if (win == null) ///alert ('אנא בטל את חוסם הפריטים המוקפצים');
				parent.location.href = url;
			else 
				parent.close();	
			break;
	}	
}


function $(objName) {
	return document.getElementById(objName);
}

function openpicture(path)
{         
	if ( -1 != path.search("Images.he/") )
		return;
	
	var wImg = window.open('../Member/Image.aspx?MEMBERID=0&IMAGEINDEX=0&IMAGEPATH='+path,'PIC','status=no,scrollbars=yes,height=500, width=500, titlebar=no, resizable=yes', false )
	if ( wImg == null ) {
		alert('PopUp-Blocker Detected.');
	}
	else
		wImg.focus();
}
function openwindow(relativeDir, bodyfilename)
{
	var up		= "../"+relativeDir+"/up.aspx";
	var bottom	= "../"+relativeDir+"/bottom.aspx";
	var body	= "../"+relativeDir+"/" + bodyfilename;
	var query = "?up=" + up +"&bottom=" + bottom  +"&body=" + body

	window.open('../frameset/Index.aspx' + query,'WIN','status=no,scrollbars=yes,height=600, width=800, top=0, left=0, titlebar=no, resizable=yes', false );		
}

function showhistory(nMemberId,  obj, id, sMsg )
{
	if ( confirm(sMsg ) )
		parent.parent.document.location.replace('Index.aspx?CARDMEMBER='+nMemberId + '&SHOWHISTORY='+id +'#_End')
}

function autoHideMsgAlert() {
	var objMsgAlert = document.getElementById('lblMsg');
	if ( objMsgAlert != null )
		window.setTimeout(fadeOutAlert, 3000);
}
function fadeOutAlert() {
	opacity('lblMsg', 85, 0, 800);
}

function resize( img, box  )
{
	var width = img.width
	var height = img.height
	
	var zoom = (width > height) ? box/width : box/height;
	if( zoom < 1 )
	{
		 img.height = zoom * height;
		 img.width = zoom * width;
	}
}
function blink(divID, state)
{
	var objDiv = document.getElementById(divID);
	if (objDiv)
		objDiv.style.color = state ? "#cc0000" : "darkblue";
	window.setTimeout( function () { blink(divID, !state) }, 1000);
}

function AstroBlink(divID, state)
{
	var objDiv = document.getElementById(divID);
	if (objDiv)
		objDiv.style.color = state ? "#555C0B" : "#A70505";
	window.setTimeout( function () { AstroBlink(divID, !state) }, 1000);
}

function showDiv(divID) {
	var objDiv = $(divID);
	if (objDiv)
		objDiv.style.display = '';
	else
		alert('אירעה שגיאה');
}
function hideDiv(divID) {
	var objDiv = $(divID);
	if (objDiv)
		objDiv.style.display = 'none';
	else
		alert('אירעה שגיאה');
}

function PopThisUp(obj, width, height, windowName) {
	return PopMeUp(obj['href'], width, height, windowName);
}

function PopMeUp(url, width, height, windowName) {
	width = width || 500;
	height = height || 500;
	windowName = windowName || '';
	
	var win = window.open(url,windowName,'scrollbars=yes,toolbar=no,menubar=no,status=no,location=no,resizable=yes,width='+width+',height='+height);
	if ( win == null ) alert (removePopupBlockerMsg);
	else {win.focus(); return false;}
	return true;
}