function cs(e, eventTarget, eventArgument)
{
	if (e.keyCode == 13 || e.which == 13)
	{		
		return doPB(e, eventTarget, eventArgument)
	}
	return false;
}

function doPB(e, eventTarget, eventArgument)
{
		if (e.preventDefault) e.preventDefault();
		if (e.stopPropagation) e.stopPropagation();
		if (e.preventBubble) e.preventBubble();
		e.cancelBubble = true;
		e.returnValue = false;
		if (typeof(__doPostBack) == 'function'){
			__doPostBack(eventTarget, eventArgument);
		}
		else {
	  		var theform = document.forms[0];
	  		theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
	  		theform.__EVENTARGUMENT.value = eventArgument;
	  		theform.submit();
		}
		return false;
}

function swImage(url) {
	NewWindow(url,'',600,500,false,false,100,100);
}

function NewWindow(url, title, w, h, bResize, bScroll, winLeftPos, winTopPos) {
	if (title == undefined) title = '';
	if (w == undefined) w = '600';
	if (h == undefined) h = '500';
	if (bResize == undefined) bResize = 'Yes';
	if (bScroll == undefined) bScroll = 'Yes';
	var winl = (winLeftPos == undefined)?(screen.width - w) / 2:winLeftPos;
	var wint = (winTopPos  == undefined)?(screen.height - h) / 2:winTopPos;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable='+bResize+',scrollbars='+bScroll
	win = window.open(url, title, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function cvIsNumeric(source, arguments) {
		arguments.IsValid = (parseInt(arguments.Value) > 0)?true:false;
}
 
function swDisplay(elemId,imgId,bShowElem) { 
	var o = document.getElementById(elemId);	
 	if(o == null || o == undefined) return false; 	
 	if(bShowElem != undefined) { 	
  		o.style.display=(bShowElem)?"block":"none";
 	}
 	else { 	
 		o.style.display=(o.style.display=="none")?"block":"none";
 	} 	
 	if(imgId != undefined) { 	 	
 		var oimg = document.getElementById(imgId);
 		if(oimg != null || oimg != undefined){
 			var s=(o.style.display=="none")?"add.gif":"sub.gif";
  			setTimeout("document.getElementById('"+imgId+"').src='../images/"+s+"'", 10);  			
  		}
 	}
} 

function showCCDetails(obj) {
    if(obj == null) return false;
    var cctype = obj.options[obj.selectedIndex].value;
    var _UK0 = document.getElementById("_UK0");
    var _UK1 = document.getElementById("_UK1");
    if(_UK0 != undefined && _UK1 != undefined){
      if (cctype == 8 || cctype == 9) {
	_UK0.style.display = "block";
	_UK1.style.display = "block";
      }
      else {
	_UK0.style.display = "none";
	_UK1.style.display = "none";		
      }
    }
}

/* valdate credit card number */
function cvIsCardNum(source, arguments) {

	var s = arguments.Value
	var v = "0123456789";
	var w = "";

	for (var i=0; i < s.length; i++) {
		x = s.charAt(i);
		if (v.indexOf(x,0) != -1)
		w += x;
	}
		
	var j = w.length / 2;	
	if (j < 6.5 || j > 8 || j == 7) {
		arguments.IsValid = false;
		return arguments.IsValid;
	}

	var k = Math.floor(j);
	var m = Math.ceil(j) - k;
	var c = 0;
	
	for (var i=0; i<k; i++) {
		a = w.charAt(i*2+m) * 2;
		c += a > 9 ? Math.floor(a/10 + a%10) : a;
	}
	
	for (var i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
	
	arguments.IsValid = (c%10 == 0);
	return arguments.IsValid;
}
