
/***********************************************/
/**************  ｹｫﾓﾃｻｾｺｯﾊ ******************/

function checkLogin()
{
	if (!top.leftfra.login)
	{
		alert("กรุณาลงทะเบียนก่อนค่ะ");
		return false;
	}
		return true;	
}

function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function logopenCart()
{
	if(checkLogin()) openCart();
}

/**************  ｹｫﾓﾃｻｾｺｯﾊ END **************/
/***********************************************/




/***********************************************/
/*************  ｹｫﾓﾃﾒｳﾃ貅ｯﾊ *******************/

function PrintSex(itemgender)
{
	if(itemgender == 'F')
		document.write('(ญ)');
	else if(itemgender == 'M')
		document.write('(ช)');

	return 0;
}

function Buy(name,itemno,price,vipprice, itemisvip)
{
	if(checkLogin())
	{
		if(checkVipShopBuy(itemisvip))
		{
			addItemQuantity(name,itemno,price,vipprice, 1,0,0,0);
			top.leftfra.cartnum.innerHTML = getCookie('cartLength')?getCookie('cartLength'):0;
		}
	}		
}

function Send(itemname,itemno,iNowMoney,iVipMoney,itemisvip)
{
	if(checkLogin())
	{
		if(checkVipShopSend(itemisvip))
		{
			var url="/mall/inc/don01.html?itemno="+itemno+"&nowprice="+iNowMoney+"&itemname="+itemname+"&vipprice="+iVipMoney+"&itemtype="+itemisvip;
//			var url="/mall/inc/don01.html?itemno="+itemno+"&nowprice="+iNowMoney+"&itemname="+escape(itemname)+"&vipprice="+iVipMoney+"&itemtype="+itemisvip;
			savetomall();
			window.location=url;
		 }  
	}	 
}

function SendFun(itemname,itemno,iNowMoney,iVipMoney,itemisvip)
{
	if(checkLogin())
	{
		if(checkVipShopSend(itemisvip))
		{
			var url="/mall/inc/don02.html?itemno="+itemno+"&nowprice="+iNowMoney+"&itemname="+itemname+"&vipprice="+iVipMoney+"&itemtype="+itemisvip;
			savetomall();
			window.location=url;
		 }  
	}	 
}

function AskFor(itemname,itemno,iNowMoney,iVipMoney,itemisvip)
{
	if(checkLogin())
	{
		if(checkVipShopAskfor(itemisvip))
		{
			var url="/mall/inc/req01.html?itemno="+itemno+"&nowprice="+iNowMoney+"&itemname="+itemname+"&vipprice="+iVipMoney;
			savetomall();
			window.location=url;
		}  
	}	 
}

function Recommend(itemno, itemisvip)
{
	if (checkLogin()) {
		if(checkVipShopBuy(itemisvip)) {
			savetomall();
			window.location="/cgi-bin/qqshow_user_addIntoShop?items=" + itemno;
		}
	}
}

function checkVipShopBuy(itemisvip)
{
	if (!parent.leftfra.isvip&&itemisvip==1)
	{
		
		if (confirm('สินค้าหน้านี้สำหรับสมาชิก VIP เท่านั้น คลิก OK เพื่อเลื่อนขั้นเป็นสมาชิก VIP')) {
			openVip();
		}
		return false;
	}
	else if (!parent.leftfra.isvip30&&itemisvip==2)
	{
		if (confirm('ขออภัยค่ะ สินค้านี้เป็นสินค้าในโซนผู้ได้รับบิ๊กแพคเกจ สมาชิกผู้ได้รับบิ๊กแพคเกจนี้ีเท่านั้นที่สามารถซื้อได้ \n คลิก "ยืนยัน" เพื่อขอเป็นผู้ได้รับบิ๊กแพคเกจ')) {
			openVip30();
		}
		return false;
	}	
	return true;	
}

