var deletedItemIdList = '';
function getItemDelete(element,value){
if(typeof(element)=='undefined') return;
if(element.checked == true){
deletedItemIdList+= value+';';}
else{
deletedItemIdList = deletedItemIdList.replace(value+';', '');}}
function ClearDeletedItemGlobalVariable(){
deletedItemIdList = '';}
function GetAjaxChosePhoto(divTargetID, url){
url = url+"&pidList="+deletedItemIdList;
ajax_loadContent(divTargetID,url);
ClearDeletedItemGlobalVariable();}
function GetAlbumDelete(divTargetID, url){
url = url+"&albumidList="+deletedItemIdList;
ajax_loadContent(divTargetID,url);
ClearDeletedItemGlobalVariable();}
function checkbox(divID,url){
url = url+"&DeleteCust="+deletedItemIdList;
ajax_loadContent(divID,url);
ClearDeletedItemGlobalVariable();}
function EditXml(divAdd,url){
url = url+"&EditXml="+deletedItemIdList;
ajax_loadContent(divAdd,url);
ClearDeletedItemGlobalVariable();}
function ConfirmDelete(){
if(deletedItemIdList.length==0){
alert('Bạn phải chọn đối tượng cần xóa');
return false;}
else{
return confirm('Bạn chắc chắn muốn xóa');}}
var checkIds = '';
var isCheckAll = true;
function check_photo(chk){
var proId = chk.value;
if(chk.checked)
checkIds+=','+proId+',';
else
checkIds = checkIds.replace(','+proId+',','');}
function SelectedCheckBox(fieldName, textObjID){
var textObj=document.getElementById(textObjID);
var text = textObj.innerHTML;
switch(text){
case 'Bỏ chọn tất cả':
UnCheckAll(fieldName)
textObj.innerHTML='Chọn tất cả';
break;
case 'Chọn tất cả':
CheckAll(fieldName)
textObj.innerHTML='Bỏ chọn tất cả';
break;
default:
textObj.innerHTML='Chọn tất cả';
break;}}
function CheckAll(fieldName){
var frm = document.aspnetForm;
for(i = 0 ; i < frm.length; i++){
e = frm.elements[i];
if(e.type == 'checkbox'){
deletedItemIdList+= e.Name;
e.checked = true;}}}
function UnCheckAll(fieldName){
var frm = document.aspnetForm;
for(i = 0; i < frm.length; i++){
e = frm.elements[i];
if(e.type == 'checkbox'){
e.checked = false;}
deletedItemIdList = '';}}
function Check_All(spanChk){
var oItem = spanChk.children;
var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" && elm[i].id!=theBox.id){
if(elm[i].checked!=xState)
elm[i].click();}}
function CheckChanged(chkB){
var xState=chkB.checked;
var frm = document.aspnetForm;
var boolAllChecked;
boolAllChecked=true;
for(i=0;i< frm.length;i++){
e=frm.elements[i];
if ( e.type=='checkbox' && e.name.indexOf('Id') !=-1 )
if(e.checked== false){
boolAllChecked=false;
break;}}
for(i=0;i< frm.length;i++){
e=frm.elements[i];
if ( e.type=='checkbox' && e.name.indexOf('checkAll') !=-1 ){
if( boolAllChecked==false)
e.checked= false;
else
e.checked= true;
break;}}}
function getCheckIds(chkPhoto){
var checks = document.getElementById(chkPhoto);
var cks = '';
for(var i = 0; i<checks.length;i++){
if(checks[i].checked)cks+=checks[i].value+',';}
cks = cks.substring(0,cks.length-1);
return cks;}
function checkList(chkPhoto){
var checkList = document.getElementById(chkPhoto);
var total = 0;
for(var i =0; i<checkList.length; i++){
if(checkList[i].checked){
total++;}}
return total;}
function addFavs(chkPhoto){
var checkeds = getCheckIds(chkPhoto);
if(checkeds=='')
alert('Chọn ảnh để lưu vào mục ưa thích');
else
location.href='FavoritesAdd.aspx?photoId='+checkeds+'&return='+escape(location.href);}
function printPhotos(chkPhoto){
var checkeds = getCheckIds(chkPhoto);
if(checkeds=='')
alert('Chọn ảnh để in');
else
location.href='printPhotos.aspx?photoId='+checkeds+'&return='+escape(location.href);}
function printTexture(chkPhoto){
var iTotal = checkList(chkPhoto);
var checkeds = getCheckIds(chkPhoto);
if(checkeds == '')
alert('Chọn ảnh để in');
else if(iTotal> 1)
alert('Quý khách chỉ chọn 1 ảnh cho 1 lần in ảnh trên sản phẩm.');
else
location.href='printTexture.aspx?photoId='+checkeds+'&return='+escape(location.href);}
function printNormal(chkPhoto){
var checkeds = getCheckIds(chkPhoto);
if(checkeds=='')
alert('Chọn ảnh để in');
else
location.href='PrintNormalSimple.aspx?catId={0}&photoId='+checkeds;}
function printSilk(chkPhoto){
var checkeds = getCheckIds(chkPhoto);
if(checkeds=='')
alert('Chọn ảnh để in');
else
location.href='PrintNormalSimple.aspx?catId={1}&photoId='+checkeds;}
function delPhotos(chkPhoto){
var checkeds = getCheckIds(chkPhoto);
if(checkeds==''){
alert('Chọn ảnh để xóa');
return false;}
else{
return confirm('Bạn chắc chắn muốn xóa?');}}/*  ----------------Check out-----------------         */
function ShipAddress(chkID, FirstName, LastName, Address, Phone, Email, Fax, txtFirstName, txtLastName, txtAddress, txtPhone, txtEmail, txtFax){
var B_FirstNameObj = document.getElementById(txtFirstName);
var B_LastNameObj = document.getElementById(txtLastName);
var B_AddressObj = document.getElementById(txtAddress);
var B_PhoneObj = document.getElementById(txtPhone);
var B_EmailObj = document.getElementById(txtEmail);
var B_FaxObj = document.getElementById(txtFax);
var S_FirstNameObj = document.getElementById(FirstName);
var S_LastNameObj = document.getElementById(LastName);
var S_AddressObj = document.getElementById(Address);
var S_PhoneObj = document.getElementById(Phone);
var S_EmailObj = document.getElementById(Email);
var S_FaxObj = document.getElementById(Fax);
var chkObj = document.getElementById(chkID);
var chkValue = chkObj.value;
if(chkValue =='rbtShipToMe'){
B_FirstNameObj.value = S_FirstNameObj.value;
B_LastNameObj.value = S_LastNameObj.value;
B_AddressObj.value = S_AddressObj.value;
B_PhoneObj.value = S_PhoneObj.value;
B_EmailObj.value = S_EmailObj.value;
B_FaxObj.value = S_FaxObj.value;}
else if(chkValue=='rbtShipToOther'){
B_FirstNameObj.value = "";
B_LastNameObj.value = "";
B_AddressObj.value = "";
B_PhoneObj.value = "";
B_EmailObj.value = "";
B_FaxObj.value = "";}}
function CheckOut_ShowHideThanhToan(chkID, targetCODID,targetATMID,targetMOBIVI, targetSmartlink){
var chkObj = document.getElementById(chkID);
var CODObj = document.getElementById(targetCODID);
var ATMObj = document.getElementById(targetATMID);
var MBVObj = document.getElementById(targetMOBIVI);
var SmartObj = document.getElementById(targetSmartlink);
var chkValue = chkObj.value;
if(chkValue =="rdoATM"){
CODObj.style.display ='none';
MBVObj.style.display ='none';
SmartObj.style.display ='none';
ATMObj.style.display ='';}
else if(chkValue=="rdoCOD"){
CODObj.style.display ='';
ATMObj.style.display ='none';
MBVObj.style.display ='none';
SmartObj.style.display ='none';}
else if(chkValue=="rbMobivi"){
CODObj.style.display ='none';
ATMObj.style.display ='none';
SmartObj.style.display ='none';
MBVObj.style.display ='';}
else if(chkValue=="rbSmart"){
CODObj.style.display ='none';
ATMObj.style.display ='none';
SmartObj.style.display ='';
MBVObj.style.display ='none';}}
function CheckAccept(chkID){
chkObj = document.getElementById(chkID);
if(chkObj.checked == false){
alert('Xin vui lòng đồng ý với điều khoản trên trước khi Đặt hàng');
return false;}}/*-----------        Hint------------------------*/
var horizontal_offset="9px" //horizontal offset of hint box from anchor link
var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;}
return totaloffset;}
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}
function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight}
return edgeoffset}
function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip}}
function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"}
function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)}
if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox/*-----------    End Hint------------------------*/
function open_popup(URL){
popupWin = window.open(URL, 'popup', 'dependent=0,height=550px,width=600px,screenX=1,left=197,screenY=1,top=120,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0', 'launcher');}/*----------Upload Flash----------*/
function open_popup_flash(URL){
popupWin = window.open(URL, 'popup', 'dependent=0,height=590px,width=600px,screenX=1,left=197,screenY=1,top=100,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0', 'launcher');}
function onSubmitOK(txtImgId,value){
var oObjectID = null;
if(!window.opener.closed){
oObjectID = window.opener.document.getElementById(txtImgId);
if(oObjectID != null){
oObjectID.value = value;
oObjectID.focus();}}
window.close();}
function ConfirmSelectedObject(){
if(deletedItemIdList.length==0){
alert('Chưa có đối tượng nào được chọn!');
return false;}
else{
return confirm('Bạn chắc chắn muốn thực hiện!');}}
function GenCodeFlash(path, fileName){
var index = fileName.lastIndexOf(".");
var code = null;
var fileNameExt = null;
if(index !=-1){
fileNameExt = fileName.substring(index+1);
if(fileNameExt == "swf"){
code = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-Shop3600000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='709' height='273'>";
code = code+"<param name='movie' value='"+path+"/"+fileName+"' />";
code = code+"<param name='quality' value='high' />";
code = code+"<embed src='"+path+"/"+fileName+"' type='application/x-shockwave-flash' width='709' height='273'></embed></object>";}
else{
code = "<img src='"+path+"/"+fileName+"' width='709' height='273' />";}}
return code;}
function GenCodeLogo(path, fileName){
var index = fileName.lastIndexOf(".");
var code = null;
var fileNameExt = null;
if(index !=-1){
fileNameExt = fileName.substring(index+1);
if(fileNameExt == "swf"){
code = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-Shop3600000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='200'>";
code = code+"<param name='movie' value='"+path+"/"+fileName+"' />";
code = code+"<param name='quality' value='high' />";
code = code+"<embed src='"+path+"/"+fileName+"' type='application/x-shockwave-flash' width='200'></embed></object>";}
else{
code = "<img src='"+path+"/"+fileName+"' width='200' />";}}
return code;}/*----------End Upload Flash----------*/
