// START - code moved from HTML file

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function PageLoaded () {
	clicky.init (181206);
	if (typeof(_gat) == 'object') {
		var pageTracker = _gat._getTracker("UA-1699977-2");
		pageTracker._initData();
		pageTracker._trackPageview();
	}
}

function loadpage(url) {
    if (window.opener && !window.opener.closed) {
    	  window.opener.location.href = url;
    } else {
        window.open(url, 'ooShirts Design Lab');
    }
    window.close();
}

// END - code moved from HTML file








function show_loading()
{
        document.getElementById('loading').style.display = "block";
        document.getElementById('submit').value='Uploading...';
        document.getElementById('newupload').submit;
        document.getElementById('submit').disabled = true;
        return true;
}

function show_error(err)
{
        document.getElementById('error').innerHTML=err;
        document.getElementById('loading').style.display = "none";
        document.getElementById('submit').disabled = false;
        document.getElementById('submit').value='Upload';
}
// CECKOUT STEP
function billship_card(type)
	{
	var same=document.getElementById('billship_charge').checked;

	if(same==true)
		{
		document.getElementById('charge_address').value=document.getElementById('ship_address1').value;
		document.getElementById('charge_city').value=document.getElementById('ship_city').value;
		document.getElementById('charge_state').value=document.getElementById('ship_state').value;
		document.getElementById('charge_zip').value=document.getElementById('ship_zip').value;
		document.getElementById('charge_country').value=document.getElementById('ship_country').value;
		document.getElementById('charge_phone').value=document.getElementById('ship_phone').value;
		}

	return false;
	}
function billship_checks(type)
	{
	var same=document.getElementById('billship_check').checked;

	if(same==true)
		{
		document.getElementById('check_address1').value=document.getElementById('ship_address1').value;
		document.getElementById('check_address2').value=document.getElementById('ship_address2').value;
		document.getElementById('check_city').value=document.getElementById('ship_city').value;
		document.getElementById('check_state').value=document.getElementById('ship_state').value;
		document.getElementById('check_zip').value=document.getElementById('ship_zip').value;
		}

	return false;
}

function billship_purches(type)
{
	var same=document.getElementById('billship_po').checked;

	if(same==true)
		{
		document.getElementById('po_address1').value=document.getElementById('ship_address1').value;
		document.getElementById('po_address2').value=document.getElementById('ship_address2').value;
		document.getElementById('po_city').value=document.getElementById('ship_city').value;
		document.getElementById('po_state').value=document.getElementById('ship_state').value;
		document.getElementById('po_zip').value=document.getElementById('ship_zip').value;
		document.getElementById('po_country').value=document.getElementById('po_country').value;
		}

	return false;
}

function ship_sameas_contact()
{
	var same=document.getElementById('do_cont').checked;

	if(same==true)
		{
		document.getElementById('ship_fname').value=document.getElementById('cont_fname').value;
		document.getElementById('ship_lname').value=document.getElementById('cont_lname').value;
		document.getElementById('ship_phone').value=document.getElementById('cont_phone').value;
		}

	return false;
}
function ship_sameas_calculation()
{
	var same=document.getElementById('do_cal').checked;

	if(same==true)
		{
		document.getElementById('ship_zip').value=document.getElementById('cal_zipcode').value;

		}

	return false;
}
function checkout_submit(name)
{
	if(name!='')
	{
		document.getElementById('buttons').value=name;
	}

	document.getElementById('frmid').submit();
}

function calculate_shippingcost(type,basecost)
{

	var extra_shipping_cost;
	//var shipcost = document.getElementById('shipcost').value;

	if(type=='rush')
		{extra_shipping_cost=(basecost/100)*25;} else{extra_shipping_cost=0.00;}


	//document.getElementById('shippingcost').value= Math.round(extra_shipping_cost*100)/100;
	document.getElementById('shippingcost_view').innerHTML=Math.round(extra_shipping_cost*100)/100;
	//document.getElementById('total').value=Math.round((basecost+extra_shipping_cost)*100)/100;
	//var shipping_cost = extra_shipping_cost+shipcost;
	//alert(shipping_cost);
	document.getElementById('total_view').innerHTML=Math.round((basecost+extra_shipping_cost)*100)/100;
	//document.getElementById('check_amount').value=basecost+shipping_cost;


	return false;
}

//END CHECKOUT
function show_error2(err)
{
        alert(err);
        /*$('error').update(err);
        $('loading').hide();
        $('submit').enable();
        $('submit').value='Upload';*/
}

function show_error3(err)
{
        alert(err);

/*        $('error').update(err);
        $('loading').hide();
        $('submit').enable();
        $('submit').value='Upload';
        */
}

function celeb(cat_id,action)
{
        window.location.href= "index.php?module=admin&action="+action+"&catid="+cat_id;
}

function select_color(n)
{
	if(n>0)
	{
		for(i=1;i<=n;i++)
		{
			document.getElementById('color'+i).style.display='block';
		}
	}
}
function view_orders_page(status)
{
      window.location.href= "index.php?module=admin&action=view_orders&status="+status;
}
function page_go_action(pageno,action)
{
      if(pageno >0)
      window.location.href= action+"&page="+pageno;
}
function go_page(pageno,action)
{
      if(pageno >0)
      window.location.href= "index.php?module=admin&action="+action+"&page="+pageno;
}

