///////// JScript File

function ShowFlash(filepath, width, height)
{
	document.write(" <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+width+"\" height=\""+height+"\" VIEWASTEXT> ");
	document.write(" 		<param name=\"movie\" value=\""+filepath+"\"> ");
	document.write(" 		<param name=\"quality\" value=\"high\"> ");
	document.write(" 		<param name=\"wmode\" value=\"transparent\"> ");
	document.write(" 		<param name=\"menu\" value=\"false\" /> ");
	document.write("        <param name=\"allowScriptAccess\" value=\"always\" />");
	document.write(" 		<embed src=\""+filepath+"\" allowScriptAccess=\"always\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\" wmode=\"transparent\" menu=\"false\" ></embed> ");
	document.write(" </object> ");
}
function ddlActivation(country)
{var sDiv = document.getElementById("location_state");
    if(country!="220")
        sDiv.disabled=true;
    else
        sDiv.disabled=false;
}
function getQueryVariable(variable) 
{  
    var query = window.location.search.substring(1);  
    var vars = query.split("&");  
    for (var i=0;i<vars.length;i++) 
    {    
        var pair = vars[i].split("=");    
        if (pair[0] == variable) 
        {      
            return pair[1];    
        }  
    } 
    return null;
}

function getCategory()
{
    var currUrl = location.href;
        
    if (currUrl.indexOf("boardNo=20")>0){
        currPage="menu3";
        return currPage;}
    if (currUrl.indexOf("boardNo=102")>0){
        currPage="menu2";
        return currPage;}
    if (currUrl.indexOf("boardNo=101") >0){
        currPage="menu1";
        return currPage;}
    currPage="menu1";
    return currPage;
}

function ImgNext(category,lastno)
{
    var image_no_1,image_no_2,image_no_3;
    image_no_1 = document.images[category+"1"].src;
    image_no_2 = document.images[category+"2"].src;
    image_no_3 = document.images[category+"3"].src;
    var startIndex,endIndex;
    var next_images_no_1,next_images_no_2,next_images_no_3;
    startIndex = image_no_3.indexOf("m_shot")+6;
    endIndex = image_no_3.indexOf(".gif");
    image_no_1= image_no_3.substring(startIndex,endIndex);
    image_no_1 = parseInt(image_no_1)-2;
    
    next_images_no_1 = parseInt(image_no_1)+3;
    if(lastno < next_images_no_1){
        next_images_no_1 = 1;
    }
    next_images_no_2 = next_images_no_1+1;
    if(lastno < next_images_no_2){
        next_images_no_2 = 1;
    }
    next_images_no_3 = next_images_no_2+1;
    if(lastno < next_images_no_3){
        next_images_no_3 = 1;
    }
    document.images[category+"1"].src="http://nxcache.nexon.net/mabinogi/images/multimedia/"+category+"/m_shot"+next_images_no_1+".gif";
    document.images[category+"2"].src="http://nxcache.nexon.net/mabinogi/images/multimedia/"+category+"/m_shot"+next_images_no_2+".gif";
    document.images[category+"3"].src="http://nxcache.nexon.net/mabinogi/images/multimedia/"+category+"/m_shot"+next_images_no_3+".gif";
}

function ImgPrev(category,lastno)
{
    var image_no_1,image_no_2,image_no_3;
    image_no_1 = document.images[category+"1"].src;
    image_no_2 = document.images[category+"2"].src;
    image_no_3 = document.images[category+"3"].src;
    var startIndex,endIndex;
    var next_images_no_1,next_images_no_2,next_images_no_3;
    startIndex = image_no_1.indexOf("m_shot")+6;
    endIndex = image_no_1.indexOf(".gif");
    image_no_1= image_no_1.substring(startIndex,endIndex);
    image_no_1 = parseInt(image_no_1)+2;
    
    next_images_no_1 = parseInt(image_no_1)-3;
    if(1 > next_images_no_1){
        next_images_no_1 = lastno;
    }
    next_images_no_2 = next_images_no_1-1;
    if(1 > next_images_no_2){
        next_images_no_2 = lastno;
    }
    next_images_no_3 = next_images_no_2-1;
    if(1 > next_images_no_3){
        next_images_no_3 = lastno;
    }
    document.images[category+"1"].src="http://nxcache.nexon.net/mabinogi/images/multimedia/"+category+"/m_shot"+next_images_no_3+".gif";
    document.images[category+"2"].src="http://nxcache.nexon.net/mabinogi/images/multimedia/"+category+"/m_shot"+next_images_no_2+".gif";
    document.images[category+"3"].src="http://nxcache.nexon.net/mabinogi/images/multimedia/"+category+"/m_shot"+next_images_no_1+".gif";
}
function Multimedia(id)
{
    var tabs=new Array("wallpaper","screenshot","videoclip");
    var tabDiv;
    var tableDiv;
    
    for (var i=0 ; i<tabs.length; i++)
    {
        if (tabs[i] == id)
        {
            tabDiv = document.getElementById("tab"+id);
            tableDiv = document.getElementById(id);
            tableDiv.style.display ="inline";
            tabDiv.style.display ="inline";
        }else
        {
            tabDiv = document.getElementById("tab"+tabs[i]);
            tableDiv = document.getElementById(tabs[i]);
            tableDiv.style.display ="none";
            tabDiv.style.display ="none";
        }
    }
    
}