function checkVipShopSend(itemisvip)
{
	if (!parent.leftfra.isvip&&itemisvip==1)
	{
		if (confirm('สินค้าหน้านี้สำหรับสมาชิก VIP เท่านั้น  \n คลิก OK เพื่อเลื่อนขั้นเป็นสมาชิก VIP')) {
			openVip();
		}
		return false;
	}
	else if (!parent.leftfra.isvip30&&itemisvip==2)
	{
		if (confirm('ขออภัยค่ะ สินค้านี้เป็นสินค้าในโซนผู้ได้รับบิ๊กแพคเกจ ผู้ได้รับบิ๊กแพคเกจเท่านั้นที่จะได้รับสิทธินี้ี \n คลิก "ยืนยัน " เพื่อขอเป็นผู้ได้รับบิ๊กแพคเกจ')) {
			openVip30();
		}
		return false;
	}	
	return true;	
}

function checkVipShopAskfor(itemisvip)
{
	if (!parent.leftfra.isvip&&itemisvip==1)
	{
		if (confirm('สินค้าหน้านี้สำหรับสมาชิก VIP เท่านั้น  \n คลิก OK เพื่อเลื่อนขั้นเป็นสมาชิก VIP')) {
			openVip();
		}
		return false;
	}
	else if (!parent.leftfra.isvip30&&itemisvip==2)
	{
		if (confirm('ขออภัยค่ะ สินค้านี้เป็นสินค้าในโซนผู้ได้รับบิ๊กแพคเกจ ผู้ได้รับบิ๊กแพคเกจเท่านั้นที่จะขอได้ \n คลิก "ยืนยัน" เพื่อขอเป็นผู้ได้รับบิ๊กแพคเกจ')) {
			openVip30();
		}
		return false;
	}	
	return true;	
}

function checkVipShopCollect(itemisvip)
{
	if (!parent.leftfra.isvip&&itemisvip==1)
	{
		if (confirm('ขออภัยค่ะ สินค้านี้เป็นสินค้าในโซนวีไอพี เมื่อได้รับแล้ว ท่านต้องอัพระดับตัวเองเป็นวีไอพีก่อนจึงจะสามารถซื้อสินค้าได้ \n คลิก " ยืนยัน"เพื่อขอเลื่อนเป็นวีไอพี' )) {
			openVip();
		}
	}
	return true;
}

function userPhoto(cl)
{
	var tFileNo;
	var itemnoArray = new Array;
	var itemno;
	var itemnos='';
	var j;
	var count=0;
	var flag;
	if(!confirm('ยืนยันการบันทึกหรือไม่'))
		return ;
	for (var i=1; i<26; i++)
	{
		flag = 0;
		tFileNo = qqshow.children[0].children[i].preFileNo;
		if(!tFileNo)
			continue;
		itemno = tFileNo;	
		for(j=0;j<i;j++)
			if(itemnoArray[j] == itemno)  
			{
				flag = 1;
				break;
			}
		if(flag == 0)
		{
			itemnoArray[count] = itemno;
			if (count != 0)
				itemnos = itemnos + '|';
			itemnos = itemnos + itemno;
			count ++;
		}
	}
	if(cl != 1)
		window.location = "/cgi-bin/qqshow_user_saveuserphoto?itemnum=" + count + "&itemnolist=" + itemnos;
	else
		window.location = "/cgi-bin/qqshow_user_saveuserphoto?cl=1&itemnum=" + count + "&itemnolist=" + itemnos;
}

function openVip()
{
		//vip=window.open('/vip/','vip');
		//vip=window.open('/vip/','vip','width=800,height=600');
		vip=window.open('/vip/','vip','toolbars=1, scrollbars=1, location=1, statusbars=1, menubars=1, resizable=1, width=800, height=600, left = 112, top = 84');
		//vip.focus();
}

function openVip30()
{
		
		vip.focus();
}

