function ShowFlash(strFileName,StrWidth,strHeight)
{
	document.write ("<embed src='"+strFileName+"' style='width:"+StrWidth+"px; height:"+strHeight+"px' quality='high' type='application/x-shockwave-flash' wmode='transparent'></embed>")
}

function new_window(filename, h, w, s, m)
{
	if (s=="")
	{
		window.open(filename,null,"top=50,left=0,height=" + h + ",width=" + w + ",status=no,toolbar=no,scrollbars=yes,menubar=no,location=no");
	}
	else
	{
		window.open(filename,null,"top=50,left=00,height=" + h + ",width=" + w + ",status=no,toolbar=no,scrollbars=" + s + ",menubar=" + m + ",location=no");
	}
}


var errfound = false;

function error(elem, text) {
	if (errfound) return;
	window.alert(text);
	elem.select();
	elem.focus();
	errfound = true;
}

function login_user(f) {

	errfound = false;

	if (f.StrUsername.value == "")
		error(f.StrUsername,"Bạn phải nhập đầy đủ Username !");

	if (f.strPassword.value == "")
		error(f.strPassword,"Bạn phải nhập đầy đủ Password !");
  	return ! errfound;
}

		/* Change Make */
		function changeFirm(iMake) {
		frm = document.forms[1];
		if(iMake=="-1")iMake=frm.cboMake.value;
		frm.cboModel.length = 0;
		frm.cboModel.length = frm.cboModel.length + 1;
		frm.cboModel.options[frm.cboModel.length-1].value = '0';
		frm.cboModel.options[frm.cboModel.length-1].text = 'Tất cả các Model';
		for (i=0; i<typeFirmIDs.length; i++) {
			if (typeFirmIDs[i] == iMake) {
				frm.cboModel.length = frm.cboModel.length + 1;
				frm.cboModel.options[frm.cboModel.length-1].value = typeIDs[i] ;
				frm.cboModel.options[frm.cboModel.length-1].text = typeNames[i] ;
			}
		}
		if(frm.cboMake.value==0){
			frm.cboModel.disabled = true;
			frm.cboModel.options[0].selected = true;
		}else{
			frm.cboModel.disabled = false;
		}

	}
	
function modalDialogShow_IE(url,width,height) //IE
	{
	return window.showModalDialog(url,window,
		"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes");
	}
function modalDialogShow_Moz(url,width,height) //Moz
    {
    var left = screen.availWidth/2 - width/2;
    var top = screen.availHeight/2 - height/2;
    activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
    window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
    }
var sActiveAssetInput;
function setAssetValue(v) //required by the asset manager
    {
    document.getElementById(sActiveAssetInput).value = v;
    }
function openAsset(s)
	{
	sActiveAssetInput = s
	if(navigator.appName.indexOf('Microsoft')!=-1)
		document.getElementById(sActiveAssetInput).value=modalDialogShow_IE("assetmanager/assetmanager.asp",640,465); //IE	
	else
		modalDialogShow_Moz("assetmanager/assetmanager.asp",640,465); //Moz	
	}
	
function openWin(theURL,winName,features) 
	{
  		window.open(theURL,winName,features);
	}
	
function OpenPreviewWindow(targetPage, formName)
	{
		now = new Date  
	   	openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')
	   	formName.action = targetPage + "?ID=" + now.getTime();	
		formName.target = "preview";
		formName.submit();
	}	