function viewbanpage_go(pageno)
{
      if(pageno >0)
      window.location.href= "index.php?module=admin&action=viewban&page="+pageno;
}

function page_del(pageno)
{
      if(pageno >0)
      window.location.href= "index.php?module=admin&action=massdel&page="+pageno;
}

function image_del(pageno)
{
      if(pageno >0)
      window.location.href= "index.php?module=admin&action=massdel&month="+pageno;
}

function viewpage_del(pageno,gal_i)
{
      var gal=gal_i

      if(pageno >0)
     window.location.href= "index.php?module=profile&action=viewimages&gal_id="+gal+"&page="+pageno;
}

function arenapage_del(pageno)
{
      if(pageno >0)
      window.location.href= "index.php?module=profile&action=memberarena&page="+pageno;
}


function view_gallery(gallery)
{
      if(gallery >0)
      window.location.href= "index.php?module=profile&action=viewimages&gallery="+gallery;
}

function confirmban()
{
        return confirm('Are you sure you want to ban this users?');
}


function confirmdel()
{
        return confirm('Are you sure you want to Delete?');
}
function confirmactive()
{
        return confirm('Are you sure you want to Active?');
}
function confirminactive()
{
        return confirm('Are you sure you want to Inactive?');
}
function confirmage()
{
        return confirm('Are you 18 years old?');
}


function confirmdecline()
{
        return confirm('Are you sure you want to Decline?');
}

function check_all(name, value, formid) {

        formblock= document.getElementById(formid);
        forminputs = formblock.getElementsByTagName('input');

        for (i = 0; i < forminputs.length; i++)
        {
                // regex here to check name attribute
                var regex = new RegExp(name, "i");
                if (regex.test(forminputs[i].getAttribute('name')))
                {
                        if (value == '1')
                        {
                                forminputs[i].checked = true;
                        } else
                        {
                                forminputs[i].checked = false;
                        }
                }
        }
        return false;
}

function framecheck(section)
{
        if( self == top )
        {
                var url = "/webadmin/home.aspx";

                switch(section)
                {
                        case "home":
                                url = '/webadmin/home.aspx';
                                break;
                        case "contacts":
                                url = '/webadmin/contacts.aspx';
                                break;
                        case "accounts":
                                url = '/webadmin/accounts.aspx';
                                break;
                        case "settings":
                                url = '/webadmin/settings.aspx';
                                break;
                        case "site":
                                url = '/webadmin/site.aspx';
                                break;
                }
                this.location = url ;
        }
}

function description(des)
{
	alert(des);
	des.select();
}

function highlight(sel)
{
sel.select();
}


function c(des)
{
	des.value='';
}


function addBookmark(favouriteurl,favouritetitle)
{
    if ( window.sidebar )
    { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(favouritetitle, favouriteurl,"");
    }
    if ( document.all )
    { // Internet Explorer AddFavourite
      window.external.AddFavorite(favouriteurl,favouritetitle);
	}
	return false;
}

function payment(pay)
{

if(pay=='0')
{
window.location.href= "index.php?module=admin&action=reward&method="+pay;
}
else
{
window.location.href= "index.php?module=admin&action=reward&method="+pay;
}
}
function view_preview(id)
{
    var name="preview"+id.toString();

    id=document.getElementById(name);
    id.style.display="block";
}

function hide_block(id)
{
    var name="preview"+id.toString();
    id=document.getElementById(name);
    id.style.display="none";
}


//sahbaj

function viewsubpcat(p)
{
	if(p>0)
	window.location.href = "index.php?module=admin&action=view_sub_pcat&page="+p;
}

function viewpcat(p)
{
	if(p>0)
	window.location.href = "index.php?module=admin&action=view_pcat&page="+p;
}

/* function catsel(c,s,n)
{
	window.location.href = "index.php?module=admin&action=add_products&catid="+c+"&subid="+s+"&num="+n;
} */

function colorno(field1)
{
	for(i=3;i>field1;i--)
	{
		document.getElementById('plain'+i).style.display='none';
	}

	for(i=1;i<=field1;i++)
	{
		document.getElementById('plain'+i).style.display='block';
	}
	return false;
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=420,height=605,screenX=120,screenY=160,top=150,left=100')
}

function parent_opener(url)
{
	parent.location.href = 'http://localhost/aaa';
	//window.close();
	return false;
}

function selected_color (index, total_color, colorcode, additional_cost) {
	for (var i=0; i<total_color; i++) {
		var Obj1 = document.getElementById ('color' + i);
		if (Obj1) { Obj1.style.display = 'none'; }
		// else { alert ('selected_color error 1'); }
	}
	var Obj2 = document.getElementById ('colorcode');
	if (Obj2) { Obj2.value = colorcode; }
	// else { alert ('selected_color error 2'); }
	var Obj3 = document.getElementById ('color_cost');
	if (Obj3) { Obj3.value = additional_cost; }
	// else { alert ('selected_color error 3'); }
	var Obj4 = document.getElementById ('color' + index);
	if (Obj4) { Obj4.style.display = 'block'; }
	// else { alert ('selected_color error 4'); }
	return false;
}