function PrintPrice(oriqbprice, nowqbprice, discountflag)
{
	if (new Number(discountflag) == 1)
	{
		var str='<strike>'+oriqbprice+'</strike> <font color=red><b>'+nowqbprice+'</b></font>';
		document.write(str);
	}
	else
		document.write(oriqbprice);

	return ;
}

/*************  ｹｫﾓﾃﾒｳﾃ貅ｯﾊ END ***************/
/***********************************************/


/***********************************************/
/*************  ﾋｽﾓﾐﾒｳﾃ貅ｯﾊ *******************/

//i_show.html
function otherpayav()
{
        var tFileNo;
        var itemnoArray = new Array;
        var itemno;
        var itemnos='';
        var j;
        var count=0;
        var flag;
        if(!confirm('ยืนยันที่จะให้เพื่อนซื้อ QQ Show ชุดนี้ให้หรือไม่'))
                return ;
        for (var i=1; i<26; i++)
        {
                flag = 0;
                tFileNo = qqshow.children[0].children[i].preFileNo;
                if(!tFileNo)
                        continue;
                itemno = tFileNo;
                for(j=0;j<i;j++)
                        if(itemnoArray[j] == itemno)
                        {
                                flag = 1;
                                break;
                        }
                if(flag == 0)
                {
                        itemnoArray[count] = itemno;
                        if (count != 0)
                                itemnos = itemnos + '|';
                        itemnos = itemnos + itemno;
                        count ++;
                }
        }
        setCookie('hislocation',parent.mainfra.location);
        parent.mainfra.location= "/cgi-bin/qqshow_user_ask_win?items=" + itemnos;
}

//i_login.htm
function userAv(cl)
{
	var tFileNo;
	var itemnoArray = new Array;
	var itemno;
	var itemnos='';
	var j;
	var count=0;
	var flag;

	if(!confirm('ยืนยันการบันทึกหรือไม่'))
		return ;
	for (var i=1; i<26; i++)
	{
		flag = 0;
		tFileNo = qqshow.children[0].children[i].preFileNo;
		if(!tFileNo)
			continue;
		itemno = tFileNo;	
		for(j=0;j<i;j++)
			if(itemnoArray[j] == itemno)  
			{
				flag = 1;
				break;
			}
		if(flag == 0)
		{
			itemnoArray[count] = itemno;
			if (count != 0)
				itemnos = itemnos + '|';
			itemnos = itemnos + itemno;
			count ++;
		}
	}
	
	var tmpUin = GetUin();
	if(tmpUin > 10000)
	{
		var saveshowname = tmpUin +'_saveshow';
		setCookie(saveshowname, itemnos);
	}
	var url = "/cgi-bin/qqshow_user_saveusershow?itemnum=" + count + "&itemnolist=" + itemnos + "&cl="+ cl + "&pagetype=2";  
        if(login && IsHeadChange(itemnos))
	{
                url += '&chghead=1';
	}
	window.location = url;
}

//reg.htm,m_m07.htm
function FillYear(yearID)
{
	var yearList=document.all(yearID);
	//for(var I=1990;I<2100;I++){
	for(var I=2010;I>1930;I--){
		var oOption = document.createElement("OPTION");
		oOption.text=""+I;
		oOption.value=""+I;
		if(I==1979)	oOption.selected=true;
		yearList.add(oOption);
	}
}
//m_m11.htm
function FillYear2006(yearID)
{
	var yearList=document.all(yearID);
	//for(var I=1990;I<2100;I++){
	for(var I=2010;I>=2005;I--){
		var oOption = document.createElement("OPTION");
		oOption.text=""+I;
		oOption.value=""+I;
		if(I==2005)	oOption.selected=true;
		yearList.add(oOption);
	}
}

//reg.htm,m_m07.htm
function FillMonth(monthID)
{
	var monthList=document.all(monthID);
	for(var I=1;I<13;I++){
	var oOption = document.createElement("OPTION");
		if(I<10){
			oOption.text="0"+I;
			oOption.value="0"+I;
		}else{
			oOption.text=""+I;
			oOption.value=""+I;
		}
		monthList.add(oOption);
	}
}