function getSubCategory()
{
    var currUrl = location.href;
    if (currUrl.indexOf("boardNo=201")>0){
        return 4;}
    if (currUrl.indexOf("boardNo=202")>0){
        return 5;}
    return 0;
}

function ResizeParentFrameSize()
{
	iframeobj = window.parent.document.getElementById("shopiframe");
	if(iframeobj)
	{
		iframeobj.height = 0;
		iframeobj.height = document.body.scrollHeight;
	}
}

function ChangeLink(page)
{
    var link = document.getElementById("List");//alert(link.innerHTML.replace(/View.aspx?/g,"Poll.aspx?event=result&"));
    link.innerHTML = link.innerHTML.replace(/View.aspx\?/g,page);

}
function get_url_param(name)
{ 
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
    var regexS = "[\\?&]"+name+"=([^&#]*)"; 
    var regex = new RegExp( regexS ); 
    var results = regex.exec( window.location.href ); 
    if( results == null )    return ""; 
    else return results[1];
}
var count = 600;
function ComposerCategoryTab_onLoad(img,id)
{
//    if(count==id)
//    {   
//        if(id==get_url_param('boardNo')){
//            img.src="http://nxcache.nexon.net/mabinogi/images/composer_category_"+id+"_on.gif";
//        }
//        count=count+1;
//    }

}
function ComposerCategoryTab_MouseOver(img,id)
{
    img.src="http://nxcache.nexon.net/mabinogi/images/composer_category_"+id+"_on.gif";
}
function ComposerCategoryTab_MouseOut(img,id)
{
    if(id!=get_url_param('boardNo')){
    img.src="http://nxcache.nexon.net/mabinogi/images/composer_category_"+id+"_off.gif";
    }
}
function ComposerCategoryTab_Click(id)
{
location.href="../Community/Composer.aspx?boardNo="+id+"&pageIndex=1";
//../Community/Composer.aspx?boardNo=600&pageIndex=1
}
function ComposerEventProhibit(cat)
{
	if(cat == '6')
	{
	    alert("Currently, you may not make a post under 'Event' category because there is no event in progress.");
	    var sDiv = document.getElementById("ctl00_ctl00_MainCPH_SubContentCPH_ddlCategory");
	    sDiv.selectedIndex= 4;
	}
}

function SectionCollapse(id)
{
    var dDiv = document.getElementById(id);
    if(dDiv.style.display == "none")
    {
        dDiv.style.display="inline";
    }
    else
    {
        dDiv.style.display="none";
    }
}

function CustomCheckBox(obj)
{
    if(obj.src == CheckedImgPath)
        obj.src=UnCheckedImgPath;
    else
        obj.src=CheckedImgPath;
}
function ShowPreview(referrer)
{

    //var index_of_intro = referrer.indexOf("mabinogi.nexon.net/intro");
    //alert(readCookie("Preview"));
    if(!ExistSomeCookie("Preview")&& !ExistSomeCookie("IntroVisiting") )
    {
        location.href='http://mabinogi.nexon.net/Preview/intro.htm';
    //alert(index_of_intro);
    }
}
function ExistSomeCookie(key)
{
    if (readCookie(key) == "1")
        return true;
    else
        return false;

}

function createCookie(name,value,days) {
	    if (days) {
		    var date = new Date();
		    date.setTime(date.getTime()+(days*24*60*60*1000));
		    var expires = "; expires="+date.toGMTString();
	    }
	    else var expires = "";
	    document.cookie = name+"="+value+expires+"; path=/";
	    //window.location.href = 'http://mabinogi.nexon.net'; 
    }

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}

function PreviewPageCookieSetting()
{
    var objCheckBox = document.getElementById("checkbox").src;
    if(objCheckBox == CheckedImgPath)
    {
        createCookie("Preview","1",7);
    }else
    {
        createCookie("Preview","1",0);
    }
    //alert("cookie value : "+readCookie("Preview"));
    location.href="http://mabinogi.nexon.net";
}
//eraseCookie("Preview");
//alert("cookie value : "+readCookie("Preview"));
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return null;
}
function openBeginnerGuide(){
          window.open('http://mabinogi.nexon.net/Guide/Beginner.aspx','newWin','width=770,height=600,left=0,top=0, scrollbars=No,resizable=No');NewWindow.focus ();void(0);
}
function openHousingGuide(){
           window.open('http://mabinogi.nexon.net/Guide/Housing/housingC2.html', '_blank', 'width=1000, height=700, scrollbars=0');if (newWin == null){alert('Your browser is preventing popup windows from being displayed. Please enable popups for this site.');}else{newWin.focus();}
}