//reg.htm,m_m07.htm
function FillDay(dayID,maxDay)
{
	var count=document.all(dayID).length;
	for(var I=0;I<count;I++)
		document.all(dayID).remove(0);
		
	for(var I=1;I<=maxDay;I++){
	var oOption = document.createElement("OPTION");
		if(I<10){
			oOption.text="0"+I;
			oOption.value="0"+I;
		}else{
			oOption.text=""+I;
			oOption.value=""+I;
		}
			
		document.all(dayID).add(oOption);
	}		
}

function FillDayThai(dayID,maxDay)
{
        var count=document.all(dayID).length;
        if(count<maxDay)
        {
			for(var I=count+1;I<=maxDay;I++)
			{	
        		var oOption = document.createElement("OPTION");
                //document.getElementById("test").options[0].text = "abc"
				//document.getElementById("test").options[0].value = "def"
                oOption.text=""+I;
				oOption.value=""+I;
		document.all(dayID).add(oOption);       
      }
		}
		else if(count>maxDay)
		{
			for(var I=count;I>=maxDay;I--)
				document.all(dayID).remove(I);
		}
		
}
//ｺｯﾊMonthChange
function IsLeapYear(Year) 
{
	if(Math.round(Year/4) == Year/4){
		if(Math.round(Year/100) == Year/100){
			if(Math.round(Year/400) == Year/400)
				return true;
			else return false;
		}else return true;
	}
	return false;
}

//reg.htm,m_m07.htm
function YearChange(yearID,monthID,dayID)
{
//change by abit
//	document.all(monthID).selectedIndex=0;
	MonthChange(yearID,monthID,dayID);
}

//reg.htm,m_m07.htm
function MonthChange(yearID,monthID,dayID)
{
	var nowYear=new Number(document.all(yearID).value);
	var nowMonth=new Number(document.all(monthID).value);
	var maxDay=30;
	
	if(IsLeapYear(nowYear)){
	 if (nowMonth==2)
		maxDay=29;	
	}else{
	 if (nowMonth==2)
		maxDay=28;	
	}
 	if((nowMonth==1) || (nowMonth==3) || (nowMonth==5) || (nowMonth==7) || (nowMonth==8) || (nowMonth==10) || (nowMonth==12))
		maxDay=31;
	
	//change by abit
	FillDayThai(dayID,maxDay);

	//if(nowDay>maxDay)
	//	document.all(dayID).selectedIndex=0;		
	//else
	//	document.all(dayID).selectedIndex=nowDay-1;
}

//reg.htm,m_m07.htm
function getshowsex(itype)
{
	listname = new Array("<select size='1' name='sex'> <option value='M' selected>ผู้ชาย</option>  <option value='F'>ผู้หญิง</option></select> ","<select size='1' name='sex'> <option value='M'>ผู้ชาย</option>  <option value='F' selected>ผู้หญิง</option></select> ","<select size='1' name='sex'> <option value='M'>ผู้ชาย</option>  <option value='F'>ผู้หญิง</option></select> ");
	if(itype=="M")	document.write(listname[0]);	
	else if(itype=="F")	document.write(listname[1]);	
	else 	document.write(listname[2]);	
}

//reg.htm,m_m07.htm
function getUserPro(property)
{
	if(property=='1')
		document.write("สมาชิกวีไอพี");
	else
		document.write('สมาชิก QQ Show<a href="#"  onclick="window.open(\'/vip/\',\'subscribe\',\'width=448,height=300\');" style="color:#FF6600;margin-left:3px;text-decoration:underline;">อัพเกรดเป็นสมาชิกวีไอพี</a>');
}

/*************  ﾋｽﾓﾐﾒｳﾃ貅ｯﾊ END ***************/
/***********************************************/
